Skip to content

Commit 1bb3d5b

Browse files
committedJul 28, 2017
should be clear that jwt passed to secretOrKeyProvider is not decoded
1 parent a236e40 commit 1bb3d5b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
 

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ extracted from the request or verified.
2929
* `secretOrKey` is a string or buffer containing the secret
3030
(symmetric) or PEM-encoded public key (asymmetric) for verifying the token's
3131
signature. REQUIRED unless `secretOrKeyProvider` is provided.
32-
* `secretOrKeyProvider` is a callback in the format `function secretOrKeyProvider(token, done)`,
32+
* `secretOrKeyProvider` is a callback in the format `function secretOrKeyProvider(request, rawJwtToken, done)`,
3333
which should call `done` with a secret or PEM-encoded public key (asymmetric) for the given key and request combination.
34-
`done` accepts arguments in the format `function done(err, secret)`.
34+
`done` accepts arguments in the format `function done(err, secret)`. Note it is up to the implementer to decode rawJwtToken.
3535
REQUIRED unless `secretOrKey` is provided.
3636
* `jwtFromRequest` (REQUIRED) Function that accepts a request as the only
3737
parameter and returns either the JWT as a string or *null*. See

‎lib/strategy.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ var passport = require('passport-strategy')
1111
*
1212
* @param options
1313
* secretOrKey: String or buffer containing the secret or PEM-encoded public key. Required unless secretOrKeyProvider is provided.
14-
* secretOrKeyProvider: callback in the format secretOrKeyProvider(request, token, done)`,
14+
* secretOrKeyProvider: callback in the format secretOrKeyProvider(request, rawJwtToken, done)`,
1515
* which should call done with a secret or PEM-encoded public key
16-
* (asymmetric) for the given token and request combination. done
17-
* has the signature function done(err, secret).
16+
* (asymmetric) for the given undecoded jwt token string and request
17+
* combination. done has the signature function done(err, secret).
1818
* REQUIRED unless `secretOrKey` is provided.
1919
* jwtFromRequest: (REQUIRED) Function that accepts a reqeust as the only parameter and returns the either JWT as a string or null
2020
* issuer: If defined issuer will be verified against this value
@@ -36,7 +36,7 @@ function JwtStrategy(options, verify) {
3636
if (this._secretOrKeyProvider) {
3737
throw new TypeError('JwtStrategy has been given both a secretOrKey and a secretOrKeyProvider');
3838
}
39-
this._secretOrKeyProvider = function (request, token, done) {
39+
this._secretOrKeyProvider = function (request, rawJwtToken, done) {
4040
done(null, options.secretOrKey)
4141
};
4242
}

0 commit comments

Comments
 (0)
Please sign in to comment.