Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue in AbstractAuthorizationGrantHandler #904

Open
tbaker57 opened this issue Jun 22, 2018 · 0 comments
Open

Issue in AbstractAuthorizationGrantHandler #904

tbaker57 opened this issue Jun 22, 2018 · 0 comments

Comments

@tbaker57
Copy link

tbaker57 commented Jun 22, 2018

Description:

Hi there,

I'm trying to follow https://docs.wso2.com/display/AM210/Securing+OAuth+Token+with+HMAC+Validation and am encountering an error with trying to use https://github.com/lahirus/oauth-hmac-extension/blob/master/src/main/java/com/sample/lahiru/wso2/hmac/oauth/OAuthHMACTokenIssuer.java as a alternative token generator.

When the sample OAuthHMACTokenIssuer calls

 public String accessToken(OAuthTokenReqMessageContext tokReqMsgCtx)

the validity period in the tokReqMsgCtx is always -1. I believe this is due to the code https://github.com/wso2-extensions/identity-inbound-auth-oauth/blob/master/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/token/handlers/grant/AbstractAuthorizationGrantHandler.java#L272

AccessTokenDO newTokenBean = createNewTokenBean(tokReqMsgCtx, oAuthAppBean, existingTokenBean, timestamp,
                validityPeriodInMillis);
setDetailsToMessageContext(tokReqMsgCtx, validityPeriodInMillis, newTokenBean, timestamp);

Here createNewTokenBean has a tokReqMsgCtx with default values (e.g. validityPeriod has not been set yet). Since the validity period is -1, the enhanced token (with expiry timestamp and HMAC field) always fails validation.

I think the solution is to change the order of the calls above so that tokReqMsgCtx has all the details needed to create the access token (with the correct timestamp field).

P.S. The OAuthHMACTokenIssuer sample works fine in the 'implicit grant' case (since it doesn't use the AbstractAuthorizationGrantHandler class) - only the 'authorization code grant' case seems broken.

Suggested Labels:

Suggested Assignees:

Affected Product Version:

OS, DB, other environment details and versions:

Steps to reproduce:

Related Issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant