Documentation
¶
Index ¶
- Constants
- Variables
- func ConstructAuth(rawConfig map[string]interface{}, deps authentication.AuthenticationDeps) (authentication.Authentication, error)
- type AuthWrapper
- type Bearer
- type BearerConfig
- type BearerPostgresqlConfig
- type BearerRedisConfig
- type BearerRegistration
- type Custom
- type CustomConfig
- type CustomRegistration
- type JWKSConfig
- type JWT
- type JWTConfig
- type JWTRegistration
- type Noop
- type NoopConfig
- type NoopRegistration
- type Passthrough
- type PassthroughConfig
- type PassthroughRegistration
- type StaticKey
- type StaticKeyConfig
- type StaticKeyRegistration
Constants ¶
View Source
const ( LookupEncodingNone = "none" LookupEncodingBase64 = "base64" LookupEncodingBase64URLSafe = "base64urlsafe" LookupEncodingBase36 = "base36" )
View Source
const ( ExtractModeHeader = "header" ExtractModeCookie = "cookie" ExtractModeQuery = "query" ExtractModePathSuffix = "path" )
Variables ¶
View Source
var AllBearerRedisTypes = []string{"string", "hash", "list", "set", "zset", "stream"}
View Source
var AllLookupEncodings = []string{LookupEncodingNone, LookupEncodingBase64, LookupEncodingBase64URLSafe, LookupEncodingBase36}
Functions ¶
func ConstructAuth ¶ added in v0.13.0
func ConstructAuth(rawConfig map[string]interface{}, deps authentication.AuthenticationDeps) (authentication.Authentication, error)
Types ¶
type AuthWrapper ¶ added in v0.13.0
type AuthWrapper struct {
Name string
Auth authentication.Authentication
}
Adds tracing spans around every auth. Always used since OTEL no-ops when telemetry is disabled
func (AuthWrapper) CheckAuthentication ¶ added in v0.13.0
type Bearer ¶ added in v0.13.0
type Bearer struct {
BearerConfig
// contains filtered or unexported fields
}
func (Bearer) CheckAuthentication ¶ added in v0.13.0
type BearerConfig ¶ added in v0.13.0
type BearerConfig struct {
Datastore string // ID of a postgresql or redis datastore that holds the tokens. Required
HeaderName string // The header containing the token. If this is "Authorization" the "Bearer " prefix is required and removed. Defaults to "Authorization"
TokenEncoding string // Encoding applied to the token before the lookup. One of AllLookupEncodings. Defaults to none
CacheSize int // How many lookup results to keep in memory. Zero or negative disables the cache, which is the default
CacheTTL uint32 // Seconds a lookup result is reused, for both passing and failing tokens. Defaults to 600
Postgresql *BearerPostgresqlConfig // Required when Datastore is a postgresql datastore
Redis *BearerRedisConfig // Only allowed when Datastore is a redis datastore
}
type BearerPostgresqlConfig ¶ added in v0.13.0
type BearerPostgresqlConfig struct {
Query string // The token is bound to $1. Reads the valid, user_id, and tenant_id columns
}
type BearerRedisConfig ¶ added in v0.13.0
type BearerRedisConfig struct {
KeyPrefix string // Prepended to the token to form the key. Required
UserField string // The hash field holding the user ID. Defaults to "user"
TenantField string // The hash field holding the tenant ID. Defaults to "tenant"
AllowedType string // The key type accepted as a token. One of AllBearerRedisTypes. Defaults to any type
}
type BearerRegistration ¶ added in v0.13.0
type BearerRegistration struct {
}
func (BearerRegistration) Initialize ¶ added in v0.13.0
func (s BearerRegistration) Initialize(cfgAny any, deps authentication.AuthenticationDeps) (authentication.Authentication, error)
func (BearerRegistration) InitializeConfig ¶ added in v0.13.0
func (s BearerRegistration) InitializeConfig() any
func (BearerRegistration) Name ¶ added in v0.13.0
func (s BearerRegistration) Name() string
type Custom ¶
type Custom struct {
CustomConfig
// contains filtered or unexported fields
}
func (Custom) CheckAuthentication ¶
type CustomConfig ¶
type CustomConfig struct {
Token map[string]string // How to extract the auth token from the request. Key should be one of the ExtractMode and Value is the specific identifier (or blank if inapplicable)
CacheSize int // Configures the size of the cache of already verified tokens to avoid re-verifying every request. Set to -1 to disable. Defaults to 100
File string // Contains the go code to perform validation of the auth token as a file.
Script string // Contains the go code to perform validation of the auth token inline.
}
type CustomRegistration ¶
type CustomRegistration struct {
}
func (CustomRegistration) Initialize ¶
func (s CustomRegistration) Initialize(cfgAny any, deps authentication.AuthenticationDeps) (authentication.Authentication, error)
func (CustomRegistration) InitializeConfig ¶
func (s CustomRegistration) InitializeConfig() any
func (CustomRegistration) Name ¶
func (s CustomRegistration) Name() string
type JWKSConfig ¶ added in v0.11.0
type JWKSConfig struct {
URL string // The HTTPS URL of the JWKS endpoint. Required
RefreshInterval uint // How many seconds between unconditional refreshes of the keyset. Defaults to 900
RefreshMinInterval uint // The minimum seconds between refreshes triggered by an unknown key ID. Defaults to 60
RequestTimeout uint // How many seconds before a fetch of the keyset is cancelled. Defaults to 10
AllowStartupFailure bool // If true, a failed fetch at startup logs a warning instead of preventing startup. Defaults to false
}
type JWT ¶
type JWT struct {
JWTConfig
// contains filtered or unexported fields
}
func (JWT) CheckAuthentication ¶
type JWTConfig ¶
type JWTConfig struct {
CacheSize uint16 // Configures the size of the cache of already verified JWTs to avoid re-verifying keys for every token. Expiration still applies. Set to 0 to disable. Defaults to 0
Key string // The key for verifying the signature. The public key if using asymmetric signing. Required unless JWKS is supplied
Algorithm string // Deprecated: use Algorithms. Retained so existing configurations keep working
Algorithms []string // Algorithms to allow for JWT signatures. Required
JWKS *JWKSConfig // Fetch verification keys from a remote JWKS endpoint instead of Key
HeaderName string // The header to extract the JWT from. If this is "Authorization" it removes the "Bearer " from the start. Defaults to "Authorization"
MaxExpiration uint32 // How many seconds from now can the expiration be. JWTs more than X seconds from now will result in a 401. Defaults to 1 day
ExpectedAudience string // If specified, require the "aud" grant to be this string
ExpectedSubject string // If specified, require the "sub" grant to be this string
ExpectedIssuer string // If specified, require the "iss" grant to be this string
ExpectedScope string // If specified, require the "scope" grant to contain this string.
LayerScope bool // If specified, the "scope" grant is used to limit access to layer
ScopePrefix string // If LayerScope is true, this prefix indicates scopes to use
UserID string // Use the specified grant as the user identifier. Defaults to sub
TenantID string // Use the specified grant as the tenant identifier. Defaults to tid
}
type JWTRegistration ¶
type JWTRegistration struct {
}
func (JWTRegistration) Initialize ¶
func (s JWTRegistration) Initialize(configAny any, deps authentication.AuthenticationDeps) (authentication.Authentication, error)
func (JWTRegistration) InitializeConfig ¶
func (s JWTRegistration) InitializeConfig() any
func (JWTRegistration) Name ¶
func (s JWTRegistration) Name() string
type Noop ¶
type Noop struct {
NoopConfig
}
type NoopConfig ¶
type NoopConfig struct {
}
type NoopRegistration ¶
type NoopRegistration struct {
}
func (NoopRegistration) Initialize ¶
func (s NoopRegistration) Initialize(config any, _ authentication.AuthenticationDeps) (authentication.Authentication, error)
func (NoopRegistration) InitializeConfig ¶
func (s NoopRegistration) InitializeConfig() any
func (NoopRegistration) Name ¶
func (s NoopRegistration) Name() string
type Passthrough ¶ added in v0.13.0
type Passthrough struct {
PassthroughConfig
// contains filtered or unexported fields
}
func (Passthrough) CheckAuthentication ¶ added in v0.13.0
type PassthroughConfig ¶ added in v0.13.0
type PassthroughConfig struct {
URL string // The endpoint to call. Required
Method string // One of GET, HEAD, or POST. Defaults to GET
Headers []string // Incoming headers to forward
Cookies []string // Incoming cookies to forward
QueryParams []string // Incoming query parameters to forward
UserID string // XPath to the user ID in the JSON or XML response body
TenantID string // XPath to the tenant ID in the JSON or XML response body
CacheSize int // How many results to keep in memory. Zero or negative disables the cache, which is the default
CacheTTL uint32 // Seconds a result is reused. Defaults to 600
Client *config.ClientConfig // Overrides parameters of the top-level client
}
type PassthroughRegistration ¶ added in v0.13.0
type PassthroughRegistration struct {
}
func (PassthroughRegistration) Initialize ¶ added in v0.13.0
func (s PassthroughRegistration) Initialize(cfgAny any, deps authentication.AuthenticationDeps) (authentication.Authentication, error)
func (PassthroughRegistration) InitializeConfig ¶ added in v0.13.0
func (s PassthroughRegistration) InitializeConfig() any
func (PassthroughRegistration) Name ¶ added in v0.13.0
func (s PassthroughRegistration) Name() string
type StaticKey ¶
type StaticKey struct {
StaticKeyConfig
}
type StaticKeyConfig ¶
type StaticKeyConfig struct {
Key string
}
type StaticKeyRegistration ¶
type StaticKeyRegistration struct {
}
func (StaticKeyRegistration) Initialize ¶
func (s StaticKeyRegistration) Initialize(cfgAny any, _ authentication.AuthenticationDeps) (authentication.Authentication, error)
func (StaticKeyRegistration) InitializeConfig ¶
func (s StaticKeyRegistration) InitializeConfig() any
func (StaticKeyRegistration) Name ¶
func (s StaticKeyRegistration) Name() string
Click to show internal directories.
Click to hide internal directories.