You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2020. It is now read-only.
@@ -97,45 +99,30 @@ if (!options.certificate && !options.metadataurl) {
97
99
thrownewTypeError('OIDCBearerStrategy requires either a PEM encoded public key or a metadata location that contains cert data for RSA and ECDSA callback.');
98
100
}
99
101
102
+
if(typeofoptions=='function'){
103
+
verify=options;
104
+
options={};
105
+
}
100
106
101
107
// Passport requires a verify function
102
108
103
109
if(!verify){
104
110
thrownewTypeError('OIDCBearerStrategy requires a verify callback. Do not cheat!');
105
111
}
106
112
107
-
this.certs=[];
108
-
109
113
// Token validation settings. Hopefully most of these will be pulled from the metadata and this is not needed
110
114
111
115
112
-
113
-
// fetch metadata
114
-
115
-
if(this.metadata){
116
116
this.metadata.fetch(function(err){
117
-
if(err){
118
-
log.warn('Error parsing metadata.',err);
119
-
returnerr;
120
-
}else{
121
-
log.info(this.metadata,'Metadata returned');
122
-
this.oidc=self.metadata.oidc;
123
-
this.keyURL=oidc.keyURL;
124
-
this.algothims=oidc.algorithm;
125
-
}
126
-
});};
127
-
128
-
// fetch keys
129
-
130
-
117
+
if(err){
118
+
thrownewError("Unable to fetch metadata: "+err);
119
+
}
131
120
132
-
varconfig={
133
-
// The URL of the metadata document for your app. We will put the keys for token validation from the URL found in the jwks_uri tag of the in the metadata.
134
-
algorithms: this.algorithms
121
+
});
135
122
136
-
};
137
123
138
124
functionjwtVerify(req,token,done){
125
+
139
126
if(!options.passReqToCallback){
140
127
token=arguments[0];
141
128
done=arguments[1];
@@ -144,11 +131,30 @@ algorithms: this.algorithms
144
131
}
145
132
146
133
134
+
vardecoded=jws.decode(token);
135
+
if(decoded==null){
136
+
done(null,false,"Invalid JWT token.");
137
+
}
138
+
139
+
log.info(decoded,'was token decrypted. But is it valid?');
140
+
147
141
148
-
varPEMkey=pem.certToPEM(this._oidc.certs[0]);
149
-
log.info(PEMkey,'was the PEM returned');
142
+
// We have two different types of token signatures we have to validate here. One provides x5t and the other a kid. We need to call the right one.
0 commit comments