File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -97,11 +97,14 @@ Strategy.prototype.authenticate = function(req, options) {
9797
9898 var idTokenSegments = idToken . split ( '.' )
9999 , jwtClaimsStr
100- , jwtClaims ;
100+ , jwtClaims
101+ , joseHeader ;
101102
102103 try {
103104 jwtClaimsStr = new Buffer ( idTokenSegments [ 1 ] , 'base64' ) . toString ( ) ;
104105 jwtClaims = JSON . parse ( jwtClaimsStr ) ;
106+
107+ joseHeader = JSON . parse ( new Buffer ( idTokenSegments [ 0 ] , 'base64' ) . toString ( ) ) ;
105108 } catch ( ex ) {
106109 return self . error ( ex ) ;
107110 }
@@ -144,6 +147,12 @@ Strategy.prototype.authenticate = function(req, options) {
144147 return self . error ( new Error ( 'Invalid nonce in id_token' ) ) ;
145148 }
146149
150+ // http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation - check 10
151+ if ( jwtClaims . iat >= jwtClaims . exp ) return self . error ( new Error ( 'id token has expired' ) ) ;
152+
153+ // http://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation - check 7-ish
154+ if ( ! joseHeader . alg || typeof ( joseHeader . alg ) === 'undefined' ) return self . error ( new Error ( 'Invalid algorithm type' ) ) ;
155+
147156 var iss = jwtClaims . iss ;
148157 var sub = jwtClaims . sub ;
149158 // Prior to OpenID Connect Basic Client Profile 1.0 - draft 22, the
You can’t perform that action at this time.
0 commit comments