@@ -34,11 +34,32 @@ JWTConfig struct {
3434 // Skipper defines a function to skip middleware.
3535 Skipper Skipper
3636
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+
3750 // 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.
3954 SigningKey interface {}
4055
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.
4263 // Optional. Default value HS256.
4364 SigningMethod string
4465
@@ -56,12 +77,25 @@ JWTConfig struct {
5677 // Possible values:
5778 // - "header:<name>"
5879 // - "query:<name>"
80+ // - "param:<name>"
5981 // - "cookie:<name>"
82+ // - "form:<name>"
6083 TokenLookup string
6184
6285 // AuthScheme to be used in the Authorization header.
6386 // Optional. Default value "Bearer".
6487 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
6599}
66100```
67101
0 commit comments