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.
* Applications must supply a `verify` callback, for which the function
35
+
* signature is:
36
+
*
37
+
* function(token, done) { ... }
38
+
*
39
+
* `token` is the verified and decoded bearer token provided as a credential.
40
+
* The verify callback is responsible for finding the user who posesses the
41
+
* token, and invoking `done` with the following arguments:
42
+
*
43
+
* done(err, user, info);
44
+
*
45
+
* If the token is not valid, `user` should be set to `false` to indicate an
46
+
* authentication failure. Additional token `info` can optionally be passed as
47
+
* a third argument, which will be set by Passport at `req.authInfo`, where it
48
+
* can be used by later middleware for access control. This is typically used
49
+
* to pass any scope associated with the token.
50
+
*
51
+
* Options:
52
+
*
53
+
* - `realm` authentication realm, defaults to "Users"
54
+
* - `scope` list of scope values indicating the required scope of the
55
+
* access token for accessing the requested resource
56
+
* - `audience` if you want to check JWT audience (aud), provide a value here
57
+
* - `issuer` if you want to check JWT issuer (iss), provide a value here
58
+
*
59
+
* Examples:
60
+
*
61
+
* passport.use(new JwtBearerStrategy(
62
+
* secretOrPublicKey
63
+
* function(token, done) {
64
+
* User.findById(token.sub, function (err, user) {
65
+
* if (err) { return done(err); }
66
+
* if (!user) { return done(null, false); }
67
+
* return done(null, user, token);
68
+
* });
69
+
* }
70
+
* ));
71
+
*
72
+
* For further details on HTTP Bearer authentication, refer to [The OAuth 2.0 Authorization Protocol: Bearer Tokens](http://tools.ietf.org/html/draft-ietf-oauth-v2-bearer)
73
+
* For further details on JSON Web Token, refert to [JSON Web Token](http://tools.ietf.org/html/draft-ietf-oauth-json-web-token)
74
+
*
75
+
* @param {object} options - The Options.
76
+
* @param {Function} verify - The verify callback.
77
+
* @constructor
78
+
*/
79
+
80
+
functionStrategy(options,verify){
33
81
34
-
functionStrategy(options,callback,verify){
35
82
36
83
// You can provide your own cert if you don't want to use Azure AD's certificate from our Identity servers (just in case you're using this for your own things!)
37
84
@@ -42,7 +89,7 @@ if(options.publicCert) {
42
89
if(options.metadataurl){
43
90
44
91
log.info(options.metadataurl,'metadata url provided to Strategy');
@@ -51,77 +98,82 @@ if (!options.certificate && !options.metadataurl) {
51
98
}
52
99
53
100
54
-
if(typeofcallback=='function'){
55
-
verify=callback;
56
-
// callback = {};
57
-
}
58
-
59
101
// Passport requires a verify function
60
102
61
103
if(!verify){
62
104
thrownewTypeError('OIDCBearerStrategy requires a verify callback. Do not cheat!');
63
105
}
64
106
65
-
this.metadata.fetch(callback);
66
-
log.info(this.metadata,'Metadata returned');
107
+
this.certs=[];
67
108
68
-
functionrequestToUrl(callback){
109
+
// Token validation settings. Hopefully most of these will be pulled from the metadata and this is not needed
69
110
70
-
async.waterfall([
71
-
function(next){
72
-
if(!this.metadata.saml0){
73
-
this.metadata.fetch(next);
74
-
}else{
75
-
next(null);
76
-
}
77
-
target="";
78
-
console.log(this.metadata);
79
-
}
80
-
],function(err,target){
81
-
returncallback(err,target);
82
-
});
83
-
}
84
111
85
112
113
+
// fetch metadata
86
114
115
+
if(this.metadata){
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
+
});};
87
127
128
+
// fetch keys
88
129
89
130
90
131
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
91
135
136
+
};
92
137
93
138
functionjwtVerify(req,token,done){
94
139
if(!options.passReqToCallback){
95
140
token=arguments[0];
96
141
done=arguments[1];
97
142
req=null;
143
+
log.info(token,'was token going in to verification');
0 commit comments