Documentation ¶
Overview ¶
Package echojwtx implements echo-jwt middleware with additional helpers for setting the JWT Subject as an actor context value.
Index ¶
Constants ¶
View Source
const ( // ActorKey defines the context key an actor is stored in for an echo context ActorKey = "actor" // DefaultKeyFuncOptionRefreshInterval defines the frequency at which the jwks file is refreshed. DefaultKeyFuncOptionRefreshInterval = time.Hour // DefaultKeyFuncOptionRefreshRateLimit limits how frequently jwks is reloaded when a provided KID is not found. DefaultKeyFuncOptionRefreshRateLimit = 5 * time.Minute // DefaultKeyFuncOptionRefreshTimeout limits the runtime of a reload of jwks. DefaultKeyFuncOptionRefreshTimeout = 10 * time.Second )
View Source
const ( // DefaultOIDCJWKSRemoteTimeout defines the default timeout for fetching the OIDC JWKS file. DefaultOIDCJWKSRemoteTimeout = 5 * time.Second )
Variables ¶
View Source
var ( // ActorCtxKey defines the context key an actor is stored in for a plain context ActorCtxKey = actorContext{} // ErrJWKSURIMissing is returned when the jwks_uri field is not found in the issuer's oidc well-known configuration. ErrJWKSURIMissing = errors.New("jwks_uri missing from oidc provider") )
Functions ¶
Types ¶
type Auth ¶
type Auth struct { // JWTConfig configuration for handling JWT validation. JWTConfig echojwt.Config // KeyFuncOptions configuration for fetching JWKS. KeyFuncOptions keyfunc.Options // contains filtered or unexported fields }
Auth handles JWT Authentication as echo middleware.
func (*Auth) Middleware ¶
func (a *Auth) Middleware() echo.MiddlewareFunc
Middleware returns echo middleware for validation jwt tokens.
type AuthConfig ¶
type AuthConfig struct { // Issuer is the Auth Issuer Issuer string `mapstructure:"issuer"` // Audience is the Auth Audience Audience string `mapstructure:"audience"` // RefreshTimeout is the timeout for fetching the JWKS from the issuer. RefreshTimeout time.Duration `mapstructure:"refresh_timeout"` }
AuthConfig provides configuration for JWT validation using JWKS.
type Opts ¶ added in v0.2.0
type Opts func(*Auth)
Opts defines options for the Auth middleware.
func WithJWTConfig ¶ added in v0.2.0
WithJWTConfig sets the JWTConfig for the auth middleware.
func WithKeyFuncOptions ¶ added in v0.2.0
func WithKeyFuncOptions(keyFuncOptions keyfunc.Options) Opts
WithKeyFuncOptions sets the KeyFuncOptions for the auth middleware.
func WithLogger ¶ added in v0.2.0
WithLogger sets the logger for the auth middleware.
Click to show internal directories.
Click to hide internal directories.