@@ -29,15 +29,19 @@ type (
29
29
// ErrorHandlerWithContext is almost identical to ErrorHandler, but it's passed the current context.
30
30
ErrorHandlerWithContext JWTErrorHandlerWithContext
31
31
32
- // Signing key to validate token. Used as fallback if KeyFunc is nil or SigningKeys has length 0.
33
- // Required. This or SigningKeys or KeyFunc.
32
+ // Signing key to validate token.
33
+ // This is one of the three options to provide a token validation key.
34
+ // The order of precedence is a user-defined KeyFunc, SigningKeys and SigningKey.
35
+ // Required if neither user-defined KeyFunc nor SigningKeys is provided.
34
36
SigningKey interface {}
35
37
36
- // Map of signing keys to validate token with kid field usage. Used as fallback if KeyFunc is nil.
37
- // Required. This or SigningKey or KeyFunc.
38
+ // Map of signing keys to validate token with kid field usage.
39
+ // This is one of the three options to provide a token validation key.
40
+ // The order of precedence is a user-defined KeyFunc, SigningKeys and SigningKey.
41
+ // Required if neither user-defined KeyFunc nor SigningKey is provided.
38
42
SigningKeys map [string ]interface {}
39
43
40
- // Signing method, used to check token signing method .
44
+ // Signing method used to check the token's signing algorithm .
41
45
// Optional. Default value HS256.
42
46
SigningMethod string
43
47
@@ -64,11 +68,15 @@ type (
64
68
// Optional. Default value "Bearer".
65
69
AuthScheme string
66
70
67
- // KeyFunc defines a function to supply the key for a token verification.
71
+ // KeyFunc defines a user-defined function that supplies the public key for a token validation.
72
+ // The function shall take care of verifying the signing algorithm and selecting the proper key.
73
+ // A user-defined KeyFunc can be useful if tokens are issued by an external party.
74
+ //
68
75
// When a user-defined KeyFunc is provided, SigningKey, SigningKeys, and SigningMethod are ignored.
69
- // Required. This or SigningKey or SigningKeys.
76
+ // This is one of the three options to provide a token validation key.
77
+ // The order of precedence is a user-defined KeyFunc, SigningKeys and SigningKey.
78
+ // Required if neither SigningKeys nor SigningKey is provided.
70
79
// Default to an internal implementation verifying the signing algorithm and selecting the proper key.
71
- // See: `jwt.Keyfunc`
72
80
KeyFunc jwt.Keyfunc
73
81
}
74
82
0 commit comments