Skip to content

Commit 88fb662

Browse files
committed
Fix for issue 661
1 parent a1652dc commit 88fb662

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

projects/lib/src/oauth-service.ts

+25-3
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ export class OAuthService extends AuthConfig implements OnDestroy {
225225
public loadDiscoveryDocumentAndLogin(options: LoginOptions = null): Promise<boolean> {
226226
return this.loadDiscoveryDocumentAndTryLogin(options).then(_ => {
227227
if (!this.hasValidIdToken() || !this.hasValidAccessToken()) {
228-
this.initImplicitFlow();
228+
if(this.responseType === 'code'){
229+
this.initCodeFlow();
230+
} else {
231+
this.initImplicitFlow();
232+
}
229233
return false;
230234
} else {
231235
return true;
@@ -1794,7 +1798,13 @@ export class OAuthService extends AuthConfig implements OnDestroy {
17941798
this.logger.warn(err);
17951799
return Promise.reject(err);
17961800
}
1797-
1801+
// at_hash is not applicable to authorization code flow
1802+
// addressing https://github.com/manfredsteyer/angular-oauth2-oidc/issues/661
1803+
// i.e. Based on spec the at_hash check is only true for implicit code flow on Ping Federate
1804+
// https://www.pingidentity.com/developer/en/resources/openid-connect-developers-guide.html
1805+
if(this.hasOwnProperty('responseType') && this.responseType === 'code'){
1806+
this.disableAtHashCheck = true;
1807+
}
17981808
if (
17991809
!this.disableAtHashCheck &&
18001810
this.requestAccessToken &&
@@ -1832,7 +1842,19 @@ export class OAuthService extends AuthConfig implements OnDestroy {
18321842
idTokenHeader: header,
18331843
loadKeys: () => this.loadJwks()
18341844
};
1835-
1845+
if(this.disableAtHashCheck){
1846+
return this.checkSignature(validationParams).then(_ => {
1847+
const result: ParsedIdToken = {
1848+
idToken: idToken,
1849+
idTokenClaims: claims,
1850+
idTokenClaimsJson: claimsJson,
1851+
idTokenHeader: header,
1852+
idTokenHeaderJson: headerJson,
1853+
idTokenExpiresAt: expiresAtMSec
1854+
};
1855+
return result;
1856+
});
1857+
}
18361858

18371859
return this.checkAtHash(validationParams)
18381860
.then(atHashValid => {

0 commit comments

Comments
 (0)