providers

package
v1.3.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigColumnSecurityProvider

type ConfigColumnSecurityProvider struct {
	// contains filtered or unexported fields
}

ConfigColumnSecurityProvider provides static column security configuration

func NewConfigColumnSecurityProvider

func NewConfigColumnSecurityProvider(rules map[string][]sectypes.ColumnSecurity) *ConfigColumnSecurityProvider

func (*ConfigColumnSecurityProvider) GetColumnSecurity

func (p *ConfigColumnSecurityProvider) GetColumnSecurity(ctx context.Context, userID int, schema, table string) ([]sectypes.ColumnSecurity, error)

type ConfigKeyStore

type ConfigKeyStore struct {
	// contains filtered or unexported fields
}

ConfigKeyStore is an in-memory keystore backed by a static slice of UserKey values. It is designed for config-file driven setups (e.g. service accounts defined in YAML) with a small, bounded number of keys. For large or dynamic key sets use DatabaseKeyStore.

Pre-existing entries must have KeyHash set to the SHA-256 hex of the intended raw key. Keys created at runtime via CreateKey are held in memory only and lost on restart.

func NewConfigKeyStore

func NewConfigKeyStore(keys []sectypes.UserKey) *ConfigKeyStore

NewConfigKeyStore creates a ConfigKeyStore seeded with the provided keys. Pass nil or an empty slice to start with no pre-loaded keys. Zero-value entries (CreatedAt is zero) are treated as active and assigned the current time.

func (*ConfigKeyStore) CreateKey

CreateKey generates a new raw key, stores its SHA-256 hash, and returns the raw key once.

func (*ConfigKeyStore) DeleteKey

func (s *ConfigKeyStore) DeleteKey(_ context.Context, userID int, keyID int64) error

DeleteKey soft-deletes a key by setting IsActive to false after ownership verification.

func (*ConfigKeyStore) GetUserKeys

func (s *ConfigKeyStore) GetUserKeys(_ context.Context, userID int, keyType sectypes.KeyType) ([]sectypes.UserKey, error)

GetUserKeys returns all active, non-expired keys for the given user. Pass an empty KeyType to return all types.

func (*ConfigKeyStore) ValidateKey

func (s *ConfigKeyStore) ValidateKey(_ context.Context, rawKey string, keyType sectypes.KeyType) (*sectypes.UserKey, error)

ValidateKey hashes the raw key and finds a matching, active, non-expired entry. Uses constant-time comparison to prevent timing side-channels. Pass an empty KeyType to accept any type.

type ConfigRowSecurityProvider

type ConfigRowSecurityProvider struct {
	// contains filtered or unexported fields
}

ConfigRowSecurityProvider provides static row security configuration

func NewConfigRowSecurityProvider

func NewConfigRowSecurityProvider(templates map[string]string, blocked map[string]bool) *ConfigRowSecurityProvider

func (*ConfigRowSecurityProvider) GetRowSecurity

func (p *ConfigRowSecurityProvider) GetRowSecurity(ctx context.Context, userRef any, schema, table string) (sectypes.RowSecurity, error)

type HeaderAuthenticator

type HeaderAuthenticator struct{}

HeaderAuthenticator provides simple header-based authentication Expects: X-User-ID, X-User-Name, X-User-Level, X-Session-ID, X-Remote-ID, X-User-Roles, X-User-Email

func NewHeaderAuthenticator

func NewHeaderAuthenticator() *HeaderAuthenticator

func (*HeaderAuthenticator) Authenticate

func (a *HeaderAuthenticator) Authenticate(r *http.Request) (*sectypes.UserContext, error)

func (*HeaderAuthenticator) Login

func (*HeaderAuthenticator) LoginWithCookie

func (*HeaderAuthenticator) Logout

func (*HeaderAuthenticator) LogoutWithCookie

type KeyStoreAuthenticator

type KeyStoreAuthenticator struct {
	// contains filtered or unexported fields
}

KeyStoreAuthenticator implements the Authenticator interface using a KeyStore. It is suitable for long-lived application credentials (API keys, JWT secrets, etc.) rather than interactive sessions. Login and Logout are not supported — key lifecycle is managed directly through the KeyStore.

Key extraction order:

  1. Authorization: Bearer <key>
  2. Authorization: ApiKey <key>
  3. X-API-Key header

func NewKeyStoreAuthenticator

func NewKeyStoreAuthenticator(ks security.KeyStore, keyType sectypes.KeyType) *KeyStoreAuthenticator

NewKeyStoreAuthenticator creates a KeyStoreAuthenticator. Pass an empty keyType to accept keys of any type.

func (*KeyStoreAuthenticator) Authenticate

func (a *KeyStoreAuthenticator) Authenticate(r *http.Request) (*sectypes.UserContext, error)

Authenticate extracts an API key from the request and validates it against the KeyStore. Returns a UserContext built from the matching UserKey on success.

func (*KeyStoreAuthenticator) Login

Login is not supported for keystore authentication.

func (*KeyStoreAuthenticator) LoginWithCookie

LoginWithCookie is not supported for keystore authentication.

func (*KeyStoreAuthenticator) Logout

Logout is not supported for keystore authentication.

func (*KeyStoreAuthenticator) LogoutWithCookie

LogoutWithCookie is not supported for keystore authentication.

func (*KeyStoreAuthenticator) SetAuthenticateCallback

func (a *KeyStoreAuthenticator) SetAuthenticateCallback(fn func(r *http.Request) (*sectypes.UserContext, error))

SetAuthenticateCallback registers a fallback called when key authentication fails.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL