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

Add error message when there is no access_token and id_token is HS256 #727

Merged
merged 6 commits into from
Apr 18, 2018

Conversation

luisrudge
Copy link
Contributor

No description provided.

@luisrudge luisrudge changed the title [Don't Merge] Add error message when there is no access_token and id_token is HS256 Add error message when there is no access_token and id_token is HS256 Apr 6, 2018
@luisrudge
Copy link
Contributor Author

var noAccessTokenError = {
error: 'invalid_token',
description: 'The id_token cannot be validated because it was signed with the HS256 algorithm and public clients (like a browser) can’t store secrets. Please read the associated doc for possible ways to fix this.',
error_uri: 'https://auth0.com/docs/errors/libraries/auth0-js/invalid-token#parsing-an-hs256-signed-id-token-without-an-access-token'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a new field on the "error object" or you have already been using it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you hardcoding the URL? IMO this is not easy to maintain. Anyway, instead of adding a new property to the error object I'd append it to the description.

@@ -1487,7 +1515,7 @@ describe('auth0.WebAuth', function() {
stub(SilentAuthenticationHandler.prototype, 'login', function(usePostMessage, cb) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clarify in the test name why this token validation is going to fail and which token you're talking about (I'm guessing the AT)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed the test, but I only changed the hash value it doesn't try to validate the access_token

@@ -95,7 +95,7 @@ describe('auth0.WebAuth', function() {
stub(SilentAuthenticationHandler.prototype, 'login', function(usePostMessage, cb) {
cb(
null,
'#state=foo&id_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IlF6R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-sO1PBHchpSo1WHeDYMlRrOFd9bh741sUuBuXdPQZ3Zb0i2sNOAC2RFB1E11mZn7uNvVPGdPTg-Y5xppz30GSXoOJLbeBszfrVDCmPhpHKGGMPL1N6HV-3EEF77L34YNAi2JQ-b70nFK_dnYmmv0cYTGUxtGTHkl64UEDLi3u7bV-kbGky3iOOCzXKzDDY6BBKpCRTc2KlbrkO2A2PuDn27WVv1QCNEFHvJN7HxiDDzXOsaUmjrQ3sfrHhzD7S9BcCRkekRfD9g95SKD5J0Fj8NA'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have you changed this?

Copy link
Contributor Author

@luisrudge luisrudge Apr 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the AT so it doesn't try to validate it

@@ -283,6 +283,14 @@ WebAuth.prototype.validateAuthenticationResponse = function(options, parsedHash,
if (validationError.error !== 'invalid_token') {
return callback(validationError);
}
if (!parsedHash.access_token) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can you know with just this !parsedHash.access_token that the token is HS256 signed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ops, moved it below the .alg check

@@ -289,6 +289,14 @@ WebAuth.prototype.validateAuthenticationResponse = function(options, parsedHash,
if (decodedToken.header.alg !== 'HS256') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any chance that this get called with a HS384/512 alg? That also uses "raw secrets" and the warning message below would apply to them as well.

Copy link
Contributor

@lbalmaceda lbalmaceda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@luisrudge luisrudge merged commit 072ced2 into master Apr 18, 2018
@luisrudge luisrudge deleted the feature-no-AT-hs256-idtoken branch April 18, 2018 20:50
@luisrudge luisrudge added this to the v9.5.0 milestone Apr 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants