{"modulePath":"github.com/bitechdev/ResolveSpec","version":"v1.3.14","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package providers\n\n## Types\n\n```go\ntype ConfigColumnSecurityProvider struct {\n\t// contains filtered or unexported fields\n}\n```\nConfigColumnSecurityProvider provides static column security configuration\n\n```go\nfunc NewConfigColumnSecurityProvider(rules map[string][]sectypes.ColumnSecurity) *ConfigColumnSecurityProvider\n```\n\n```go\nfunc (p *ConfigColumnSecurityProvider) GetColumnSecurity(ctx context.Context, userID int, schema, table string) ([]sectypes.ColumnSecurity, error)\n```\n\n```go\ntype ConfigKeyStore struct {\n\t// contains filtered or unexported fields\n}\n```\nConfigKeyStore 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.\n\nPre-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.\n\n```go\nfunc NewConfigKeyStore(keys []sectypes.UserKey) *ConfigKeyStore\n```\nNewConfigKeyStore 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.\n\n```go\nfunc (s *ConfigKeyStore) CreateKey(_ context.Context, req sectypes.CreateKeyRequest) (*sectypes.CreateKeyResponse, error)\n```\nCreateKey generates a new raw key, stores its SHA-256 hash, and returns the raw key once.\n\n```go\nfunc (s *ConfigKeyStore) DeleteKey(_ context.Context, userID int, keyID int64) error\n```\nDeleteKey soft-deletes a key by setting IsActive to false after ownership verification.\n\n```go\nfunc (s *ConfigKeyStore) GetUserKeys(_ context.Context, userID int, keyType sectypes.KeyType) ([]sectypes.UserKey, error)\n```\nGetUserKeys returns all active, non-expired keys for the given user. Pass an empty KeyType to return all types.\n\n```go\nfunc (s *ConfigKeyStore) ValidateKey(_ context.Context, rawKey string, keyType sectypes.KeyType) (*sectypes.UserKey, error)\n```\nValidateKey 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.\n\n```go\ntype ConfigRowSecurityProvider struct {\n\t// contains filtered or unexported fields\n}\n```\nConfigRowSecurityProvider provides static row security configuration\n\n```go\nfunc NewConfigRowSecurityProvider(templates map[string]string, blocked map[string]bool) *ConfigRowSecurityProvider\n```\n\n```go\nfunc (p *ConfigRowSecurityProvider) GetRowSecurity(ctx context.Context, userRef any, schema, table string) (sectypes.RowSecurity, error)\n```\n\n```go\ntype HeaderAuthenticator struct{}\n```\nHeaderAuthenticator 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\n\n```go\nfunc NewHeaderAuthenticator() *HeaderAuthenticator\n```\n\n```go\nfunc (a *HeaderAuthenticator) Authenticate(r *http.Request) (*sectypes.UserContext, error)\n```\n\n```go\nfunc (a *HeaderAuthenticator) Login(ctx context.Context, req sectypes.LoginRequest) (*sectypes.LoginResponse, error)\n```\n\n```go\nfunc (a *HeaderAuthenticator) LoginWithCookie(ctx context.Context, req sectypes.LoginRequest, w http.ResponseWriter) (*sectypes.LoginResponse, error)\n```\n\n```go\nfunc (a *HeaderAuthenticator) Logout(ctx context.Context, req sectypes.LogoutRequest) error\n```\n\n```go\nfunc (a *HeaderAuthenticator) LogoutWithCookie(ctx context.Context, req sectypes.LogoutRequest, w http.ResponseWriter) error\n```\n\n```go\ntype KeyStoreAuthenticator struct {\n\t// contains filtered or unexported fields\n}\n```\nKeyStoreAuthenticator 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.\n\nKey extraction order:\n\n 1. Authorization: Bearer \\\u003ckey\u003e\n 2. Authorization: ApiKey \\\u003ckey\u003e\n 3. X-API-Key header\n\n```go\nfunc NewKeyStoreAuthenticator(ks security.KeyStore, keyType sectypes.KeyType) *KeyStoreAuthenticator\n```\nNewKeyStoreAuthenticator creates a KeyStoreAuthenticator. Pass an empty keyType to accept keys of any type.\n\n```go\nfunc (a *KeyStoreAuthenticator) Authenticate(r *http.Request) (*sectypes.UserContext, error)\n```\nAuthenticate extracts an API key from the request and validates it against the KeyStore. Returns a UserContext built from the matching UserKey on success.\n\n```go\nfunc (a *KeyStoreAuthenticator) Login(_ context.Context, _ sectypes.LoginRequest) (*sectypes.LoginResponse, error)\n```\nLogin is not supported for keystore authentication.\n\n```go\nfunc (a *KeyStoreAuthenticator) LoginWithCookie(_ context.Context, _ sectypes.LoginRequest, _ http.ResponseWriter) (*sectypes.LoginResponse, error)\n```\nLoginWithCookie is not supported for keystore authentication.\n\n```go\nfunc (a *KeyStoreAuthenticator) Logout(_ context.Context, _ sectypes.LogoutRequest) error\n```\nLogout is not supported for keystore authentication.\n\n```go\nfunc (a *KeyStoreAuthenticator) LogoutWithCookie(_ context.Context, _ sectypes.LogoutRequest, _ http.ResponseWriter) error\n```\nLogoutWithCookie is not supported for keystore authentication.\n\n```go\nfunc (a *KeyStoreAuthenticator) SetAuthenticateCallback(fn func(r *http.Request) (*sectypes.UserContext, error))\n```\nSetAuthenticateCallback registers a fallback called when key authentication fails.\n\n","path":"github.com/bitechdev/ResolveSpec/pkg/security/providers","name":"providers","synopsis":"","isRedistributable":true}
