Documentation
¶
Index ¶
- Variables
- func AuthenticationMiddleware(next http.Handler) http.Handler
- func BuildClientTLSConfig(cfg TLSConfig) (*tls.Config, error)
- func ContextWithTenant(ctx context.Context, tc *TenantContext) context.Context
- func GRPCDialOption(cfg TLSConfig) (grpc.DialOption, error)
- func HTTPAuthMiddleware(validator AccessValidator, audit *AuditLogger, requiredPerm string) func(http.Handler) http.Handler
- func SecurityHeaders(next http.Handler) http.Handler
- func ValidateInput(input string) error
- type AccessValidator
- type AuditEntry
- type AuditLogger
- type CertReloader
- func (r *CertReloader) BuildServerTLSConfig() (*tls.Config, error)
- func (r *CertReloader) GRPCServerOption() (grpc.ServerOption, error)
- func (r *CertReloader) GetCertificate(_ *tls.ClientHelloInfo) (*tls.Certificate, error)
- func (r *CertReloader) GetClientCertificate(_ *tls.CertificateRequestInfo) (*tls.Certificate, error)
- func (r *CertReloader) Reload() error
- func (r *CertReloader) Rotations() int64
- func (r *CertReloader) StartAutoReload(interval time.Duration)
- func (r *CertReloader) Stop()
- type Claims
- type InputSanitizer
- type JWTClaims
- type KMSConfig
- type KeyProvider
- type LocalKeyProvider
- func (p *LocalKeyProvider) ActiveKeyID(_ context.Context) (string, error)
- func (p *LocalKeyProvider) GenerateDEK(_ context.Context) ([]byte, WrappedDEK, error)
- func (p *LocalKeyProvider) RotateKey(_ context.Context) (string, error)
- func (p *LocalKeyProvider) UnwrapDEK(_ context.Context, wrapped WrappedDEK) ([]byte, error)
- type OAuthManager
- func (m *OAuthManager) CreateSession(token *SSOToken, userInfo UserInfo) (*Session, error)
- func (m *OAuthManager) DeleteSession(sessionID string)
- func (m *OAuthManager) ExchangeCode(ctx context.Context, provider OAuthProvider, code string) (*SSOToken, error)
- func (m *OAuthManager) GetAuthURL(provider OAuthProvider, state string) (string, error)
- func (m *OAuthManager) GetSession(sessionID string) (*Session, error)
- func (m *OAuthManager) GetUserInfo(ctx context.Context, provider OAuthProvider, token *SSOToken) (*UserInfo, error)
- func (m *OAuthManager) IsDomainAllowed(email string) bool
- func (m *OAuthManager) Middleware() func(http.Handler) http.Handler
- func (m *OAuthManager) RefreshToken(ctx context.Context, refreshToken string) (*SSOToken, error)
- func (m *OAuthManager) RequireAdmin(next http.Handler) http.Handler
- func (m *OAuthManager) RequireAuth(next http.Handler) http.Handler
- func (m *OAuthManager) ValidateToken(ctx context.Context, tokenString string) (*JWTClaims, error)
- type OAuthProvider
- type OAuthState
- type OIDCAccessValidator
- type OIDCClaims
- type OIDCConfig
- type OIDCIssuerConfig
- type OIDCManager
- func (m *OIDCManager) AddIssuer(cfg OIDCIssuerConfig) error
- func (m *OIDCManager) Enabled() bool
- func (m *OIDCManager) ListIssuers() []OIDCIssuerConfig
- func (m *OIDCManager) RemoveIssuer(issuerURL string) bool
- func (m *OIDCManager) ValidateToken(ctx context.Context, rawToken string) (claims *OIDCClaims, err error)
- type OIDCProviderKind
- type RLSEvaluator
- type RLSOperator
- type RLSPolicy
- type RLSRule
- type RateLimiter
- type SSOConfig
- type SSOToken
- type Session
- type SessionStore
- type TLSConfig
- type TenantContext
- type TokenGenerator
- type UserInfo
- type VaultTransitKeyProvider
- func (v *VaultTransitKeyProvider) ActiveKeyID(_ context.Context) (string, error)
- func (v *VaultTransitKeyProvider) GenerateDEK(ctx context.Context) ([]byte, WrappedDEK, error)
- func (v *VaultTransitKeyProvider) RotateKey(ctx context.Context) (string, error)
- func (v *VaultTransitKeyProvider) UnwrapDEK(ctx context.Context, wrapped WrappedDEK) ([]byte, error)
- type WrappedDEK
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidToken = errors.New("invalid token") ErrTokenExpired = errors.New("token expired") ErrInvalidProvider = errors.New("invalid OAuth provider") ErrMissingCode = errors.New("authorization code missing") ErrUserNotAuthorized = errors.New("user not authorized") )
var ( ErrKeyNotFound = errors.New("kms: key version not found") ErrInvalidKeySize = errors.New("kms: master key must be 32 bytes (AES-256)") )
Functions ¶
func AuthenticationMiddleware ¶
AuthenticationMiddleware provides basic authentication middleware
func BuildClientTLSConfig ¶
BuildClientTLSConfig builds a client *tls.Config with optional mTLS and custom CA trust.
func ContextWithTenant ¶
func ContextWithTenant(ctx context.Context, tc *TenantContext) context.Context
ContextWithTenant returns a derived context carrying TenantContext.
func GRPCDialOption ¶
func GRPCDialOption(cfg TLSConfig) (grpc.DialOption, error)
GRPCDialOption returns gRPC transport credentials for clients.
func HTTPAuthMiddleware ¶
func HTTPAuthMiddleware(validator AccessValidator, audit *AuditLogger, requiredPerm string) func(http.Handler) http.Handler
HTTPAuthMiddleware enforces RBAC Bearer / X-API-Key authentication on HTTP handlers when validator is non-nil.
func SecurityHeaders ¶
SecurityHeaders adds security-related HTTP headers
func ValidateInput ¶
ValidateInput validates and sanitizes input parameters
Types ¶
type AccessValidator ¶
type AccessValidator interface {
AuthorizeToken(ctx context.Context, rawToken, permission, namespace, dataset string) (*TenantContext, error)
}
AccessValidator validates raw API keys or bearer tokens and resolves TenantContext + authorization.
type AuditEntry ¶
type AuditEntry struct {
Timestamp time.Time `json:"timestamp"`
UserID string `json:"user_id"`
TenantID string `json:"tenant_id,omitempty"`
Operation string `json:"operation"`
Resource string `json:"resource"`
IPAddress string `json:"ip_address"`
Success bool `json:"success"`
Reason string `json:"reason,omitempty"`
}
AuditEntry represents a security audit log entry
type AuditLogger ¶
type AuditLogger struct {
// contains filtered or unexported fields
}
AuditLogger handles security audit logging with an in-memory queryable ring buffer.
func (*AuditLogger) LogAuditEntry ¶
func (a *AuditLogger) LogAuditEntry(ctx context.Context, entry *AuditEntry)
LogAuditEntry logs an audit entry and records it in the ring buffer.
func (*AuditLogger) RecentEntries ¶
func (a *AuditLogger) RecentEntries(limit int) []AuditEntry
RecentEntries returns up to limit most recent audit log entries (newest first).
func (*AuditLogger) RecordEvent ¶
func (a *AuditLogger) RecordEvent(ctx context.Context, userID, tenantID, op, resource, ip string, success bool, reason string)
RecordEvent creates and logs a structured AuditEntry.
type CertReloader ¶
type CertReloader struct {
// contains filtered or unexported fields
}
CertReloader loads and hot-reloads X.509 key pairs and CA trust pools without restarts.
func NewCertReloader ¶
func NewCertReloader(cfg TLSConfig) (*CertReloader, error)
NewCertReloader initializes a CertReloader and loads initial certificates from disk.
func (*CertReloader) BuildServerTLSConfig ¶
func (r *CertReloader) BuildServerTLSConfig() (*tls.Config, error)
BuildServerTLSConfig creates a server *tls.Config using dynamic certificate and CA lookup.
func (*CertReloader) GRPCServerOption ¶
func (r *CertReloader) GRPCServerOption() (grpc.ServerOption, error)
GRPCServerOption returns the grpc.Creds server option for this reloader when TLS is enabled.
func (*CertReloader) GetCertificate ¶
func (r *CertReloader) GetCertificate(_ *tls.ClientHelloInfo) (*tls.Certificate, error)
GetCertificate returns the active server certificate for TLS handshakes.
func (*CertReloader) GetClientCertificate ¶
func (r *CertReloader) GetClientCertificate(_ *tls.CertificateRequestInfo) (*tls.Certificate, error)
GetClientCertificate returns the active client certificate for mTLS handshakes.
func (*CertReloader) Reload ¶
func (r *CertReloader) Reload() error
Reload reloads the certificate/key pair and optional CA bundle atomically.
func (*CertReloader) Rotations ¶
func (r *CertReloader) Rotations() int64
Rotations returns the number of successful certificate loads/rotations.
func (*CertReloader) StartAutoReload ¶
func (r *CertReloader) StartAutoReload(interval time.Duration)
StartAutoReload begins periodic certificate rotation checks until Stop is called.
func (*CertReloader) Stop ¶
func (r *CertReloader) Stop()
Stop stops the background certificate reloader.
type Claims ¶
type InputSanitizer ¶
type InputSanitizer struct{}
InputSanitizer provides input sanitization functions
func NewInputSanitizer ¶
func NewInputSanitizer() *InputSanitizer
NewInputSanitizer creates a new input sanitizer
func (*InputSanitizer) SanitizeString ¶
func (is *InputSanitizer) SanitizeString(input string) string
SanitizeString removes potentially dangerous characters
type KMSConfig ¶
type KMSConfig struct {
Provider string `envconfig:"KMS_PROVIDER" json:"provider"` // "local", "env", "vault"
MasterKeyHex string `envconfig:"KMS_MASTER_KEY" json:"master_key_hex,omitempty"`
MasterKeyEnv string `envconfig:"KMS_MASTER_KEY_ENV" json:"master_key_env,omitempty"`
VaultAddr string `envconfig:"VAULT_ADDR" json:"vault_addr,omitempty"`
VaultToken string `envconfig:"VAULT_TOKEN" json:"vault_token,omitempty"`
VaultMount string `envconfig:"VAULT_TRANSIT_MOUNT" json:"vault_mount,omitempty"`
VaultKeyName string `envconfig:"VAULT_TRANSIT_KEY" json:"vault_key_name,omitempty"`
}
KMSConfig configures key management for encryption at rest.
type KeyProvider ¶
type KeyProvider interface {
ActiveKeyID(ctx context.Context) (string, error)
GenerateDEK(ctx context.Context) (plaintext []byte, wrapped WrappedDEK, err error)
UnwrapDEK(ctx context.Context, wrapped WrappedDEK) ([]byte, error)
RotateKey(ctx context.Context) (string, error)
}
KeyProvider abstracts local keys, environment keys, and external KMS/Vault Transit.
func NewKeyProviderFromConfig ¶
func NewKeyProviderFromConfig(cfg KMSConfig) (KeyProvider, error)
NewKeyProviderFromConfig constructs a KeyProvider from KMSConfig.
type LocalKeyProvider ¶
type LocalKeyProvider struct {
// contains filtered or unexported fields
}
LocalKeyProvider implements envelope encryption with zero-downtime key rotation in memory.
func NewLocalKeyProvider ¶
func NewLocalKeyProvider(masterKey []byte) (*LocalKeyProvider, error)
NewLocalKeyProvider creates a LocalKeyProvider with an optional initial 32-byte KEK. If masterKey is nil, a fresh CSPRNG 32-byte KEK is generated.
func NewLocalKeyProviderFromSecret ¶
func NewLocalKeyProviderFromSecret(secret string) (*LocalKeyProvider, error)
NewLocalKeyProviderFromSecret derives or decodes a 32-byte key from hex/base64 or passphrase string.
func (*LocalKeyProvider) ActiveKeyID ¶
func (p *LocalKeyProvider) ActiveKeyID(_ context.Context) (string, error)
func (*LocalKeyProvider) GenerateDEK ¶
func (p *LocalKeyProvider) GenerateDEK(_ context.Context) ([]byte, WrappedDEK, error)
func (*LocalKeyProvider) RotateKey ¶
func (p *LocalKeyProvider) RotateKey(_ context.Context) (string, error)
func (*LocalKeyProvider) UnwrapDEK ¶
func (p *LocalKeyProvider) UnwrapDEK(_ context.Context, wrapped WrappedDEK) ([]byte, error)
type OAuthManager ¶
type OAuthManager struct {
// contains filtered or unexported fields
}
func NewOAuthManager ¶
func NewOAuthManager(config SSOConfig) (*OAuthManager, error)
func (*OAuthManager) CreateSession ¶
func (m *OAuthManager) CreateSession(token *SSOToken, userInfo UserInfo) (*Session, error)
func (*OAuthManager) DeleteSession ¶
func (m *OAuthManager) DeleteSession(sessionID string)
func (*OAuthManager) ExchangeCode ¶
func (m *OAuthManager) ExchangeCode(ctx context.Context, provider OAuthProvider, code string) (*SSOToken, error)
func (*OAuthManager) GetAuthURL ¶
func (m *OAuthManager) GetAuthURL(provider OAuthProvider, state string) (string, error)
func (*OAuthManager) GetSession ¶
func (m *OAuthManager) GetSession(sessionID string) (*Session, error)
func (*OAuthManager) GetUserInfo ¶
func (m *OAuthManager) GetUserInfo(ctx context.Context, provider OAuthProvider, token *SSOToken) (*UserInfo, error)
func (*OAuthManager) IsDomainAllowed ¶
func (m *OAuthManager) IsDomainAllowed(email string) bool
func (*OAuthManager) Middleware ¶
func (m *OAuthManager) Middleware() func(http.Handler) http.Handler
func (*OAuthManager) RefreshToken ¶
func (*OAuthManager) RequireAdmin ¶
func (m *OAuthManager) RequireAdmin(next http.Handler) http.Handler
func (*OAuthManager) RequireAuth ¶
func (m *OAuthManager) RequireAuth(next http.Handler) http.Handler
func (*OAuthManager) ValidateToken ¶
type OAuthProvider ¶
type OAuthProvider string
const ( ProviderGitHub OAuthProvider = "github" ProviderGoogle OAuthProvider = "google" ProviderMicrosoft OAuthProvider = "microsoft" ProviderOIDC OAuthProvider = "oidc" )
type OAuthState ¶
type OAuthState struct {
State string
Provider OAuthProvider
Expiry time.Time
}
type OIDCAccessValidator ¶
type OIDCAccessValidator struct {
// contains filtered or unexported fields
}
OIDCAccessValidator resolves federated OIDC tokens to TenantContext and enforces permission, namespace, and dataset boundaries.
func NewOIDCAccessValidator ¶
func NewOIDCAccessValidator(manager *OIDCManager) *OIDCAccessValidator
NewOIDCAccessValidator creates a validator backed by an OIDCManager.
func (*OIDCAccessValidator) AuthorizeToken ¶
func (v *OIDCAccessValidator) AuthorizeToken(ctx context.Context, rawToken, permission, namespace, dataset string) (*TenantContext, error)
AuthorizeToken implements AccessValidator.
func (*OIDCAccessValidator) SetAuditLogger ¶
func (v *OIDCAccessValidator) SetAuditLogger(a *AuditLogger)
SetAuditLogger attaches an audit logger.
type OIDCClaims ¶
type OIDCClaims struct {
Subject string `json:"sub"`
Issuer string `json:"iss"`
Audience []string `json:"aud"`
Expiry int64 `json:"exp"`
IssuedAt int64 `json:"iat"`
NotBefore int64 `json:"nbf,omitempty"`
JTI string `json:"jti,omitempty"`
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
Groups []string `json:"groups,omitempty"`
Raw map[string]interface{} `json:"-"`
Provider OIDCProviderKind `json:"-"`
IssuerCfg OIDCIssuerConfig `json:"-"`
}
OIDCClaims is the validated claim set extracted from a federated token.
func (*OIDCClaims) ToTenantContext ¶
func (c *OIDCClaims) ToTenantContext() *TenantContext
ToTenantContext maps validated claims into a TenantContext using issuer config.
type OIDCConfig ¶
type OIDCConfig struct {
Enabled bool `json:"enabled"`
Issuers []OIDCIssuerConfig `json:"issuers"`
JTICache int `json:"jti_cache_size,omitempty"`
}
OIDCConfig holds federation settings for the security layer.
type OIDCIssuerConfig ¶
type OIDCIssuerConfig struct {
Provider OIDCProviderKind `json:"provider"`
IssuerURL string `json:"issuer_url"`
JWKSURL string `json:"jwks_url,omitempty"`
Audience string `json:"audience"`
AllowedAlgs []string `json:"allowed_algs,omitempty"`
RoleClaim string `json:"role_claim,omitempty"`
TenantClaim string `json:"tenant_claim,omitempty"`
NamespaceClaim string `json:"namespace_claim,omitempty"`
DatasetsClaim string `json:"datasets_claim,omitempty"`
RowFilterClaim string `json:"row_filter_claim,omitempty"`
AdminClaim string `json:"admin_claim,omitempty"`
AdminValue string `json:"admin_value,omitempty"`
ClockSkew time.Duration `json:"clock_skew,omitempty"`
RefreshInterval time.Duration `json:"refresh_interval,omitempty"`
TrustPolicyARN string `json:"trust_policy_arn,omitempty"` // AWS role ARN / Google principal
}
OIDCIssuerConfig describes a trusted OIDC issuer used for federation.
func AWSOIDCIssuerConfig ¶
func AWSOIDCIssuerConfig(issuerURL, audience string) OIDCIssuerConfig
AWSOIDCIssuerConfig returns a sensible default config for AWS IAM / IRSA style OIDC federation. issuerURL is the cluster/provider issuer (e.g. https://oidc.eks.<region>.amazonaws.com/id/<id>).
func GoogleOIDCIssuerConfig ¶
func GoogleOIDCIssuerConfig(clientID string) OIDCIssuerConfig
GoogleOIDCIssuerConfig returns a sensible default config for Google IAM / Workload Identity Federation.
type OIDCManager ¶
type OIDCManager struct {
// contains filtered or unexported fields
}
OIDCManager validates federated OIDC tokens and maps them to TenantContext.
func NewOIDCManager ¶
func NewOIDCManager(cfg OIDCConfig) *OIDCManager
NewOIDCManager creates a manager from config.
func (*OIDCManager) AddIssuer ¶
func (m *OIDCManager) AddIssuer(cfg OIDCIssuerConfig) error
AddIssuer registers or updates a trusted OIDC issuer configuration.
func (*OIDCManager) Enabled ¶
func (m *OIDCManager) Enabled() bool
Enabled returns whether OIDC federation is active.
func (*OIDCManager) ListIssuers ¶
func (m *OIDCManager) ListIssuers() []OIDCIssuerConfig
ListIssuers returns a copy of all configured OIDC issuers.
func (*OIDCManager) RemoveIssuer ¶
func (m *OIDCManager) RemoveIssuer(issuerURL string) bool
RemoveIssuer removes a configured issuer by URL.
func (*OIDCManager) ValidateToken ¶
func (m *OIDCManager) ValidateToken(ctx context.Context, rawToken string) (claims *OIDCClaims, err error)
ValidateToken validates a federated OIDC JWT and returns claims.
type OIDCProviderKind ¶
type OIDCProviderKind string
OIDCProviderKind identifies the cloud identity provider backing an issuer.
const ( OIDCProviderGeneric OIDCProviderKind = "generic" OIDCProviderAWS OIDCProviderKind = "aws" OIDCProviderGoogle OIDCProviderKind = "google" )
type RLSEvaluator ¶
type RLSEvaluator struct {
// contains filtered or unexported fields
}
RLSEvaluator evaluates row-level security policies across metadata maps.
func NewRLSEvaluator ¶
func NewRLSEvaluator() *RLSEvaluator
NewRLSEvaluator creates a new row-level security evaluator.
func (*RLSEvaluator) DeletePolicy ¶
func (e *RLSEvaluator) DeletePolicy(namespace, dataset string)
DeletePolicy deletes an RLS policy by namespace and dataset.
func (*RLSEvaluator) EvaluateMetadata ¶
func (e *RLSEvaluator) EvaluateMetadata(tc *TenantContext, namespace, dataset string, meta map[string]any) bool
EvaluateMetadata checks whether a record's metadata passes all applicable RLS rules and TenantContext row filters.
func (*RLSEvaluator) GetPolicies ¶
func (e *RLSEvaluator) GetPolicies() []RLSPolicy
GetPolicies returns all configured RLS policies.
func (*RLSEvaluator) SetPolicy ¶
func (e *RLSEvaluator) SetPolicy(policy RLSPolicy) error
SetPolicy registers or replaces an RLS policy.
type RLSOperator ¶
type RLSOperator string
RLSOperator defines supported comparison operators for row-level security predicates.
const ( RLSOpEq RLSOperator = "eq" RLSOpNeq RLSOperator = "neq" RLSOpPrefix RLSOperator = "prefix" RLSOpIn RLSOperator = "in" )
type RLSPolicy ¶
type RLSPolicy struct {
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Dataset string `json:"dataset,omitempty"`
Rules []RLSRule `json:"rules"`
Enabled bool `json:"enabled"`
}
RLSPolicy binds row-level security rules to a dataset or namespace wildcard.
type RLSRule ¶
type RLSRule struct {
Field string `json:"field"`
Operator RLSOperator `json:"operator"`
Value string `json:"value,omitempty"`
ExpectedFromClaim string `json:"expected_from_claim,omitempty"`
}
RLSRule represents a single predicate on record metadata. When ExpectedFromClaim is set (e.g. "tenant_id", "user_id"), the expected value is taken from TenantContext.
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter provides basic rate limiting functionality
func NewRateLimiter ¶
func NewRateLimiter(maxRequests, windowSeconds int) *RateLimiter
NewRateLimiter creates a new rate limiter
func (*RateLimiter) CheckRateLimit ¶
func (rl *RateLimiter) CheckRateLimit(ip string) bool
CheckRateLimit checks if a request exceeds rate limits
type SSOConfig ¶
type SSOConfig struct {
Enabled bool `json:"enabled"`
Providers []OAuthProvider `json:"providers"`
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
RedirectURL string `json:"redirect_url"`
Scopes []string `json:"scopes"`
AllowedDomains []string `json:"allowed_domains"`
SessionLifetime time.Duration `json:"session_lifetime"`
JWKSPort int `json:"jwks_port"`
}
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
func NewSessionStore ¶
func NewSessionStore() *SessionStore
func (*SessionStore) Delete ¶
func (s *SessionStore) Delete(id string)
func (*SessionStore) Store ¶
func (s *SessionStore) Store(session *Session)
type TLSConfig ¶
type TLSConfig struct {
Enabled bool `envconfig:"TLS_ENABLED" json:"enabled"`
CertFile string `envconfig:"TLS_CERT_FILE" json:"cert_file"`
KeyFile string `envconfig:"TLS_KEY_FILE" json:"key_file"`
CAFile string `envconfig:"TLS_CA_FILE" json:"ca_file"`
RequireClientCert bool `envconfig:"TLS_REQUIRE_CLIENT_CERT" json:"require_client_cert"`
MinVersion string `envconfig:"TLS_MIN_VERSION" json:"min_version"` // "1.2" or "1.3"
ReloadInterval time.Duration `envconfig:"TLS_RELOAD_INTERVAL" json:"reload_interval"`
ServerName string `envconfig:"TLS_SERVER_NAME" json:"server_name,omitempty"`
}
TLSConfig defines server/client TLS and mTLS settings.
type TenantContext ¶
type TenantContext struct {
TenantID string `json:"tenant_id"`
Namespace string `json:"namespace"`
UserID string `json:"user_id"`
KeyID string `json:"key_id"`
Roles []string `json:"roles"`
Permissions []string `json:"permissions"`
Datasets []string `json:"datasets,omitempty"`
RowFilters map[string]string `json:"row_filters,omitempty"`
IsAdmin bool `json:"is_admin"`
}
TenantContext holds authenticated identity, tenant boundary, roles, and RLS metadata.
func TenantFromContext ¶
func TenantFromContext(ctx context.Context) (*TenantContext, bool)
TenantFromContext retrieves TenantContext from ctx if present.
func (*TenantContext) CanAccessDataset ¶
func (tc *TenantContext) CanAccessDataset(namespace, dataset string) bool
CanAccessDataset verifies whether this TenantContext can access the given namespace/dataset.
func (*TenantContext) HasPermission ¶
func (tc *TenantContext) HasPermission(perm string) bool
HasPermission checks whether TenantContext carries a permission string.
type TokenGenerator ¶
type TokenGenerator struct {
// contains filtered or unexported fields
}
func NewTokenGenerator ¶
func NewTokenGenerator(issuer, audience string) (*TokenGenerator, error)
func (*TokenGenerator) GenerateToken ¶
func (g *TokenGenerator) GenerateToken(claims Claims) (string, error)
func (*TokenGenerator) ValidateToken ¶
func (g *TokenGenerator) ValidateToken(tokenString string) (*Claims, error)
type VaultTransitKeyProvider ¶
type VaultTransitKeyProvider struct {
// contains filtered or unexported fields
}
VaultTransitKeyProvider delegates DEK generation/unwrapping/rotation to HashiCorp Vault Transit engine.
func NewVaultTransitKeyProvider ¶
func NewVaultTransitKeyProvider(addr, token, mount, keyName string) (*VaultTransitKeyProvider, error)
NewVaultTransitKeyProvider creates a HashiCorp Vault Transit KeyProvider.
func (*VaultTransitKeyProvider) ActiveKeyID ¶
func (v *VaultTransitKeyProvider) ActiveKeyID(_ context.Context) (string, error)
func (*VaultTransitKeyProvider) GenerateDEK ¶
func (v *VaultTransitKeyProvider) GenerateDEK(ctx context.Context) ([]byte, WrappedDEK, error)
func (*VaultTransitKeyProvider) RotateKey ¶
func (v *VaultTransitKeyProvider) RotateKey(ctx context.Context) (string, error)
func (*VaultTransitKeyProvider) UnwrapDEK ¶
func (v *VaultTransitKeyProvider) UnwrapDEK(ctx context.Context, wrapped WrappedDEK) ([]byte, error)
type WrappedDEK ¶
WrappedDEK holds a wrapped Data Encryption Key along with its wrapping KEK version ID.