config.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package jwt
  2. import "github.com/dgrijalva/jwt-go"
  3. const (
  4. //DefaultContextKey jwt
  5. DefaultContextKey = "jwt"
  6. )
  7. // Config is a struct for specifying configuration options for the jwt middleware.
  8. type Config struct {
  9. // The function that will return the Key to validate the JWT.
  10. // It can be either a shared secret or a public key.
  11. // Default value: nil
  12. ValidationKeyGetter jwt.Keyfunc
  13. // The name of the property in the request where the user (&token) information
  14. // from the JWT will be stored.
  15. // Default value: "jwt"
  16. ContextKey string
  17. // The function that will be called when there's an error validating the token
  18. // Default value:
  19. ErrorHandler errorHandler
  20. // A boolean indicating if the credentials are required or not
  21. // Default value: false
  22. CredentialsOptional bool
  23. // A function that extracts the token from the request
  24. // Default: FromAuthHeader (i.e., from Authorization header as bearer token)
  25. Extractor TokenExtractor
  26. // Debug flag turns on debugging output
  27. // Default: false
  28. Debug bool
  29. // When set, all requests with the OPTIONS method will use authentication
  30. // if you enable this option you should register your route with iris.Options(...) also
  31. // Default: false
  32. EnableAuthOnOptions bool
  33. // When set, the middelware verifies that tokens are signed with the specific signing algorithm
  34. // If the signing method is not constant the ValidationKeyGetter callback can be used to implement additional checks
  35. // Important to avoid security issues described here: https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/
  36. // Default: nil
  37. SigningMethod jwt.SigningMethod
  38. // When set, the expiration time of token will be check every time
  39. // if the token was expired, expiration error will be returned
  40. // Default: false
  41. Expiration bool
  42. }