Documentation
¶
Index ¶
- Constants
- func ApplyColumnSecurity(hookCtx *restheadspec.HookContext, securityList *SecurityList) error
- func ApplyRowSecurity(hookCtx *restheadspec.HookContext, securityList *SecurityList) error
- func CompleteServerExample(gormDB interface{}, sqlDB *sql.DB) http.Handler
- func ExampleConfigSecurity(gormDB interface{}) (*mux.Router, error)
- func ExampleDatabaseSecurity(gormDB interface{}, sqlDB *sql.DB) (http.Handler, error)
- func ExampleHeaderAuthentication(gormDB interface{}, sqlDB *sql.DB) (*mux.Router, error)
- func GetRemoteID(ctx context.Context) (string, bool)
- func GetSessionID(ctx context.Context) (string, bool)
- func GetUserEmail(ctx context.Context) (string, bool)
- func GetUserID(ctx context.Context) (int, bool)
- func GetUserLevel(ctx context.Context) (int, bool)
- func GetUserName(ctx context.Context) (string, bool)
- func GetUserRoles(ctx context.Context) ([]string, bool)
- func LoadSecurityRules(hookCtx *restheadspec.HookContext, securityList *SecurityList) error
- func LogDataAccess(hookCtx *restheadspec.HookContext) error
- func NewAuthMiddleware(securityList *SecurityList) func(http.Handler) http.Handler
- func RegisterSecurityHooks(handler *restheadspec.Handler, securityList *SecurityList)
- func SetSecurityMiddleware(securityList *SecurityList) func(http.Handler) http.Handler
- func SetupAuthRoutes(router *mux.Router, securityList *SecurityList)
- type Authenticator
- type CONTEXT_KEY
- type Cacheable
- type ColumnSecurity
- type ColumnSecurityProvider
- type CompositeSecurityProvider
- func (c *CompositeSecurityProvider) Authenticate(r *http.Request) (*UserContext, error)
- func (c *CompositeSecurityProvider) ClearCache(ctx context.Context, userID int, schema, table string) error
- func (c *CompositeSecurityProvider) GetColumnSecurity(ctx context.Context, userID int, schema, table string) ([]ColumnSecurity, error)
- func (c *CompositeSecurityProvider) GetRowSecurity(ctx context.Context, userID int, schema, table string) (RowSecurity, error)
- func (c *CompositeSecurityProvider) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
- func (c *CompositeSecurityProvider) Logout(ctx context.Context, req LogoutRequest) error
- func (c *CompositeSecurityProvider) RefreshToken(ctx context.Context, refreshToken string) (*LoginResponse, error)
- func (c *CompositeSecurityProvider) ValidateToken(ctx context.Context, token string) (bool, error)
- type ConfigColumnSecurityProvider
- type ConfigRowSecurityProvider
- type CustomSecurityProvider
- func (p *CustomSecurityProvider) Authenticate(r *http.Request) (*UserContext, error)
- func (p *CustomSecurityProvider) GetColumnSecurity(ctx context.Context, userID int, schema, table string) ([]ColumnSecurity, error)
- func (p *CustomSecurityProvider) GetRowSecurity(ctx context.Context, userID int, schema, table string) (RowSecurity, error)
- func (p *CustomSecurityProvider) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
- func (p *CustomSecurityProvider) Logout(ctx context.Context, req LogoutRequest) error
- type DatabaseAuthenticator
- func (a *DatabaseAuthenticator) Authenticate(r *http.Request) (*UserContext, error)
- func (a *DatabaseAuthenticator) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
- func (a *DatabaseAuthenticator) Logout(ctx context.Context, req LogoutRequest) error
- func (a *DatabaseAuthenticator) RefreshToken(ctx context.Context, refreshToken string) (*LoginResponse, error)
- type DatabaseAuthenticatorExample
- func (a *DatabaseAuthenticatorExample) Authenticate(r *http.Request) (*UserContext, error)
- func (a *DatabaseAuthenticatorExample) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
- func (a *DatabaseAuthenticatorExample) Logout(ctx context.Context, req LogoutRequest) error
- func (a *DatabaseAuthenticatorExample) RefreshToken(ctx context.Context, refreshToken string) (*LoginResponse, error)
- type DatabaseColumnSecurityProvider
- type DatabaseRowSecurityProvider
- type HeaderAuthenticator
- type HeaderAuthenticatorExample
- type JWTAuthenticator
- type JWTAuthenticatorExample
- type LoginRequest
- type LoginResponse
- type LogoutRequest
- type Refreshable
- type RowSecurity
- type RowSecurityProvider
- type SecurityList
- func (m *SecurityList) ApplyColumnSecurity(records reflect.Value, modelType reflect.Type, pUserID int, ...) (reflect.Value, error)
- func (m *SecurityList) ClearSecurity(pUserID int, pSchema, pTablename string) error
- func (m *SecurityList) ColumSecurityApplyOnRecord(prevRecord reflect.Value, newRecord reflect.Value, modelType reflect.Type, ...) ([]string, error)
- func (m *SecurityList) GetRowSecurityTemplate(pUserID int, pSchema, pTablename string) (RowSecurity, error)
- func (m *SecurityList) LoadColumnSecurity(ctx context.Context, pUserID int, pSchema, pTablename string, pOverwrite bool) error
- func (m *SecurityList) LoadRowSecurity(ctx context.Context, pUserID int, pSchema, pTablename string, pOverwrite bool) (RowSecurity, error)
- func (m *SecurityList) Provider() SecurityProvider
- type SecurityProvider
- type UserContext
- type Validatable
Constants ¶
const ( // Context keys for user information UserIDKey contextKey = "user_id" UserNameKey contextKey = "user_name" UserLevelKey contextKey = "user_level" SessionIDKey contextKey = "session_id" RemoteIDKey contextKey = "remote_id" UserRolesKey contextKey = "user_roles" UserEmailKey contextKey = "user_email" UserContextKey contextKey = "user_context" )
Variables ¶
This section is empty.
Functions ¶
func ApplyColumnSecurity ¶ added in v0.0.63
func ApplyColumnSecurity(hookCtx *restheadspec.HookContext, securityList *SecurityList) error
ApplyColumnSecurity applies column-level security (masking/hiding) to results
func ApplyRowSecurity ¶ added in v0.0.63
func ApplyRowSecurity(hookCtx *restheadspec.HookContext, securityList *SecurityList) error
ApplyRowSecurity applies row-level security filters to the query
func CompleteServerExample ¶ added in v0.0.63
func ExampleConfigSecurity ¶ added in v0.0.63
func ExampleDatabaseSecurity ¶ added in v0.0.63
func ExampleHeaderAuthentication ¶ added in v0.0.63
func GetRemoteID ¶ added in v0.0.63
GetRemoteID extracts the remote ID from context
func GetSessionID ¶ added in v0.0.63
GetSessionID extracts the session ID from context
func GetUserEmail ¶ added in v0.0.63
GetUserEmail extracts user email from context
func GetUserLevel ¶ added in v0.0.63
GetUserLevel extracts the user level from context
func GetUserName ¶ added in v0.0.63
GetUserName extracts the user name from context
func GetUserRoles ¶
GetUserRoles extracts user roles from context
func LoadSecurityRules ¶ added in v0.0.63
func LoadSecurityRules(hookCtx *restheadspec.HookContext, securityList *SecurityList) error
LoadSecurityRules loads security configuration for the user and entity
func LogDataAccess ¶ added in v0.0.63
func LogDataAccess(hookCtx *restheadspec.HookContext) error
LogDataAccess logs all data access for audit purposes
func NewAuthMiddleware ¶ added in v0.0.63
func NewAuthMiddleware(securityList *SecurityList) func(http.Handler) http.Handler
NewAuthMiddleware creates an authentication middleware with the given security list This middleware extracts user authentication from the request and adds it to context
func RegisterSecurityHooks ¶
func RegisterSecurityHooks(handler *restheadspec.Handler, securityList *SecurityList)
RegisterSecurityHooks registers all security-related hooks with the handler
func SetSecurityMiddleware ¶
func SetSecurityMiddleware(securityList *SecurityList) func(http.Handler) http.Handler
SetSecurityMiddleware adds security context to requests This middleware should be applied after AuthMiddleware
func SetupAuthRoutes ¶ added in v0.0.63
func SetupAuthRoutes(router *mux.Router, securityList *SecurityList)
Types ¶
type Authenticator ¶ added in v0.0.63
type Authenticator interface {
// Login authenticates credentials and returns a token
Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
// Logout invalidates a user's session/token
Logout(ctx context.Context, req LogoutRequest) error
// Authenticate extracts and validates user from HTTP request
// Returns UserContext or error if authentication fails
Authenticate(r *http.Request) (*UserContext, error)
}
Authenticator handles user authentication operations
type CONTEXT_KEY ¶ added in v0.0.20
type CONTEXT_KEY string
const SECURITY_CONTEXT_KEY CONTEXT_KEY = "SecurityList"
type Cacheable ¶ added in v0.0.63
type Cacheable interface {
// ClearCache clears cached security rules for a user/entity
ClearCache(ctx context.Context, userID int, schema, table string) error
}
Cacheable allows providers to support caching of security rules
type ColumnSecurity ¶
type ColumnSecurityProvider ¶ added in v0.0.63
type ColumnSecurityProvider interface {
// GetColumnSecurity loads column security rules for a user and entity
GetColumnSecurity(ctx context.Context, userID int, schema, table string) ([]ColumnSecurity, error)
}
ColumnSecurityProvider handles column-level security (masking/hiding)
type CompositeSecurityProvider ¶ added in v0.0.63
type CompositeSecurityProvider struct {
// contains filtered or unexported fields
}
CompositeSecurityProvider combines multiple security providers Allows separating authentication, column security, and row security concerns
func NewCompositeSecurityProvider ¶ added in v0.0.63
func NewCompositeSecurityProvider( auth Authenticator, colSec ColumnSecurityProvider, rowSec RowSecurityProvider, ) *CompositeSecurityProvider
NewCompositeSecurityProvider creates a composite provider All parameters are required
func (*CompositeSecurityProvider) Authenticate ¶ added in v0.0.63
func (c *CompositeSecurityProvider) Authenticate(r *http.Request) (*UserContext, error)
Authenticate delegates to the authenticator
func (*CompositeSecurityProvider) ClearCache ¶ added in v0.0.63
func (c *CompositeSecurityProvider) ClearCache(ctx context.Context, userID int, schema, table string) error
ClearCache implements Cacheable if any provider supports it
func (*CompositeSecurityProvider) GetColumnSecurity ¶ added in v0.0.63
func (c *CompositeSecurityProvider) GetColumnSecurity(ctx context.Context, userID int, schema, table string) ([]ColumnSecurity, error)
GetColumnSecurity delegates to the column security provider
func (*CompositeSecurityProvider) GetRowSecurity ¶ added in v0.0.63
func (c *CompositeSecurityProvider) GetRowSecurity(ctx context.Context, userID int, schema, table string) (RowSecurity, error)
GetRowSecurity delegates to the row security provider
func (*CompositeSecurityProvider) Login ¶ added in v0.0.63
func (c *CompositeSecurityProvider) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
Login delegates to the authenticator
func (*CompositeSecurityProvider) Logout ¶ added in v0.0.63
func (c *CompositeSecurityProvider) Logout(ctx context.Context, req LogoutRequest) error
Logout delegates to the authenticator
func (*CompositeSecurityProvider) RefreshToken ¶ added in v0.0.63
func (c *CompositeSecurityProvider) RefreshToken(ctx context.Context, refreshToken string) (*LoginResponse, error)
RefreshToken implements Refreshable if the authenticator supports it
func (*CompositeSecurityProvider) ValidateToken ¶ added in v0.0.63
ValidateToken implements Validatable if the authenticator supports it
type ConfigColumnSecurityProvider ¶ added in v0.0.63
type ConfigColumnSecurityProvider struct {
// contains filtered or unexported fields
}
ConfigColumnSecurityProvider provides static column security configuration
func NewConfigColumnSecurityProvider ¶ added in v0.0.63
func NewConfigColumnSecurityProvider(rules map[string][]ColumnSecurity) *ConfigColumnSecurityProvider
func (*ConfigColumnSecurityProvider) GetColumnSecurity ¶ added in v0.0.63
func (p *ConfigColumnSecurityProvider) GetColumnSecurity(ctx context.Context, userID int, schema, table string) ([]ColumnSecurity, error)
type ConfigRowSecurityProvider ¶ added in v0.0.63
type ConfigRowSecurityProvider struct {
// contains filtered or unexported fields
}
ConfigRowSecurityProvider provides static row security configuration
func NewConfigRowSecurityProvider ¶ added in v0.0.63
func NewConfigRowSecurityProvider(templates map[string]string, blocked map[string]bool) *ConfigRowSecurityProvider
func (*ConfigRowSecurityProvider) GetRowSecurity ¶ added in v0.0.63
func (p *ConfigRowSecurityProvider) GetRowSecurity(ctx context.Context, userID int, schema, table string) (RowSecurity, error)
type CustomSecurityProvider ¶ added in v0.0.63
type CustomSecurityProvider struct {
}
You can implement your own SecurityProvider by implementing all three interfaces
func (*CustomSecurityProvider) Authenticate ¶ added in v0.0.63
func (p *CustomSecurityProvider) Authenticate(r *http.Request) (*UserContext, error)
func (*CustomSecurityProvider) GetColumnSecurity ¶ added in v0.0.63
func (p *CustomSecurityProvider) GetColumnSecurity(ctx context.Context, userID int, schema, table string) ([]ColumnSecurity, error)
func (*CustomSecurityProvider) GetRowSecurity ¶ added in v0.0.63
func (p *CustomSecurityProvider) GetRowSecurity(ctx context.Context, userID int, schema, table string) (RowSecurity, error)
func (*CustomSecurityProvider) Login ¶ added in v0.0.63
func (p *CustomSecurityProvider) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
func (*CustomSecurityProvider) Logout ¶ added in v0.0.63
func (p *CustomSecurityProvider) Logout(ctx context.Context, req LogoutRequest) error
type DatabaseAuthenticator ¶ added in v0.0.63
type DatabaseAuthenticator struct {
// contains filtered or unexported fields
}
DatabaseAuthenticator provides session-based authentication with database storage All database operations go through stored procedures for security and consistency Requires stored procedures: resolvespec_login, resolvespec_logout, resolvespec_session, resolvespec_session_update, resolvespec_refresh_token See database_schema.sql for procedure definitions
func NewDatabaseAuthenticator ¶ added in v0.0.63
func NewDatabaseAuthenticator(db *sql.DB) *DatabaseAuthenticator
func (*DatabaseAuthenticator) Authenticate ¶ added in v0.0.63
func (a *DatabaseAuthenticator) Authenticate(r *http.Request) (*UserContext, error)
func (*DatabaseAuthenticator) Login ¶ added in v0.0.63
func (a *DatabaseAuthenticator) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
func (*DatabaseAuthenticator) Logout ¶ added in v0.0.63
func (a *DatabaseAuthenticator) Logout(ctx context.Context, req LogoutRequest) error
func (*DatabaseAuthenticator) RefreshToken ¶ added in v0.0.63
func (a *DatabaseAuthenticator) RefreshToken(ctx context.Context, refreshToken string) (*LoginResponse, error)
RefreshToken implements Refreshable interface
type DatabaseAuthenticatorExample ¶ added in v0.0.63
type DatabaseAuthenticatorExample struct {
// contains filtered or unexported fields
}
func NewDatabaseAuthenticatorExample ¶ added in v0.0.63
func NewDatabaseAuthenticatorExample(db *gorm.DB) *DatabaseAuthenticatorExample
func (*DatabaseAuthenticatorExample) Authenticate ¶ added in v0.0.63
func (a *DatabaseAuthenticatorExample) Authenticate(r *http.Request) (*UserContext, error)
func (*DatabaseAuthenticatorExample) Login ¶ added in v0.0.63
func (a *DatabaseAuthenticatorExample) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
func (*DatabaseAuthenticatorExample) Logout ¶ added in v0.0.63
func (a *DatabaseAuthenticatorExample) Logout(ctx context.Context, req LogoutRequest) error
func (*DatabaseAuthenticatorExample) RefreshToken ¶ added in v0.0.63
func (a *DatabaseAuthenticatorExample) RefreshToken(ctx context.Context, refreshToken string) (*LoginResponse, error)
Optional: Implement Refreshable interface
type DatabaseColumnSecurityProvider ¶ added in v0.0.63
type DatabaseColumnSecurityProvider struct {
// contains filtered or unexported fields
}
DatabaseColumnSecurityProvider loads column security from database All database operations go through stored procedures Requires stored procedure: resolvespec_column_security
func NewDatabaseColumnSecurityProvider ¶ added in v0.0.63
func NewDatabaseColumnSecurityProvider(db *sql.DB) *DatabaseColumnSecurityProvider
func (*DatabaseColumnSecurityProvider) GetColumnSecurity ¶ added in v0.0.63
func (p *DatabaseColumnSecurityProvider) GetColumnSecurity(ctx context.Context, userID int, schema, table string) ([]ColumnSecurity, error)
type DatabaseRowSecurityProvider ¶ added in v0.0.63
type DatabaseRowSecurityProvider struct {
// contains filtered or unexported fields
}
DatabaseRowSecurityProvider loads row security from database All database operations go through stored procedures Requires stored procedure: resolvespec_row_security
func NewDatabaseRowSecurityProvider ¶ added in v0.0.63
func NewDatabaseRowSecurityProvider(db *sql.DB) *DatabaseRowSecurityProvider
func (*DatabaseRowSecurityProvider) GetRowSecurity ¶ added in v0.0.63
func (p *DatabaseRowSecurityProvider) GetRowSecurity(ctx context.Context, userID int, schema, table string) (RowSecurity, error)
type HeaderAuthenticator ¶ added in v0.0.63
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 ¶ added in v0.0.63
func NewHeaderAuthenticator() *HeaderAuthenticator
func (*HeaderAuthenticator) Authenticate ¶ added in v0.0.63
func (a *HeaderAuthenticator) Authenticate(r *http.Request) (*UserContext, error)
func (*HeaderAuthenticator) Login ¶ added in v0.0.63
func (a *HeaderAuthenticator) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
func (*HeaderAuthenticator) Logout ¶ added in v0.0.63
func (a *HeaderAuthenticator) Logout(ctx context.Context, req LogoutRequest) error
type HeaderAuthenticatorExample ¶ added in v0.0.63
type HeaderAuthenticatorExample struct {
}
func NewHeaderAuthenticatorExample ¶ added in v0.0.63
func NewHeaderAuthenticatorExample() *HeaderAuthenticatorExample
func (*HeaderAuthenticatorExample) Authenticate ¶ added in v0.0.63
func (a *HeaderAuthenticatorExample) Authenticate(r *http.Request) (*UserContext, error)
func (*HeaderAuthenticatorExample) Login ¶ added in v0.0.63
func (a *HeaderAuthenticatorExample) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
func (*HeaderAuthenticatorExample) Logout ¶ added in v0.0.63
func (a *HeaderAuthenticatorExample) Logout(ctx context.Context, req LogoutRequest) error
type JWTAuthenticator ¶ added in v0.0.63
type JWTAuthenticator struct {
// contains filtered or unexported fields
}
JWTAuthenticator provides JWT token-based authentication All database operations go through stored procedures Requires stored procedures: resolvespec_jwt_login, resolvespec_jwt_logout NOTE: JWT signing/verification requires github.com/golang-jwt/jwt/v5 to be installed and imported
func NewJWTAuthenticator ¶ added in v0.0.63
func NewJWTAuthenticator(secretKey string, db *sql.DB) *JWTAuthenticator
func (*JWTAuthenticator) Authenticate ¶ added in v0.0.63
func (a *JWTAuthenticator) Authenticate(r *http.Request) (*UserContext, error)
func (*JWTAuthenticator) Login ¶ added in v0.0.63
func (a *JWTAuthenticator) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
func (*JWTAuthenticator) Logout ¶ added in v0.0.63
func (a *JWTAuthenticator) Logout(ctx context.Context, req LogoutRequest) error
type JWTAuthenticatorExample ¶ added in v0.0.63
type JWTAuthenticatorExample struct {
// contains filtered or unexported fields
}
func NewJWTAuthenticatorExample ¶ added in v0.0.63
func NewJWTAuthenticatorExample(secretKey string, db *gorm.DB) *JWTAuthenticatorExample
func (*JWTAuthenticatorExample) Authenticate ¶ added in v0.0.63
func (a *JWTAuthenticatorExample) Authenticate(r *http.Request) (*UserContext, error)
func (*JWTAuthenticatorExample) Login ¶ added in v0.0.63
func (a *JWTAuthenticatorExample) Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
func (*JWTAuthenticatorExample) Logout ¶ added in v0.0.63
func (a *JWTAuthenticatorExample) Logout(ctx context.Context, req LogoutRequest) error
type LoginRequest ¶ added in v0.0.63
type LoginRequest struct {
Username string
Password string
Claims map[string]any // Additional login data
}
LoginRequest contains credentials for login
type LoginResponse ¶ added in v0.0.63
type LoginResponse struct {
Token string
RefreshToken string
User *UserContext
ExpiresIn int64 // Token expiration in seconds
}
LoginResponse contains the result of a login attempt
type LogoutRequest ¶ added in v0.0.63
LogoutRequest contains information for logout
type Refreshable ¶ added in v0.0.63
type Refreshable interface {
// RefreshToken exchanges a refresh token for a new access token
RefreshToken(ctx context.Context, refreshToken string) (*LoginResponse, error)
}
Refreshable allows providers to support token refresh
type RowSecurity ¶
func (*RowSecurity) GetTemplate ¶
func (m *RowSecurity) GetTemplate(pPrimaryKeyName string, pModelType reflect.Type) string
type RowSecurityProvider ¶ added in v0.0.63
type RowSecurityProvider interface {
// GetRowSecurity loads row security rules for a user and entity
GetRowSecurity(ctx context.Context, userID int, schema, table string) (RowSecurity, error)
}
RowSecurityProvider handles row-level security (filtering)
type SecurityList ¶
type SecurityList struct {
ColumnSecurityMutex sync.RWMutex
ColumnSecurity map[string][]ColumnSecurity
RowSecurityMutex sync.RWMutex
RowSecurity map[string]RowSecurity
// contains filtered or unexported fields
}
SecurityList manages security state and caching It wraps a SecurityProvider and provides caching and utility methods
func NewSecurityList ¶ added in v0.0.63
func NewSecurityList(provider SecurityProvider) *SecurityList
NewSecurityList creates a new security list with the given provider
func SetupSecurityProvider ¶
func SetupSecurityProvider(handler *restheadspec.Handler, provider SecurityProvider) *SecurityList
SetupSecurityProvider initializes and configures the security provider This function creates a SecurityList with the given provider and registers hooks
Example usage:
// Create your security provider (use composite or single provider)
auth := security.NewJWTAuthenticator("your-secret-key", db)
colSec := security.NewDatabaseColumnSecurityProvider(db)
rowSec := security.NewDatabaseRowSecurityProvider(db)
provider := security.NewCompositeSecurityProvider(auth, colSec, rowSec)
// Setup security with the provider
handler := restheadspec.NewHandlerWithGORM(db)
securityList := security.SetupSecurityProvider(handler, provider)
// Apply middleware
router.Use(security.NewAuthMiddleware(securityList))
router.Use(security.SetSecurityMiddleware(securityList))
func (*SecurityList) ApplyColumnSecurity ¶
func (*SecurityList) ClearSecurity ¶
func (m *SecurityList) ClearSecurity(pUserID int, pSchema, pTablename string) error
func (*SecurityList) ColumSecurityApplyOnRecord ¶
func (*SecurityList) GetRowSecurityTemplate ¶
func (m *SecurityList) GetRowSecurityTemplate(pUserID int, pSchema, pTablename string) (RowSecurity, error)
func (*SecurityList) LoadColumnSecurity ¶
func (*SecurityList) LoadRowSecurity ¶
func (m *SecurityList) LoadRowSecurity(ctx context.Context, pUserID int, pSchema, pTablename string, pOverwrite bool) (RowSecurity, error)
func (*SecurityList) Provider ¶ added in v0.0.63
func (m *SecurityList) Provider() SecurityProvider
Provider returns the underlying security provider
type SecurityProvider ¶ added in v0.0.63
type SecurityProvider interface {
Authenticator
ColumnSecurityProvider
RowSecurityProvider
}
SecurityProvider is the main interface combining all security concerns
type UserContext ¶ added in v0.0.63
type UserContext struct {
UserID int
UserName string
UserLevel int
SessionID string
RemoteID string
Roles []string
Email string
Claims map[string]any
}
UserContext holds authenticated user information
func GetUserContext ¶ added in v0.0.63
func GetUserContext(ctx context.Context) (*UserContext, bool)
GetUserContext extracts the full user context from request context