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" // DefaultHTTPClientStorageOptionRefreshInterval defines the frequency at which the jwks file is refreshed. DefaultHTTPClientStorageOptionRefreshInterval = time.Hour // DefaultHTTPClientStorageOptionHTTPTimeout limits the runtime of a reload of jwks. DefaultHTTPClientStorageOptionHTTPTimeout = 10 * time.Second // DefaultRateLimitWaitMax is the default timeout for waiting for rate limiting to end. DefaultRateLimitWaitMax = time.Minute )
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 // HTTPClientStorageOptions configuration for fetching JWKS. HTTPClientStorageOptions jwkset.HTTPClientStorageOptions // 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"` // RateLimitWaitMax is the timeout for waiting for rate limiting to end. RateLimitWaitMax time.Duration `mapstructure:"rate_limit_wait_max"` }
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 WithHTTPClientStorageOptions ¶ added in v0.5.0
func WithHTTPClientStorageOptions(options jwkset.HTTPClientStorageOptions) Opts
WithHTTPClientStorageOptions sets the HTTPClientStorageOptions for the auth middleware.
func WithJWTConfig ¶ added in v0.2.0
WithJWTConfig sets the JWTConfig 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.