File tree Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -895,7 +895,8 @@ export class OAuthService {
895895 return Promise . reject ( 'Either requestAccessToken or oidc or both must be true.' ) ;
896896 }
897897
898- if ( this . requestAccessToken && ( ! accessToken || ! state ) ) return Promise . resolve ( ) ;
898+ if ( this . requestAccessToken && ! accessToken ) return Promise . resolve ( ) ;
899+ if ( this . requestAccessToken && ! options . disableOAuth2StateCheck && ! state ) return Promise . resolve ( ) ;
899900 if ( this . oidc && ! idToken ) return Promise . resolve ( ) ;
900901
901902 var stateParts = state . split ( ';' ) ;
@@ -905,22 +906,16 @@ export class OAuthService {
905906 var nonceInState = stateParts [ 0 ] ;
906907
907908
908- // Our state might be URL encoded
909- // Check for this and then decode it if it is
910- // TODO: Check this!
911- /*
912- let decodedState = decodeURIComponent(state);
913- if (decodedState != state) {
914- state = decodedState;
915- }
916- */
917- if ( this . requestAccessToken ) {
909+ if ( this . requestAccessToken && ! options . disableOAuth2StateCheck ) {
918910 let success = this . validateNonceForAccessToken ( accessToken , nonceInState ) ;
919911 if ( ! success ) {
920912 let event = new OAuthErrorEvent ( 'invalid_nonce_in_state' , null ) ;
921913 this . eventsSubject . next ( event ) ;
922914 return Promise . reject ( event ) ;
923915 }
916+ }
917+
918+ if ( this . requestAccessToken ) {
924919 this . storeAccessTokenResponse ( accessToken , null , parts [ 'expires_in' ] ) ;
925920 }
926921
Original file line number Diff line number Diff line change 11{
22 "name" : " angular-oauth2-oidc" ,
3- "version" : " 2.0.11 " ,
3+ "version" : " 2.0.12 " ,
44 "repository" : {
55 "type" : " git" ,
66 "url" : " https://github.com/manfredsteyer/angular-oauth2-oidc"
Original file line number Diff line number Diff line change @@ -31,6 +31,16 @@ export class LoginOptions {
3131 * pass the iframes hash fragment to this method.
3232 */
3333 customHashFragment ?: string ;
34+
35+ /**
36+ * Set this to true to disable the oauth2 state
37+ * check which is a best practice to avoid
38+ * security attacks.
39+ * As OIDC defines a nonce check that includes
40+ * this, this can be set to true when only doing
41+ * OIDC.
42+ */
43+ disableOAuth2StateCheck ?: boolean ;
3444}
3545
3646/**
You can’t perform that action at this time.
0 commit comments