@@ -225,7 +225,11 @@ export class OAuthService extends AuthConfig implements OnDestroy {
225
225
public loadDiscoveryDocumentAndLogin ( options : LoginOptions = null ) : Promise < boolean > {
226
226
return this . loadDiscoveryDocumentAndTryLogin ( options ) . then ( _ => {
227
227
if ( ! this . hasValidIdToken ( ) || ! this . hasValidAccessToken ( ) ) {
228
- this . initImplicitFlow ( ) ;
228
+ if ( this . responseType === 'code' ) {
229
+ this . initCodeFlow ( ) ;
230
+ } else {
231
+ this . initImplicitFlow ( ) ;
232
+ }
229
233
return false ;
230
234
} else {
231
235
return true ;
@@ -1794,7 +1798,13 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1794
1798
this . logger . warn ( err ) ;
1795
1799
return Promise . reject ( err ) ;
1796
1800
}
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
+ }
1798
1808
if (
1799
1809
! this . disableAtHashCheck &&
1800
1810
this . requestAccessToken &&
@@ -1832,7 +1842,19 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1832
1842
idTokenHeader : header ,
1833
1843
loadKeys : ( ) => this . loadJwks ( )
1834
1844
} ;
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
+ }
1836
1858
1837
1859
return this . checkAtHash ( validationParams )
1838
1860
. then ( atHashValid => {
0 commit comments