@@ -34,11 +34,32 @@ JWTConfig struct {
34
34
// Skipper defines a function to skip middleware.
35
35
Skipper Skipper
36
36
37
+ // BeforeFunc defines a function which is executed just before the middleware.
38
+ BeforeFunc BeforeFunc
39
+
40
+ // SuccessHandler defines a function which is executed for a valid token.
41
+ SuccessHandler JWTSuccessHandler
42
+
43
+ // ErrorHandler defines a function which is executed for an invalid token.
44
+ // It may be used to define a custom JWT error.
45
+ ErrorHandler JWTErrorHandler
46
+
47
+ // ErrorHandlerWithContext is almost identical to ErrorHandler, but it's passed the current context.
48
+ ErrorHandlerWithContext JWTErrorHandlerWithContext
49
+
37
50
// Signing key to validate token.
38
- // Required.
51
+ // This is one of the three options to provide a token validation key.
52
+ // The order of precedence is a user-defined KeyFunc, SigningKeys and SigningKey.
53
+ // Required if neither user-defined KeyFunc nor SigningKeys is provided.
39
54
SigningKey interface {}
40
55
41
- // Signing method, used to check token signing method.
56
+ // Map of signing keys to validate token with kid field usage.
57
+ // This is one of the three options to provide a token validation key.
58
+ // The order of precedence is a user-defined KeyFunc, SigningKeys and SigningKey.
59
+ // Required if neither user-defined KeyFunc nor SigningKey is provided.
60
+ SigningKeys map [string ]interface {}
61
+
62
+ // Signing method used to check the token's signing algorithm.
42
63
// Optional. Default value HS256.
43
64
SigningMethod string
44
65
@@ -56,12 +77,25 @@ JWTConfig struct {
56
77
// Possible values:
57
78
// - "header:<name>"
58
79
// - "query:<name>"
80
+ // - "param:<name>"
59
81
// - "cookie:<name>"
82
+ // - "form:<name>"
60
83
TokenLookup string
61
84
62
85
// AuthScheme to be used in the Authorization header.
63
86
// Optional. Default value "Bearer".
64
87
AuthScheme string
88
+
89
+ // KeyFunc defines a user-defined function that supplies the public key for a token validation.
90
+ // The function shall take care of verifying the signing algorithm and selecting the proper key.
91
+ // A user-defined KeyFunc can be useful if tokens are issued by an external party.
92
+ //
93
+ // When a user-defined KeyFunc is provided, SigningKey, SigningKeys, and SigningMethod are ignored.
94
+ // This is one of the three options to provide a token validation key.
95
+ // The order of precedence is a user-defined KeyFunc, SigningKeys and SigningKey.
96
+ // Required if neither SigningKeys nor SigningKey is provided.
97
+ // Default to an internal implementation verifying the signing algorithm and selecting the proper key.
98
+ KeyFunc jwt.Keyfunc
65
99
}
66
100
```
67
101
0 commit comments