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

State missing in location header request in cas of invalid scope #667

Open
lemagicien00 opened this issue Nov 6, 2020 · 0 comments
Open

Comments

@lemagicien00
Copy link

When request an authorization code with invalid scope and state parameter, 'location' in response header does not contain '&state=xxxx' in the url.

While for the others invalid cases (missing 'code_type' and Invalid 'code_type') it is present.

It's because scope validation failed and then state not added in error response.

AuthorizeHandler.prototype.handle = function(request, response) {
//...
        .then(function(validScope) { // **<-------this throw an error and skip adding state**
          scope = validScope;

          return this.generateAuthorizationCode(client, user, scope);
        })
        .then(function(authorizationCode) {
          state = this.getState(request); // **<-------move this to first then()**
          ResponseType = this.getResponseType(request);

          return this.saveAuthorizationCode(authorizationCode, expiresAt, scope, client, uri, user);
        })
        .then(function(code) {
          var responseType = new ResponseType(code.authorizationCode);
          var redirectUri = this.buildSuccessRedirectUri(uri, responseType);

          this.updateResponse(response, redirectUri, state);

          return code;
        })

I suggest moving the state assignment to the first then.

best regards

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