@@ -6,7 +6,7 @@ const { error, fakeReply, verify } = require('./utils')
6
6
const pkg = require ( '../package.json' )
7
7
8
8
/**
9
- * @type {Object|GrantManager }
9
+ * @type {Object }
10
10
* @private
11
11
*
12
12
* The plugin related options and instances.
@@ -85,20 +85,20 @@ function handleKeycloakValidation (tkn, reply) {
85
85
* If yes, return cached user data. Otherwise
86
86
* handle validation with help of Keycloak.
87
87
*
88
- * @param {string } field The authorization field, e.g. the value of `Authorization`
89
- * @param {Function } reply The callback handler
88
+ * @param {string } d The authorization field, e.g. the value of `Authorization`
89
+ * @param {Function } done The callback handler
90
90
*/
91
- function validate ( field , reply ) {
91
+ function validate ( field , done ) {
92
92
const tkn = token . create ( field )
93
- const done = fakeReply ( reply )
93
+ const reply = fakeReply ( done )
94
94
95
95
if ( ! tkn ) {
96
- return done ( error ( 'unauthorized' , error . msg . missing ) )
96
+ return reply ( error ( 'unauthorized' , error . msg . missing ) )
97
97
}
98
98
99
99
cache . get ( store , tkn , ( err , cached ) => {
100
100
const isCached = cached && ! err
101
- isCached ? done . continue ( cached ) : handleKeycloakValidation ( tkn , done )
101
+ isCached ? reply . continue ( cached ) : handleKeycloakValidation ( tkn , reply )
102
102
} )
103
103
}
104
104
@@ -117,10 +117,7 @@ function validate (field, reply) {
117
117
function strategy ( server ) {
118
118
return {
119
119
authenticate ( request , reply ) {
120
- return server . kjwt . validate (
121
- request . raw . req . headers . authorization ,
122
- reply
123
- )
120
+ return validate ( request . raw . req . headers . authorization , reply )
124
121
}
125
122
}
126
123
}
0 commit comments