Documentation
¶
Index ¶
- func NewAPIKeyProvider(name string, opts ...APIKeyOption) auth.AuthProvider
- func NewBasicAuthProvider(name string, opts ...BasicAuthOption) auth.AuthProvider
- func NewBearerTokenProvider(name string, opts ...BearerTokenOption) auth.AuthProvider
- func NewOAuth2Provider(name string, flows *auth.OAuthFlows, opts ...OAuth2Option) auth.AuthProvider
- func NewOIDCProvider(name string, openIdConnectUrl string, opts ...OIDCOption) auth.AuthProvider
- type APIKeyOption
- func WithAPIKeyContainer(container forge.Container) APIKeyOption
- func WithAPIKeyCookie(name string) APIKeyOption
- func WithAPIKeyDescription(desc string) APIKeyOption
- func WithAPIKeyHeader(name string) APIKeyOption
- func WithAPIKeyQuery(param string) APIKeyOption
- func WithAPIKeyValidator(validator APIKeyValidator) APIKeyOption
- type APIKeyProvider
- func (p *APIKeyProvider) Authenticate(ctx context.Context, r *http.Request) (*auth.AuthContext, error)
- func (p *APIKeyProvider) Middleware() forge.Middleware
- func (p *APIKeyProvider) Name() string
- func (p *APIKeyProvider) OpenAPIScheme() auth.SecurityScheme
- func (p *APIKeyProvider) Type() auth.SecuritySchemeType
- type APIKeyValidator
- type BasicAuthOption
- type BasicAuthProvider
- func (p *BasicAuthProvider) Authenticate(ctx context.Context, r *http.Request) (*auth.AuthContext, error)
- func (p *BasicAuthProvider) Middleware() forge.Middleware
- func (p *BasicAuthProvider) Name() string
- func (p *BasicAuthProvider) OpenAPIScheme() auth.SecurityScheme
- func (p *BasicAuthProvider) Type() auth.SecuritySchemeType
- type BasicAuthValidator
- type BearerTokenOption
- type BearerTokenProvider
- func (p *BearerTokenProvider) Authenticate(ctx context.Context, r *http.Request) (*auth.AuthContext, error)
- func (p *BearerTokenProvider) Middleware() forge.Middleware
- func (p *BearerTokenProvider) Name() string
- func (p *BearerTokenProvider) OpenAPIScheme() auth.SecurityScheme
- func (p *BearerTokenProvider) Type() auth.SecuritySchemeType
- type BearerTokenValidator
- type OAuth2Option
- type OAuth2Provider
- func (p *OAuth2Provider) Authenticate(ctx context.Context, r *http.Request) (*auth.AuthContext, error)
- func (p *OAuth2Provider) Middleware() forge.Middleware
- func (p *OAuth2Provider) Name() string
- func (p *OAuth2Provider) OpenAPIScheme() auth.SecurityScheme
- func (p *OAuth2Provider) Type() auth.SecuritySchemeType
- type OAuth2TokenValidator
- type OIDCOption
- type OIDCProvider
- func (p *OIDCProvider) Authenticate(ctx context.Context, r *http.Request) (*auth.AuthContext, error)
- func (p *OIDCProvider) Middleware() forge.Middleware
- func (p *OIDCProvider) Name() string
- func (p *OIDCProvider) OpenAPIScheme() auth.SecurityScheme
- func (p *OIDCProvider) Type() auth.SecuritySchemeType
- type OIDCTokenValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAPIKeyProvider ¶
func NewAPIKeyProvider(name string, opts ...APIKeyOption) auth.AuthProvider
NewAPIKeyProvider creates a new API key auth provider. By default, it looks for the API key in the "X-API-Key" header.
func NewBasicAuthProvider ¶
func NewBasicAuthProvider(name string, opts ...BasicAuthOption) auth.AuthProvider
NewBasicAuthProvider creates a new HTTP Basic Auth provider.
func NewBearerTokenProvider ¶
func NewBearerTokenProvider(name string, opts ...BearerTokenOption) auth.AuthProvider
NewBearerTokenProvider creates a new bearer token auth provider. By default, it expects JWT tokens.
func NewOAuth2Provider ¶
func NewOAuth2Provider(name string, flows *auth.OAuthFlows, opts ...OAuth2Option) auth.AuthProvider
NewOAuth2Provider creates a new OAuth2 auth provider.
func NewOIDCProvider ¶
func NewOIDCProvider(name string, openIdConnectUrl string, opts ...OIDCOption) auth.AuthProvider
NewOIDCProvider creates a new OpenID Connect auth provider.
Types ¶
type APIKeyOption ¶
type APIKeyOption func(*APIKeyProvider)
func WithAPIKeyContainer ¶
func WithAPIKeyContainer(container forge.Container) APIKeyOption
WithAPIKeyContainer sets the DI container (for accessing services)
func WithAPIKeyCookie ¶
func WithAPIKeyCookie(name string) APIKeyOption
WithAPIKeyCookie sets the cookie name to look for the API key
func WithAPIKeyDescription ¶
func WithAPIKeyDescription(desc string) APIKeyOption
WithAPIKeyDescription sets the OpenAPI description
func WithAPIKeyHeader ¶
func WithAPIKeyHeader(name string) APIKeyOption
WithAPIKeyHeader sets the header name to look for the API key
func WithAPIKeyQuery ¶
func WithAPIKeyQuery(param string) APIKeyOption
WithAPIKeyQuery sets the query parameter name to look for the API key
func WithAPIKeyValidator ¶
func WithAPIKeyValidator(validator APIKeyValidator) APIKeyOption
WithAPIKeyValidator sets the validator function
type APIKeyProvider ¶
type APIKeyProvider struct {
// contains filtered or unexported fields
}
APIKeyProvider implements API key authentication. API keys can be provided in headers, query parameters, or cookies.
func (*APIKeyProvider) Authenticate ¶
func (p *APIKeyProvider) Authenticate(ctx context.Context, r *http.Request) (*auth.AuthContext, error)
func (*APIKeyProvider) Middleware ¶
func (p *APIKeyProvider) Middleware() forge.Middleware
func (*APIKeyProvider) Name ¶
func (p *APIKeyProvider) Name() string
func (*APIKeyProvider) OpenAPIScheme ¶
func (p *APIKeyProvider) OpenAPIScheme() auth.SecurityScheme
func (*APIKeyProvider) Type ¶
func (p *APIKeyProvider) Type() auth.SecuritySchemeType
type APIKeyValidator ¶
APIKeyValidator validates an API key and returns the auth context. The validator has access to the DI container via the provider and can retrieve services like databases, caches, etc. for validation.
type BasicAuthOption ¶
type BasicAuthOption func(*BasicAuthProvider)
func WithBasicAuthContainer ¶
func WithBasicAuthContainer(container forge.Container) BasicAuthOption
WithBasicAuthContainer sets the DI container (for accessing services)
func WithBasicAuthDescription ¶
func WithBasicAuthDescription(desc string) BasicAuthOption
WithBasicAuthDescription sets the OpenAPI description
func WithBasicAuthValidator ¶
func WithBasicAuthValidator(validator BasicAuthValidator) BasicAuthOption
WithBasicAuthValidator sets the validator function
type BasicAuthProvider ¶
type BasicAuthProvider struct {
// contains filtered or unexported fields
}
BasicAuthProvider implements HTTP Basic Authentication. It extracts username and password from the Authorization header.
func (*BasicAuthProvider) Authenticate ¶
func (p *BasicAuthProvider) Authenticate(ctx context.Context, r *http.Request) (*auth.AuthContext, error)
func (*BasicAuthProvider) Middleware ¶
func (p *BasicAuthProvider) Middleware() forge.Middleware
func (*BasicAuthProvider) Name ¶
func (p *BasicAuthProvider) Name() string
func (*BasicAuthProvider) OpenAPIScheme ¶
func (p *BasicAuthProvider) OpenAPIScheme() auth.SecurityScheme
func (*BasicAuthProvider) Type ¶
func (p *BasicAuthProvider) Type() auth.SecuritySchemeType
type BasicAuthValidator ¶
type BasicAuthValidator func(ctx context.Context, username, password string) (*auth.AuthContext, error)
BasicAuthValidator validates username and password and returns the auth context. The validator can access services from the DI container to verify credentials against a database, LDAP, etc.
type BearerTokenOption ¶
type BearerTokenOption func(*BearerTokenProvider)
func WithBearerContainer ¶
func WithBearerContainer(container forge.Container) BearerTokenOption
WithBearerContainer sets the DI container (for accessing services)
func WithBearerDescription ¶
func WithBearerDescription(desc string) BearerTokenOption
WithBearerDescription sets the OpenAPI description
func WithBearerFormat ¶
func WithBearerFormat(format string) BearerTokenOption
WithBearerFormat sets the bearer token format (e.g., "JWT", "token")
func WithBearerValidator ¶
func WithBearerValidator(validator BearerTokenValidator) BearerTokenOption
WithBearerValidator sets the validator function
type BearerTokenProvider ¶
type BearerTokenProvider struct {
// contains filtered or unexported fields
}
BearerTokenProvider implements Bearer token authentication (JWT, OAuth2, etc.). It extracts tokens from the Authorization header using the "Bearer" scheme.
func (*BearerTokenProvider) Authenticate ¶
func (p *BearerTokenProvider) Authenticate(ctx context.Context, r *http.Request) (*auth.AuthContext, error)
func (*BearerTokenProvider) Middleware ¶
func (p *BearerTokenProvider) Middleware() forge.Middleware
func (*BearerTokenProvider) Name ¶
func (p *BearerTokenProvider) Name() string
func (*BearerTokenProvider) OpenAPIScheme ¶
func (p *BearerTokenProvider) OpenAPIScheme() auth.SecurityScheme
func (*BearerTokenProvider) Type ¶
func (p *BearerTokenProvider) Type() auth.SecuritySchemeType
type BearerTokenValidator ¶
BearerTokenValidator validates a bearer token and returns the auth context. The validator can access services from the DI container for JWT verification, token introspection, etc.
type OAuth2Option ¶
type OAuth2Option func(*OAuth2Provider)
func WithOAuth2Container ¶
func WithOAuth2Container(container forge.Container) OAuth2Option
WithOAuth2Container sets the DI container (for accessing services)
func WithOAuth2Description ¶
func WithOAuth2Description(desc string) OAuth2Option
WithOAuth2Description sets the OpenAPI description
func WithOAuth2Validator ¶
func WithOAuth2Validator(validator OAuth2TokenValidator) OAuth2Option
WithOAuth2Validator sets the validator function
type OAuth2Provider ¶
type OAuth2Provider struct {
// contains filtered or unexported fields
}
OAuth2Provider implements OAuth 2.0 authentication. It validates OAuth2 access tokens and extracts scopes and permissions.
func (*OAuth2Provider) Authenticate ¶
func (p *OAuth2Provider) Authenticate(ctx context.Context, r *http.Request) (*auth.AuthContext, error)
func (*OAuth2Provider) Middleware ¶
func (p *OAuth2Provider) Middleware() forge.Middleware
func (*OAuth2Provider) Name ¶
func (p *OAuth2Provider) Name() string
func (*OAuth2Provider) OpenAPIScheme ¶
func (p *OAuth2Provider) OpenAPIScheme() auth.SecurityScheme
func (*OAuth2Provider) Type ¶
func (p *OAuth2Provider) Type() auth.SecuritySchemeType
type OAuth2TokenValidator ¶
OAuth2TokenValidator validates an OAuth2 token and returns the auth context. The validator should verify the token with the OAuth2 authorization server and extract claims, scopes, etc.
type OIDCOption ¶
type OIDCOption func(*OIDCProvider)
func WithOIDCContainer ¶
func WithOIDCContainer(container forge.Container) OIDCOption
WithOIDCContainer sets the DI container (for accessing services)
func WithOIDCDescription ¶
func WithOIDCDescription(desc string) OIDCOption
WithOIDCDescription sets the OpenAPI description
func WithOIDCValidator ¶
func WithOIDCValidator(validator OIDCTokenValidator) OIDCOption
WithOIDCValidator sets the validator function
type OIDCProvider ¶
type OIDCProvider struct {
// contains filtered or unexported fields
}
OIDCProvider implements OpenID Connect authentication. It validates OIDC ID tokens and access tokens.
func (*OIDCProvider) Authenticate ¶
func (p *OIDCProvider) Authenticate(ctx context.Context, r *http.Request) (*auth.AuthContext, error)
func (*OIDCProvider) Middleware ¶
func (p *OIDCProvider) Middleware() forge.Middleware
func (*OIDCProvider) Name ¶
func (p *OIDCProvider) Name() string
func (*OIDCProvider) OpenAPIScheme ¶
func (p *OIDCProvider) OpenAPIScheme() auth.SecurityScheme
func (*OIDCProvider) Type ¶
func (p *OIDCProvider) Type() auth.SecuritySchemeType
type OIDCTokenValidator ¶
OIDCTokenValidator validates an OIDC token and returns the auth context. The validator should verify the token with the OIDC provider and extract claims (sub, email, name, etc.).