Documentation ¶
Index ¶
- Variables
- func MiddlewareControl[T any](fn func(c echo.Context, claim T) error, opts ...OptionControl) echo.MiddlewareFunc
- func MiddlewareJWT(opts ...Option) echo.MiddlewareFunc
- func MiddlewareJWTWithRedirection(opts ...Option) []echo.MiddlewareFunc
- func MiddlewareRole(opts ...OptionRole) echo.MiddlewareFunc
- func MiddlewareScope(opts ...OptionScope) echo.MiddlewareFunc
- func NewSkipper(opts ...OptionSkipper) middleware.Skipper
- type ClaimsRole
- type ClaimsScope
- type Option
- func WithClaims(newClaims func() jwt.Claims) Option
- func WithConfig(cfg echojwt.Config) Option
- func WithKeyFunc(fn jwt.Keyfunc) Option
- func WithNoop(noop bool) Option
- func WithParserFunc(fn func(tokenString string, claims jwt.Claims) (*jwt.Token, error)) Option
- func WithRedirect(redirectSetting *redirect.Setting) Option
- func WithSkipper(skipper middleware.Skipper) Option
- type OptionControl
- type OptionRole
- type OptionScope
- type OptionSkipper
Constants ¶
This section is empty.
Variables ¶
var ( // KeyClaims hold parsed claims in the echo context. // // Default claims is *claims.Custom. KeyClaims = "claims" // KeyToken hold parsed *jwt.Token in the echo context. // // This is default key for echo-jwt's ContextKey if not set. KeyToken = "token" // KeyAccessToken hold the access token in the echo context. KeyAccessToken = "access_token" // KeySkipper is true if the jwt middleware skipped. KeySkipper = "skipped" // KeyAuthNoop hold true if the provider is noop. KeyAuthNoop = "auth_noop" KeyAuthIntrospect = "auth_introspect" // KeyAuthError internal error for code token get, str format. KeyAuthError = "auth_error" KeyClearCookieOnJWTKIDError = "clear_cookie_on_jwt_kid_error" // KeyDisableRedirect is true if the redirection is disabled. KeyDisableRedirect = "disable_redirect" // KeyDisableRedirectWithCookie is true redirection disabled and removed cookie. KeyDisableRedirectWithCookie = "disable_redirect_with_cookie" )
var DisableControlCheckKey = "auth_disable_control_check"
var DisableRoleCheckKey = "auth_disable_role_check"
var DisableScopeCheckKey = "auth_disable_scope_check"
var Store = authStore{ // contains filtered or unexported fields }
Functions ¶
func MiddlewareControl ¶ added in v0.7.3
func MiddlewareControl[T any](fn func(c echo.Context, claim T) error, opts ...OptionControl) echo.MiddlewareFunc
MiddlewareControl that checks the claim manually with a function.
func MiddlewareJWT ¶
func MiddlewareJWT(opts ...Option) echo.MiddlewareFunc
MiddlewareJWT returns a JWT middleware. Default claims is *claims.Custom.
WithRedirect option not usable in this function.
func MiddlewareJWTWithRedirection ¶
func MiddlewareJWTWithRedirection(opts ...Option) []echo.MiddlewareFunc
MiddlewareJWTWithRedirection returns a JWT middleware with usable redirection option. Default claims is *claims.Custom.
Redirection returns 2 middleware functions.
func MiddlewareRole ¶
func MiddlewareRole(opts ...OptionRole) echo.MiddlewareFunc
MiddlewareRole that checks the role claim.
This middleware just work with ClaimsRole interface in claim.
func MiddlewareScope ¶
func MiddlewareScope(opts ...OptionScope) echo.MiddlewareFunc
MiddlewareScope that checks the scope claim.
This middleware just work with ClaimsScope interface in claims.
func NewSkipper ¶
func NewSkipper(opts ...OptionSkipper) middleware.Skipper
NewSkipper returns a new Skipper that skips the given suffixes.
Set skip is true to skip all.
Default suffixes are: [/ping, /health, /metrics].
Types ¶
type ClaimsRole ¶ added in v0.7.0
type ClaimsScope ¶ added in v0.7.0
type Option ¶
type Option func(*options)
func WithClaims ¶
func WithClaims(newClaims func() jwt.Claims) Option
WithClaims sets the claims to use, function must return a pointer.
func WithKeyFunc ¶
func WithKeyFunc(fn jwt.Keyfunc) Option
func WithParserFunc ¶
func WithRedirect ¶
func WithSkipper ¶
func WithSkipper(skipper middleware.Skipper) Option
type OptionControl ¶ added in v0.7.3
type OptionControl func(*optionsControl)
func WithNoopControl ¶ added in v0.7.3
func WithNoopControl(v bool) OptionControl
WithNoopControl sets the noop option.
If provider already has a noop, this one will be ignored.
type OptionRole ¶
type OptionRole func(*optionsRole)
func WithMethodsRole ¶
func WithMethodsRole(methods ...string) OptionRole
WithMethods sets the methods to check.
func WithNoopRole ¶
func WithNoopRole(v bool) OptionRole
WithNoopRole sets the noop option.
If provider already has a noop, this one will be ignored.
type OptionScope ¶
type OptionScope func(*optionsScope)
func WithMethodsScope ¶
func WithMethodsScope(methods ...string) OptionScope
WithMethods sets the methods to check.
func WithNoopScope ¶
func WithNoopScope(v bool) OptionScope
WithNoopScope sets the noop option.
If provider already has a noop, this one will be ignored.
type OptionSkipper ¶
type OptionSkipper func(*optionsSkipper)
func WithSkipAll ¶
func WithSkipAll(v bool) OptionSkipper
WithSkipAll sets skipAll to true and disable the check token.
func WithSuffixes ¶
func WithSuffixes(suffixes ...string) OptionSkipper
WithSuffixes sets the suffixes to skip.