Versions in this module Expand all Collapse all v0 v0.1.1 Feb 22, 2026 v0.1.0 Feb 16, 2026 Changes in this version + const ActionAdmin + const ActionRead + const ActionWrite + const DefaultSessionTTLSeconds + const ErrorCodeAuthFail + const ErrorCodeDenied + const ErrorMsgAuthFail + const ErrorMsgDenied + const ErrorSeverity + const FieldParse + const FieldPasswordMessage + const FieldQuery + const FieldRequest + const FieldResponse + const FieldSASLInitialResponse + const FieldSASLResponse + const FieldStartupMessage + const MD5PasswordLength + const ParamDatabase + const ParamUser + const SaltSize + const ScramIterations + var ActiveSessions = promauto.NewGauge(prometheus.GaugeOpts{ ... }) + var AuthFailures = promauto.NewCounter(prometheus.CounterOpts{ ... }) + var AuthSuccesses = promauto.NewCounter(prometheus.CounterOpts{ ... }) + var AuthzDenials = promauto.NewCounter(prometheus.CounterOpts{ ... }) + var ErrDatabaseNotAllowed = errors.New("database not allowed for user") + var ErrNoParameters = errors.New("no parameters in startup message") + var ErrNoSASLInitialData = errors.New("no SASL initial data found in message") + var ErrNoSASLResponseData = errors.New("no SASL response data found in message") + var ErrNoUser = errors.New("no user in startup message") + var ErrUserDisabled = errors.New("user is disabled") + var ErrUserNotFound = errors.New("user not found") + var GetPluginConfigCalls = promauto.NewCounter(prometheus.CounterOpts{ ... }) + var OnTrafficFromClientCalls = promauto.NewCounter(prometheus.CounterOpts{ ... }) + var PluginConfig = map[string]interface + var PluginID = v1.PluginID + var PluginMap = map[string]goplugin.Plugin + func BuildAccessDeniedResponse(detail string) ([]byte, error) + func BuildAuthFailResponse(detail string) ([]byte, error) + func DecodeBase64Field(encoded string) ([]byte, error) + func GenerateSalt(_ int) ([SaltSize]byte, error) + func GetClientRemote(fields map[string]interface{}) string + func ParsePasswordMessage(passwordDecoded []byte) map[string]string + func ParseStartupParams(startupDecoded []byte) (string, string, error) + type AuthGRPCPlugin struct + Impl Plugin + func (p *AuthGRPCPlugin) GRPCClient(_ context.Context, _ *goplugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) + func (p *AuthGRPCPlugin) GRPCServer(_ *goplugin.GRPCBroker, s *grpc.Server) error + type AuthHandler struct + Authenticators map[AuthType]Authenticator + Authorizer *Authorizer + CredStore CredentialStore + DefaultAuth AuthType + Logger hclog.Logger + Sessions *SessionManager + func NewAuthHandler(logger hclog.Logger, sessions *SessionManager, credStore CredentialStore, ...) *AuthHandler + func (h *AuthHandler) HandleTrafficFromClient(ctx context.Context, req *v1.Struct) (*v1.Struct, error) + type AuthState int + const StateAuthenticated + const StateChallengeSent + const StateFailed + const StateInit + const StateScramContinue + type AuthType string + const AuthCleartext + const AuthMD5 + const AuthScramSHA256 + type Authenticator interface + HandleResponse func(session *Session, cred *UserCredential, msgData map[string]string) ([]byte, bool, error) + HandleStartup func(session *Session, cred *UserCredential) ([]byte, error) + Name func() AuthType + type Authorizer struct + func NewAuthorizer(modelPath, policyPath string, logger hclog.Logger) (*Authorizer, error) + func (a *Authorizer) Authorize(username, database, query string) (bool, error) + func (a *Authorizer) ReloadPolicy() error + type CleartextAuthenticator struct + ServerVersion string + func (a *CleartextAuthenticator) HandleResponse(session *Session, cred *UserCredential, msgData map[string]string) ([]byte, bool, error) + func (a *CleartextAuthenticator) HandleStartup(session *Session, _ *UserCredential) ([]byte, error) + func (a *CleartextAuthenticator) Name() AuthType + type ConfigValues struct + AuthType AuthType + AuthorizationEnabled bool + CasbinModelPath string + CasbinPolicyPath string + CredentialsFile string + MetricsEnabled bool + MetricsEndpoint string + MetricsUnixDomainSocket string + ServerVersion string + SessionTTLSeconds int + func DefaultConfig() *ConfigValues + func ParseConfig(cfg map[string]interface{}) *ConfigValues + type CredentialStore interface + LookupUser func(ctx context.Context, username string) (*UserCredential, error) + Reload func(ctx context.Context) error + type FileCredentialStore struct + func NewFileCredentialStore(filePath string) (*FileCredentialStore, error) + func (s *FileCredentialStore) LookupUser(_ context.Context, username string) (*UserCredential, error) + func (s *FileCredentialStore) Reload(_ context.Context) error + type MD5Authenticator struct + ServerVersion string + func (a *MD5Authenticator) HandleResponse(session *Session, cred *UserCredential, msgData map[string]string) ([]byte, bool, error) + func (a *MD5Authenticator) HandleStartup(session *Session, _ *UserCredential) ([]byte, error) + func (a *MD5Authenticator) Name() AuthType + type Plugin struct + AuthHandler *AuthHandler + Logger hclog.Logger + func (p *Plugin) GetPluginConfig(_ context.Context, _ *v1.Struct) (*v1.Struct, error) + func (p *Plugin) OnClosed(_ context.Context, req *v1.Struct) (*v1.Struct, error) + func (p *Plugin) OnTrafficFromClient(ctx context.Context, req *v1.Struct) (*v1.Struct, error) + func (p *Plugin) OnTrafficFromServer(_ context.Context, req *v1.Struct) (*v1.Struct, error) + type ScramAuthenticator struct + ServerVersion string + func (a *ScramAuthenticator) HandleResponse(session *Session, cred *UserCredential, msgData map[string]string) ([]byte, bool, error) + func (a *ScramAuthenticator) HandleStartup(session *Session, _ *UserCredential) ([]byte, error) + func (a *ScramAuthenticator) Name() AuthType + type ScramServerState struct + AuthID string + Conversation interface{} + ServerFirstMsg []byte + type Session struct + AuthMethod AuthType + AuthenticatedAt time.Time + CreatedAt time.Time + Database string + Roles []string + Salt [SaltSize]byte + ScramState *ScramServerState + State AuthState + Username string + type SessionManager struct + func NewSessionManager(ttl time.Duration) *SessionManager + func (sm *SessionManager) Cleanup() + func (sm *SessionManager) Count() int + func (sm *SessionManager) Get(key string) *Session + func (sm *SessionManager) GetOrCreate(key string) *Session + func (sm *SessionManager) IsAuthenticated(key string) bool + func (sm *SessionManager) Remove(key string) + func (sm *SessionManager) StartCleanupLoop(interval time.Duration, done <-chan struct{}) + type UserCredential struct + AuthMethods []string + Databases []string + Enabled *bool + Password string + Roles []string + Username string + func (u *UserCredential) IsDatabaseAllowed(database string) bool + func (u *UserCredential) IsEnabled() bool + func (u *UserCredential) SupportsAuthMethod(method AuthType) bool