Skip to content

State improvements #224

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

Merged
merged 4 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion angular-oauth2-oidc/src/auth.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,12 @@ export class AuthConfig {
* Normally, the discovey document's url starts with the url of the issuer.
*/
public skipIssuerCheck? = false;


/*
* final state sent to issuer is built as follows:
* state = nonce + nonceStateSeparator + additional state
* Default separator is ';' (encoded %3B).
* In rare cases, this character might be forbidden or inconvenient to use by the issuer so it can be customized.
*/
public nonceStateSeparator = ';';
Copy link

@vdyalex vdyalex Jan 28, 2018

Choose a reason for hiding this comment

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

It should be optional to the user. However, it needs a default value. Consider using nonceStateSeparator?= ';'

Copy link
Author

Choose a reason for hiding this comment

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

Thx @alexndreazevedo, good point. It is changed.

}
13 changes: 3 additions & 10 deletions angular-oauth2-oidc/src/oauth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ export class OAuthService
return this.createAndSaveNonce().then((nonce: any) => {

if (state) {
state = nonce + ';' + state;
state = nonce + this.config.nonceStateSeparator + state;
}
else {
state = nonce;
Expand Down Expand Up @@ -1125,19 +1125,12 @@ export class OAuthService
}

let nonceInState = state;
let idx = state.indexOf(';');
let idx = state.indexOf(this.config.nonceStateSeparator);

if ( idx > -1) {
nonceInState = state.substr(0, idx);
this.state = state.substr(idx+1);
this.state = state.substr(idx + this.config.nonceStateSeparator.length);
}
/*
let stateParts = state.split(';');
if (stateParts.length > 1) {
this.state = stateParts[1];
}
*/
// let nonceInState = stateParts[0];

if (this.requestAccessToken && !options.disableOAuth2StateCheck) {
let success = this.validateNonceForAccessToken(accessToken, nonceInState);
Expand Down