@@ -18,29 +18,29 @@ let manager
18
18
* @function
19
19
* @private
20
20
*
21
- * Validate the token offline with help of
22
- * the related public key. Resolve if the
23
- * verification succeeded.
21
+ * Validate the signed token offline with help of the related
22
+ * public key or online with help of the Keycloak server and
23
+ * JWKS. Resolve if the verification succeeded.
24
24
*
25
25
* @param {string } token The token to be validated
26
26
* @returns {Promise } The error-handled promise
27
27
*/
28
- function validateOffline ( token ) {
28
+ function validateSignedJwt ( token ) {
29
29
return manager . validateToken ( new Token ( token , options . clientId ) )
30
30
}
31
31
32
32
/**
33
33
* @function
34
34
* @private
35
35
*
36
- * Validate the token online with help of
37
- * the related Keycloak server. Resolve if
38
- * the request succeeded and token is valid.
36
+ * Validate the token online with help of the related
37
+ * Keycloak server, the client identifier and its secret.
38
+ * Resolve if the request succeeded and token is valid.
39
39
*
40
40
* @param {string } token The token to be validated
41
41
* @returns {Promise } The error-handled promise
42
42
*/
43
- function validateOnline ( token ) {
43
+ function validateSecret ( token ) {
44
44
return manager . validateAccessToken ( token ) . then ( ( res ) => {
45
45
if ( res === false ) {
46
46
throw Error ( error . msg . invalid )
@@ -62,7 +62,7 @@ function validateOnline (token) {
62
62
* @param {Function } reply The callback handler
63
63
*/
64
64
function handleKeycloakValidation ( tkn , reply ) {
65
- const validateFn = options . secret ? validateOnline : validateOffline
65
+ const validateFn = options . secret ? validateSecret : validateSignedJwt
66
66
67
67
validateFn ( tkn . get ( ) ) . then ( ( ) => {
68
68
const { expiresIn, credentials } = tkn . getData ( options . userInfo )
0 commit comments