Skip to content

Commit

Permalink
Assume requested scopes when response response doesn't contain scope I…
Browse files Browse the repository at this point in the history
  • Loading branch information
brockallen committed Aug 7, 2019
1 parent 251f737 commit d6e83ac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/ResponseValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ export class ResponseValidator {
return Promise.reject(new Error("Unexpected code in response"));
}

if (!response.scope) {
// if there's no scope on the response, then assume all scopes granted (per-spec) and copy over scopes from original request
response.scope = state.scope;
}

return Promise.resolve(response);
}

Expand Down
2 changes: 1 addition & 1 deletion src/SigninRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class SigninRequest {
data, client_id, authority, redirect_uri,
code_verifier: code,
request_type, response_mode,
client_secret });
client_secret, scope });

url = UrlUtility.addQueryParam(url, "client_id", client_id);
url = UrlUtility.addQueryParam(url, "redirect_uri", redirect_uri);
Expand Down
9 changes: 7 additions & 2 deletions src/SigninState.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { JoseUtil } from './JoseUtil.js';
import random from './random.js';

export class SigninState extends State {
constructor({nonce, authority, client_id, redirect_uri, code_verifier, response_mode, client_secret} = {}) {
constructor({nonce, authority, client_id, redirect_uri, code_verifier, response_mode, client_secret, scope} = {}) {
super(arguments[0]);

if (nonce === true) {
Expand Down Expand Up @@ -35,6 +35,7 @@ export class SigninState extends State {
this._client_id = client_id;
this._response_mode = response_mode;
this._client_secret = client_secret;
this._scope = scope;
}

get nonce() {
Expand All @@ -61,6 +62,9 @@ export class SigninState extends State {
get client_secret() {
return this._client_secret;
}
get scope() {
return this._scope;
}

toStorageString() {
Log.debug("SigninState.toStorageString");
Expand All @@ -75,7 +79,8 @@ export class SigninState extends State {
authority: this.authority,
client_id: this.client_id,
response_mode: this.response_mode,
client_secret: this.client_secret
client_secret: this.client_secret,
scope: this.scope
});
}

Expand Down

0 comments on commit d6e83ac

Please sign in to comment.