Skip to content

Fix for issue 661 #720

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 1 commit into from
Mar 2, 2020
Merged
Changes from all commits
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
28 changes: 25 additions & 3 deletions projects/lib/src/oauth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ export class OAuthService extends AuthConfig implements OnDestroy {
public loadDiscoveryDocumentAndLogin(options: LoginOptions = null): Promise<boolean> {
return this.loadDiscoveryDocumentAndTryLogin(options).then(_ => {
if (!this.hasValidIdToken() || !this.hasValidAccessToken()) {
this.initImplicitFlow();
if(this.responseType === 'code'){
this.initCodeFlow();
} else {
this.initImplicitFlow();
}
return false;
} else {
return true;
Expand Down Expand Up @@ -1794,7 +1798,13 @@ export class OAuthService extends AuthConfig implements OnDestroy {
this.logger.warn(err);
return Promise.reject(err);
}

// at_hash is not applicable to authorization code flow
// addressing https://github.com/manfredsteyer/angular-oauth2-oidc/issues/661
// i.e. Based on spec the at_hash check is only true for implicit code flow on Ping Federate
// https://www.pingidentity.com/developer/en/resources/openid-connect-developers-guide.html
if(this.hasOwnProperty('responseType') && this.responseType === 'code'){
this.disableAtHashCheck = true;
}
if (
!this.disableAtHashCheck &&
this.requestAccessToken &&
Expand Down Expand Up @@ -1832,7 +1842,19 @@ export class OAuthService extends AuthConfig implements OnDestroy {
idTokenHeader: header,
loadKeys: () => this.loadJwks()
};

if(this.disableAtHashCheck){
return this.checkSignature(validationParams).then(_ => {
const result: ParsedIdToken = {
idToken: idToken,
idTokenClaims: claims,
idTokenClaimsJson: claimsJson,
idTokenHeader: header,
idTokenHeaderJson: headerJson,
idTokenExpiresAt: expiresAtMSec
};
return result;
});
}

return this.checkAtHash(validationParams)
.then(atHashValid => {
Expand Down