Documentation
¶
Index ¶
- Constants
- Variables
- func NewView(caller router.Caller) view.Presenter
- type AuthMode
- type Authenticator
- type Config
- type Identity
- func (m *Identity) DecodeFields(r model.FieldReader)
- func (m *Identity) EncodeFields(w model.FieldWriter)
- func (m *Identity) IsNil() bool
- func (m *Identity) ModelName() string
- func (m *Identity) Pointers() []any
- func (m *Identity) Schema() []model.Field
- func (m *Identity) SchemaExt() []model.FieldExt
- func (m *Identity) Validate(action byte) error
- type IdentityList
- func (s *IdentityList) Append() model.Fielder
- func (s *IdentityList) At(i int) model.Fielder
- func (s *IdentityList) DecodeFields(_ model.FieldReader)
- func (s *IdentityList) EncodeFields(_ model.FieldWriter)
- func (s *IdentityList) IsNil() bool
- func (s *IdentityList) Len() int
- func (s *IdentityList) Pointers() []any
- func (s *IdentityList) Schema() []model.Field
- type LANIP
- func (m *LANIP) DecodeFields(r model.FieldReader)
- func (m *LANIP) EncodeFields(w model.FieldWriter)
- func (m *LANIP) IsNil() bool
- func (m *LANIP) ModelName() string
- func (m *LANIP) Pointers() []any
- func (m *LANIP) Schema() []model.Field
- func (m *LANIP) SchemaExt() []model.FieldExt
- func (m *LANIP) Validate(action byte) error
- type LANIPList
- func (s *LANIPList) Append() model.Fielder
- func (s *LANIPList) At(i int) model.Fielder
- func (s *LANIPList) DecodeFields(_ model.FieldReader)
- func (s *LANIPList) EncodeFields(_ model.FieldWriter)
- func (s *LANIPList) IsNil() bool
- func (s *LANIPList) Len() int
- func (s *LANIPList) Pointers() []any
- func (s *LANIPList) Schema() []model.Field
- type LoginData
- func (m *LoginData) DecodeFields(r model.FieldReader)
- func (m *LoginData) EncodeFields(w model.FieldWriter)
- func (m *LoginData) IsNil() bool
- func (m *LoginData) ModelName() string
- func (m *LoginData) Pointers() []any
- func (m *LoginData) Schema() []model.Field
- func (m *LoginData) Validate(action byte) error
- type LoginDataList
- func (s *LoginDataList) Append() model.Fielder
- func (s *LoginDataList) At(i int) model.Fielder
- func (s *LoginDataList) DecodeFields(_ model.FieldReader)
- func (s *LoginDataList) EncodeFields(_ model.FieldWriter)
- func (s *LoginDataList) IsNil() bool
- func (s *LoginDataList) Len() int
- func (s *LoginDataList) Pointers() []any
- func (s *LoginDataList) Schema() []model.Field
- type ModuleContext
- type OAuthConfig
- type OAuthProvider
- type OAuthState
- func (m *OAuthState) DecodeFields(r model.FieldReader)
- func (m *OAuthState) EncodeFields(w model.FieldWriter)
- func (m *OAuthState) IsNil() bool
- func (m *OAuthState) ModelName() string
- func (m *OAuthState) Pointers() []any
- func (m *OAuthState) Schema() []model.Field
- func (m *OAuthState) Validate(action byte) error
- type OAuthStateList
- func (s *OAuthStateList) Append() model.Fielder
- func (s *OAuthStateList) At(i int) model.Fielder
- func (s *OAuthStateList) DecodeFields(_ model.FieldReader)
- func (s *OAuthStateList) EncodeFields(_ model.FieldWriter)
- func (s *OAuthStateList) IsNil() bool
- func (s *OAuthStateList) Len() int
- func (s *OAuthStateList) Pointers() []any
- func (s *OAuthStateList) Schema() []model.Field
- type OAuthToken
- type OAuthUserInfo
- type PasswordData
- func (m *PasswordData) DecodeFields(r model.FieldReader)
- func (m *PasswordData) EncodeFields(w model.FieldWriter)
- func (m *PasswordData) IsNil() bool
- func (m *PasswordData) ModelName() string
- func (m *PasswordData) Pointers() []any
- func (m *PasswordData) Schema() []model.Field
- func (m *PasswordData) Validate(action byte) error
- type PasswordDataList
- func (s *PasswordDataList) Append() model.Fielder
- func (s *PasswordDataList) At(i int) model.Fielder
- func (s *PasswordDataList) DecodeFields(_ model.FieldReader)
- func (s *PasswordDataList) EncodeFields(_ model.FieldWriter)
- func (s *PasswordDataList) IsNil() bool
- func (s *PasswordDataList) Len() int
- func (s *PasswordDataList) Pointers() []any
- func (s *PasswordDataList) Schema() []model.Field
- type Permission
- func (m *Permission) DecodeFields(r model.FieldReader)
- func (m *Permission) EncodeFields(w model.FieldWriter)
- func (m *Permission) IsNil() bool
- func (m *Permission) ModelName() string
- func (m *Permission) Pointers() []any
- func (m *Permission) Schema() []model.Field
- func (m *Permission) Validate(action byte) error
- type PermissionList
- func (s *PermissionList) Append() model.Fielder
- func (s *PermissionList) At(i int) model.Fielder
- func (s *PermissionList) DecodeFields(_ model.FieldReader)
- func (s *PermissionList) EncodeFields(_ model.FieldWriter)
- func (s *PermissionList) IsNil() bool
- func (s *PermissionList) Len() int
- func (s *PermissionList) Pointers() []any
- func (s *PermissionList) Schema() []model.Field
- type ProfileDTO
- type ProfileData
- func (m *ProfileData) DecodeFields(r model.FieldReader)
- func (m *ProfileData) EncodeFields(w model.FieldWriter)
- func (m *ProfileData) IsNil() bool
- func (m *ProfileData) ModelName() string
- func (m *ProfileData) Pointers() []any
- func (m *ProfileData) Schema() []model.Field
- func (m *ProfileData) Validate(action byte) error
- type ProfileDataList
- func (s *ProfileDataList) Append() model.Fielder
- func (s *ProfileDataList) At(i int) model.Fielder
- func (s *ProfileDataList) DecodeFields(_ model.FieldReader)
- func (s *ProfileDataList) EncodeFields(_ model.FieldWriter)
- func (s *ProfileDataList) IsNil() bool
- func (s *ProfileDataList) Len() int
- func (s *ProfileDataList) Pointers() []any
- func (s *ProfileDataList) Schema() []model.Field
- type RegisterData
- func (m *RegisterData) DecodeFields(r model.FieldReader)
- func (m *RegisterData) EncodeFields(w model.FieldWriter)
- func (m *RegisterData) IsNil() bool
- func (m *RegisterData) ModelName() string
- func (m *RegisterData) Pointers() []any
- func (m *RegisterData) Schema() []model.Field
- func (m *RegisterData) Validate(action byte) error
- type RegisterDataList
- func (s *RegisterDataList) Append() model.Fielder
- func (s *RegisterDataList) At(i int) model.Fielder
- func (s *RegisterDataList) DecodeFields(_ model.FieldReader)
- func (s *RegisterDataList) EncodeFields(_ model.FieldWriter)
- func (s *RegisterDataList) IsNil() bool
- func (s *RegisterDataList) Len() int
- func (s *RegisterDataList) Pointers() []any
- func (s *RegisterDataList) Schema() []model.Field
- type Role
- type RoleList
- func (s *RoleList) Append() model.Fielder
- func (s *RoleList) At(i int) model.Fielder
- func (s *RoleList) DecodeFields(_ model.FieldReader)
- func (s *RoleList) EncodeFields(_ model.FieldWriter)
- func (s *RoleList) IsNil() bool
- func (s *RoleList) Len() int
- func (s *RoleList) Pointers() []any
- func (s *RoleList) Schema() []model.Field
- type RolePermission
- func (m *RolePermission) DecodeFields(r model.FieldReader)
- func (m *RolePermission) EncodeFields(w model.FieldWriter)
- func (m *RolePermission) IsNil() bool
- func (m *RolePermission) ModelName() string
- func (m *RolePermission) Pointers() []any
- func (m *RolePermission) Schema() []model.Field
- func (m *RolePermission) SchemaExt() []model.FieldExt
- func (m *RolePermission) Validate(action byte) error
- type RolePermissionList
- func (s *RolePermissionList) Append() model.Fielder
- func (s *RolePermissionList) At(i int) model.Fielder
- func (s *RolePermissionList) DecodeFields(_ model.FieldReader)
- func (s *RolePermissionList) EncodeFields(_ model.FieldWriter)
- func (s *RolePermissionList) IsNil() bool
- func (s *RolePermissionList) Len() int
- func (s *RolePermissionList) Pointers() []any
- func (s *RolePermissionList) Schema() []model.Field
- type SecurityEvent
- type SecurityEventType
- type Session
- func (m *Session) DecodeFields(r model.FieldReader)
- func (m *Session) EncodeFields(w model.FieldWriter)
- func (m *Session) IsNil() bool
- func (m *Session) ModelName() string
- func (m *Session) Pointers() []any
- func (m *Session) Schema() []model.Field
- func (m *Session) SchemaExt() []model.FieldExt
- func (m *Session) Validate(action byte) error
- type SessionList
- func (s *SessionList) Append() model.Fielder
- func (s *SessionList) At(i int) model.Fielder
- func (s *SessionList) DecodeFields(_ model.FieldReader)
- func (s *SessionList) EncodeFields(_ model.FieldWriter)
- func (s *SessionList) IsNil() bool
- func (s *SessionList) Len() int
- func (s *SessionList) Pointers() []any
- func (s *SessionList) Schema() []model.Field
- type User
- func (m *User) DecodeFields(r model.FieldReader)
- func (m *User) EncodeFields(w model.FieldWriter)
- func (m *User) IsNil() bool
- func (m *User) Item() view.Item
- func (m *User) ModelName() string
- func (m *User) Pointers() []any
- func (m *User) Schema() []model.Field
- func (m *User) Validate(action byte) error
- type UserList
- func (s *UserList) Append() model.Fielder
- func (s *UserList) At(i int) model.Fielder
- func (s *UserList) DecodeFields(_ model.FieldReader)
- func (s *UserList) EncodeFields(_ model.FieldWriter)
- func (s *UserList) IsNil() bool
- func (s *UserList) Len() int
- func (s *UserList) Pointers() []any
- func (s *UserList) Schema() []model.Field
- type UserRole
- func (m *UserRole) DecodeFields(r model.FieldReader)
- func (m *UserRole) EncodeFields(w model.FieldWriter)
- func (m *UserRole) IsNil() bool
- func (m *UserRole) ModelName() string
- func (m *UserRole) Pointers() []any
- func (m *UserRole) Schema() []model.Field
- func (m *UserRole) SchemaExt() []model.FieldExt
- func (m *UserRole) Validate(action byte) error
- type UserRoleList
- func (s *UserRoleList) Append() model.Fielder
- func (s *UserRoleList) At(i int) model.Fielder
- func (s *UserRoleList) DecodeFields(_ model.FieldReader)
- func (s *UserRoleList) EncodeFields(_ model.FieldWriter)
- func (s *UserRoleList) IsNil() bool
- func (s *UserRoleList) Len() int
- func (s *UserRoleList) Pointers() []any
- func (s *UserRoleList) Schema() []model.Field
Constants ¶
View Source
const ( PathLogin = "/login" PathLogout = "/logout" PathAfterLogin = "/" )
View Source
const ( OpMe = "me" // authenticated caller's profile OpListUsers = "list_users" // admin: list users OpUpsertUser = "upsert_user" // admin: create (Id=="") or update OpDeleteUser = "delete_user" // admin: delete by record )
Op names — shared vocabulary between the wasm view and the server module.
View Source
const TopicSecurity = "user.security"
TopicSecurity is the events topic every SecurityEvent is published on.
Variables ¶
View Source
var ( ErrInvalidCredentials = fmt.Err("access", "denied") // EN: Access Denied / ES: Acceso Denegado ErrSuspended = fmt.Err("user", "suspended") // EN: User Suspended / ES: Usuario Suspendido ErrEmailTaken = fmt.Err("email", "registered") // EN: Email Registered / ES: Correo electrónico Registrado ErrWeakPassword = fmt.Err("password", "weak") // EN: Password Weak / ES: Contraseña Débil ErrSessionExpired = fmt.Err("token", "expired") // EN: Token Expired / ES: Token Expirado ErrNotFound = fmt.Err("user", "not", "found") // EN: User Not Found / ES: Usuario No Encontrado ErrProviderNotFound = fmt.Err("provider", "not", "found") // EN: Provider Not Found / ES: Proveedor No Encontrado ErrInvalidOAuthState = fmt.Err("state", "invalid") // EN: State Invalid / ES: Estado Inválido ErrCannotUnlink = fmt.Err("identity", "cannot", "unlink") // EN: Identity Cannot Unlink / ES: Identidad No puede Desvincular ErrInvalidRUT = fmt.Err("rut", "invalid") // EN: Rut Invalid / ES: Rut Inválido ErrRUTTaken = fmt.Err("rut", "registered") // EN: Rut Registered / ES: Rut Registrado ErrIPTaken = fmt.Err("ip", "registered") // EN: Ip Registered / ES: Ip Registrado )
View Source
var IdentityModel = model.Definition{ Name: "identity", Fields: model.Fields{ {Name: "id", Type: model.Text(), DB: &model.FieldDB{PK: true}}, {Name: "user_id", Type: model.Text(), DB: &model.FieldDB{RefColumn: "id"}, Ref: &UserModel}, {Name: "provider", Type: model.Text()}, {Name: "provider_id", Type: model.Text()}, {Name: "email", Type: model.Text()}, {Name: "created_at", Type: model.Int()}, }, }
View Source
var Identity_ = struct { Id string UserId string Provider string ProviderId string Email string CreatedAt string }{ Id: "id", UserId: "user_id", Provider: "provider", ProviderId: "provider_id", Email: "email", CreatedAt: "created_at", }
View Source
var LANIPModel = model.Definition{ Name: "lanip", Fields: model.Fields{ {Name: "id", Type: model.Text(), DB: &model.FieldDB{PK: true}}, {Name: "user_id", Type: model.Text(), DB: &model.FieldDB{RefColumn: "id"}, Ref: &UserModel}, {Name: "ip", Type: model.Text()}, {Name: "label", Type: model.Text()}, {Name: "created_at", Type: model.Int()}, }, }
View Source
var LANIP_ = struct { Id string UserId string Ip string Label string CreatedAt string }{ Id: "id", UserId: "user_id", Ip: "ip", Label: "label", CreatedAt: "created_at", }
View Source
var LoginDataModel = model.Definition{ Name: "login_data", Fields: model.Fields{ {Name: "email", Type: input.Email(), NotNull: true}, {Name: "password", Type: input.Password(), NotNull: true}, }, }
View Source
var OAuthStateModel = model.Definition{ Name: "oauth_state", Fields: model.Fields{ {Name: "state", Type: model.Text(), DB: &model.FieldDB{PK: true}}, {Name: "provider", Type: model.Text()}, {Name: "expires_at", Type: model.Int()}, {Name: "created_at", Type: model.Int()}, }, }
View Source
var OAuthState_ = struct { State string Provider string ExpiresAt string CreatedAt string }{ State: "state", Provider: "provider", ExpiresAt: "expires_at", CreatedAt: "created_at", }
View Source
var PasswordDataModel = model.Definition{ Name: "password_data", Fields: model.Fields{ {Name: "current", Type: input.Password(), NotNull: true}, {Name: "new", Type: input.Password(), NotNull: true}, {Name: "confirm", Type: input.Password(), NotNull: true}, }, }
View Source
var PermissionModel = model.Definition{ Name: "permission", Fields: model.Fields{ {Name: "id", Type: model.Text(), DB: &model.FieldDB{PK: true}}, {Name: "name", Type: model.Text()}, {Name: "resource", Type: model.Text()}, {Name: "action", Type: model.Text()}, }, }
View Source
var Permission_ = struct { Id string Name string Resource string Action string }{ Id: "id", Name: "name", Resource: "resource", Action: "action", }
View Source
var ProfileDataModel = model.Definition{ Name: "profile_data", Fields: model.Fields{ {Name: "name", Type: input.Text(), NotNull: true}, {Name: "phone", Type: input.Phone()}, }, }
View Source
var RegisterDataModel = model.Definition{ Name: "register_data", Fields: model.Fields{ {Name: "name", Type: input.Text(), NotNull: true}, {Name: "email", Type: input.Email(), NotNull: true}, {Name: "password", Type: input.Password(), NotNull: true}, {Name: "phone", Type: input.Phone()}, }, }
View Source
var RoleModel = model.Definition{ Name: "role", Fields: model.Fields{ {Name: "id", Type: model.Text(), DB: &model.FieldDB{PK: true}}, {Name: "code", Type: model.Text()}, {Name: "name", Type: model.Text()}, {Name: "description", Type: model.Text()}, }, }
View Source
var RolePermissionModel = model.Definition{ Name: "role_permission", Fields: model.Fields{ {Name: "role_id", Type: model.Text(), DB: &model.FieldDB{PK: true, RefColumn: "id"}, Ref: &RoleModel}, {Name: "permission_id", Type: model.Text(), DB: &model.FieldDB{PK: true, RefColumn: "id"}, Ref: &PermissionModel}, }, }
View Source
var RolePermission_ = struct { RoleId string PermissionId string }{ RoleId: "role_id", PermissionId: "permission_id", }
View Source
var Role_ = struct { Id string Code string Name string Description string }{ Id: "id", Code: "code", Name: "name", Description: "description", }
View Source
var SessionModel = model.Definition{ Name: "session", Fields: model.Fields{ {Name: "id", Type: model.Text(), DB: &model.FieldDB{PK: true}}, {Name: "user_id", Type: model.Text(), DB: &model.FieldDB{RefColumn: "id"}, Ref: &UserModel}, {Name: "expires_at", Type: model.Int()}, {Name: "ip", Type: model.Text()}, {Name: "user_agent", Type: model.Text()}, {Name: "created_at", Type: model.Int()}, }, }
View Source
var Session_ = struct { Id string UserId string ExpiresAt string Ip string UserAgent string CreatedAt string }{ Id: "id", UserId: "user_id", ExpiresAt: "expires_at", Ip: "ip", UserAgent: "user_agent", CreatedAt: "created_at", }
View Source
var UserModel = model.Definition{ Name: "user", Fields: model.Fields{ {Name: "id", Type: model.Text(), DB: &model.FieldDB{PK: true}}, {Name: "email", Type: input.Email(), DB: &model.FieldDB{Unique: true}}, {Name: "name", Type: input.Text()}, {Name: "phone", Type: input.Phone()}, {Name: "status", Type: model.Text()}, {Name: "created_at", Type: model.Int()}, {Name: "roles", Type: model.StructSlice(&RoleModel), Exclude: true}, {Name: "permissions", Type: model.StructSlice(&PermissionModel), Exclude: true}, }, }
View Source
var UserRoleModel = model.Definition{ Name: "user_role", Fields: model.Fields{ {Name: "user_id", Type: model.Text(), DB: &model.FieldDB{PK: true, RefColumn: "id"}, Ref: &UserModel}, {Name: "role_id", Type: model.Text(), DB: &model.FieldDB{PK: true, RefColumn: "id"}, Ref: &RoleModel}, }, }
View Source
var UserRole_ = struct { UserId string RoleId string }{ UserId: "user_id", RoleId: "role_id", }
Functions ¶
Types ¶
type AuthMode ¶ added in v0.0.17
type AuthMode uint8
AuthMode selects the session strategy.
const ( // AuthModeCookie stores a session ID in an HttpOnly cookie. // Stateful: requires user_sessions table. Supports immediate revocation. AuthModeCookie AuthMode = iota // default // AuthModeJWT stores a signed JWT in an HttpOnly cookie. // Stateless: no DB lookup per request. No immediate revocation. // Ideal for SPA/PWA and multi-server deployments. AuthModeJWT // AuthModeBearer reads a signed JWT from the "Authorization: Bearer <token>" header. // Stateless: for API clients (MCP servers, IDEs, LLMs) that cannot use cookies. // Requires JWTSecret. AuthModeBearer )
type Authenticator ¶ added in v0.1.0
type Config ¶ added in v0.0.2
type Config struct {
AuthMode AuthMode // default: AuthModeCookie
// Shared by all modes
CookieName string // default: "session"
TokenTTL int // default: 86400 (seconds). Session TTL in cookie mode, JWT expiry in JWT mode.
// Required when AuthMode == AuthModeJWT or AuthMode == AuthModeBearer.
// Also required to call GenerateAPIToken regardless of AuthMode.
JWTSecret []byte
TrustProxy bool
// Injected authenticators. The consumer can select 1 or N supported authentication modes.
Authenticators []Authenticator
// IDs mints primary keys for every record this module creates (users, sessions,
// oauth states, identities, LAN ips). REQUIRED: authority.New fails if nil —
// an auth module must never silently pick its own generator.
IDs model.IDGenerator
// Events receives security events (user.TopicSecurity). Optional: nil = events
// are dropped (fire-and-forget contract), never an error.
Events events.Publisher
// OnPasswordValidate is called by SetPassword before hashing.
// Return a non-nil error to reject the password.
// If nil, only the built-in len >= 8 check applies.
OnPasswordValidate func(password string) error
// AfterLoginPath is the path to redirect to after successful login.
// Default: PathAfterLogin ("/")
AfterLoginPath string
// RateLimit is called by endpoints before processing a request.
// Return a non-nil error to reject the request (429 Too Many Requests).
// remoteAddr is the client's IP address.
RateLimit func(remoteAddr string) error
}
type Identity ¶ added in v0.0.2
type Identity struct {
Id string
UserId string
Provider string
ProviderId string
Email string
CreatedAt int64
}
func ReadOneIdentity ¶ added in v0.0.6
func (*Identity) DecodeFields ¶ added in v0.0.29
func (m *Identity) DecodeFields(r model.FieldReader)
func (*Identity) EncodeFields ¶ added in v0.0.29
func (m *Identity) EncodeFields(w model.FieldWriter)
type IdentityList ¶ added in v0.0.29
type IdentityList []*Identity
func ReadAllIdentity ¶ added in v0.0.6
func ReadAllIdentity(qb *orm.QB) (IdentityList, error)
func (*IdentityList) Append ¶ added in v0.0.29
func (s *IdentityList) Append() model.Fielder
func (*IdentityList) DecodeFields ¶ added in v0.0.29
func (s *IdentityList) DecodeFields(_ model.FieldReader)
func (*IdentityList) EncodeFields ¶ added in v0.0.29
func (s *IdentityList) EncodeFields(_ model.FieldWriter)
func (*IdentityList) IsNil ¶ added in v0.0.29
func (s *IdentityList) IsNil() bool
func (*IdentityList) Len ¶ added in v0.0.29
func (s *IdentityList) Len() int
func (*IdentityList) Pointers ¶ added in v0.0.29
func (s *IdentityList) Pointers() []any
func (*IdentityList) Schema ¶ added in v0.0.29
func (s *IdentityList) Schema() []model.Field
type LANIP ¶ added in v0.0.2
func (*LANIP) DecodeFields ¶ added in v0.0.29
func (m *LANIP) DecodeFields(r model.FieldReader)
func (*LANIP) EncodeFields ¶ added in v0.0.29
func (m *LANIP) EncodeFields(w model.FieldWriter)
type LANIPList ¶ added in v0.0.29
type LANIPList []*LANIP
func (*LANIPList) DecodeFields ¶ added in v0.0.29
func (s *LANIPList) DecodeFields(_ model.FieldReader)
func (*LANIPList) EncodeFields ¶ added in v0.0.29
func (s *LANIPList) EncodeFields(_ model.FieldWriter)
type LoginData ¶ added in v0.0.2
func (*LoginData) DecodeFields ¶ added in v0.0.29
func (m *LoginData) DecodeFields(r model.FieldReader)
func (*LoginData) EncodeFields ¶ added in v0.0.29
func (m *LoginData) EncodeFields(w model.FieldWriter)
type LoginDataList ¶ added in v0.0.29
type LoginDataList []*LoginData
func (*LoginDataList) Append ¶ added in v0.0.29
func (s *LoginDataList) Append() model.Fielder
func (*LoginDataList) DecodeFields ¶ added in v0.0.29
func (s *LoginDataList) DecodeFields(_ model.FieldReader)
func (*LoginDataList) EncodeFields ¶ added in v0.0.29
func (s *LoginDataList) EncodeFields(_ model.FieldWriter)
func (*LoginDataList) IsNil ¶ added in v0.0.29
func (s *LoginDataList) IsNil() bool
func (*LoginDataList) Len ¶ added in v0.0.29
func (s *LoginDataList) Len() int
func (*LoginDataList) Pointers ¶ added in v0.0.29
func (s *LoginDataList) Pointers() []any
func (*LoginDataList) Schema ¶ added in v0.0.29
func (s *LoginDataList) Schema() []model.Field
type ModuleContext ¶ added in v0.1.0
type ModuleContext interface {
Config() Config
DB() *orm.DB
IDs() model.IDGenerator
Notify(e SecurityEvent)
IssueToken(userID string, ttl int) (string, error)
CreateSession(userID, ip, userAgent string) (Session, error)
DeleteSession(id string) error
GetSession(id string) (Session, error)
Login(email, password string) (User, error)
ExtractClientIP(ctx router.Context) string
RegisterProvider(p OAuthProvider)
BeginOAuth(providerName string) (string, error)
CompleteOAuth(providerName string, ctx router.Context, ip, ua string) (User, bool, error)
}
type OAuthConfig ¶ added in v0.0.34
type OAuthConfig struct {
ClientID string
ClientSecret string
RedirectURL string
Scopes []string
AuthURL string // provider's authorization endpoint
TokenURL string // provider's token endpoint
}
OAuthConfig is the provider's registration: what the app declares in the provider console.
type OAuthProvider ¶ added in v0.0.2
type OAuthProvider interface {
Name() string
AuthCodeURL(state string) string
ExchangeCode(code string) (OAuthToken, error)
GetUserInfo(token OAuthToken) (OAuthUserInfo, error)
}
type OAuthState ¶ added in v0.0.6
func ReadOneOAuthState ¶ added in v0.0.6
func ReadOneOAuthState(qb *orm.QB, model *OAuthState) (*OAuthState, error)
func (*OAuthState) DecodeFields ¶ added in v0.0.29
func (m *OAuthState) DecodeFields(r model.FieldReader)
func (*OAuthState) EncodeFields ¶ added in v0.0.29
func (m *OAuthState) EncodeFields(w model.FieldWriter)
func (*OAuthState) IsNil ¶ added in v0.0.29
func (m *OAuthState) IsNil() bool
func (*OAuthState) ModelName ¶ added in v0.0.29
func (m *OAuthState) ModelName() string
func (*OAuthState) Pointers ¶ added in v0.0.6
func (m *OAuthState) Pointers() []any
func (*OAuthState) Schema ¶ added in v0.0.6
func (m *OAuthState) Schema() []model.Field
func (*OAuthState) Validate ¶ added in v0.0.32
func (m *OAuthState) Validate(action byte) error
type OAuthStateList ¶ added in v0.0.29
type OAuthStateList []*OAuthState
func ReadAllOAuthState ¶ added in v0.0.6
func ReadAllOAuthState(qb *orm.QB) (OAuthStateList, error)
func (*OAuthStateList) Append ¶ added in v0.0.29
func (s *OAuthStateList) Append() model.Fielder
func (*OAuthStateList) DecodeFields ¶ added in v0.0.29
func (s *OAuthStateList) DecodeFields(_ model.FieldReader)
func (*OAuthStateList) EncodeFields ¶ added in v0.0.29
func (s *OAuthStateList) EncodeFields(_ model.FieldWriter)
func (*OAuthStateList) IsNil ¶ added in v0.0.29
func (s *OAuthStateList) IsNil() bool
func (*OAuthStateList) Len ¶ added in v0.0.29
func (s *OAuthStateList) Len() int
func (*OAuthStateList) Pointers ¶ added in v0.0.29
func (s *OAuthStateList) Pointers() []any
func (*OAuthStateList) Schema ¶ added in v0.0.29
func (s *OAuthStateList) Schema() []model.Field
type OAuthToken ¶ added in v0.0.34
OAuthToken is what a provider returns when it exchanges the code. It replaces oauth2.Token: that type dragged net/http in, and net/http does not exist under TinyGo — which put this whole module out of the edge for one function call.
func (*OAuthToken) DecodeFields ¶ added in v0.0.34
func (t *OAuthToken) DecodeFields(r model.FieldReader)
func (OAuthToken) IsNil ¶ added in v0.0.34
func (t OAuthToken) IsNil() bool
type OAuthUserInfo ¶ added in v0.0.2
type PasswordData ¶ added in v0.0.2
func (*PasswordData) DecodeFields ¶ added in v0.0.29
func (m *PasswordData) DecodeFields(r model.FieldReader)
func (*PasswordData) EncodeFields ¶ added in v0.0.29
func (m *PasswordData) EncodeFields(w model.FieldWriter)
func (*PasswordData) IsNil ¶ added in v0.0.29
func (m *PasswordData) IsNil() bool
func (*PasswordData) ModelName ¶ added in v0.0.29
func (m *PasswordData) ModelName() string
func (*PasswordData) Pointers ¶ added in v0.0.28
func (m *PasswordData) Pointers() []any
func (*PasswordData) Schema ¶ added in v0.0.28
func (m *PasswordData) Schema() []model.Field
func (*PasswordData) Validate ¶ added in v0.0.32
func (m *PasswordData) Validate(action byte) error
type PasswordDataList ¶ added in v0.0.29
type PasswordDataList []*PasswordData
func (*PasswordDataList) Append ¶ added in v0.0.29
func (s *PasswordDataList) Append() model.Fielder
func (*PasswordDataList) DecodeFields ¶ added in v0.0.29
func (s *PasswordDataList) DecodeFields(_ model.FieldReader)
func (*PasswordDataList) EncodeFields ¶ added in v0.0.29
func (s *PasswordDataList) EncodeFields(_ model.FieldWriter)
func (*PasswordDataList) IsNil ¶ added in v0.0.29
func (s *PasswordDataList) IsNil() bool
func (*PasswordDataList) Len ¶ added in v0.0.29
func (s *PasswordDataList) Len() int
func (*PasswordDataList) Pointers ¶ added in v0.0.29
func (s *PasswordDataList) Pointers() []any
func (*PasswordDataList) Schema ¶ added in v0.0.29
func (s *PasswordDataList) Schema() []model.Field
type Permission ¶ added in v0.0.6
func ReadOnePermission ¶ added in v0.0.6
func ReadOnePermission(qb *orm.QB, model *Permission) (*Permission, error)
func (*Permission) DecodeFields ¶ added in v0.0.29
func (m *Permission) DecodeFields(r model.FieldReader)
func (*Permission) EncodeFields ¶ added in v0.0.29
func (m *Permission) EncodeFields(w model.FieldWriter)
func (*Permission) IsNil ¶ added in v0.0.29
func (m *Permission) IsNil() bool
func (*Permission) ModelName ¶ added in v0.0.29
func (m *Permission) ModelName() string
func (*Permission) Pointers ¶ added in v0.0.6
func (m *Permission) Pointers() []any
func (*Permission) Schema ¶ added in v0.0.6
func (m *Permission) Schema() []model.Field
func (*Permission) Validate ¶ added in v0.0.32
func (m *Permission) Validate(action byte) error
type PermissionList ¶ added in v0.0.29
type PermissionList []*Permission
func ReadAllPermission ¶ added in v0.0.6
func ReadAllPermission(qb *orm.QB) (PermissionList, error)
func (*PermissionList) Append ¶ added in v0.0.29
func (s *PermissionList) Append() model.Fielder
func (*PermissionList) DecodeFields ¶ added in v0.0.29
func (s *PermissionList) DecodeFields(_ model.FieldReader)
func (*PermissionList) EncodeFields ¶ added in v0.0.29
func (s *PermissionList) EncodeFields(_ model.FieldWriter)
func (*PermissionList) IsNil ¶ added in v0.0.29
func (s *PermissionList) IsNil() bool
func (*PermissionList) Len ¶ added in v0.0.29
func (s *PermissionList) Len() int
func (*PermissionList) Pointers ¶ added in v0.0.29
func (s *PermissionList) Pointers() []any
func (*PermissionList) Schema ¶ added in v0.0.29
func (s *PermissionList) Schema() []model.Field
type ProfileDTO ¶ added in v0.0.30
type ProfileDTO struct {
Id string
Name string
Email string
Avatar string
Roles []string
Permissions []string // "resource:actions" pairs, e.g. "service_catalog:rc"
Locale string
}
ProfileDTO is a safe subset of User data for public/API consumption.
func (*ProfileDTO) DecodeFields ¶ added in v0.0.30
func (p *ProfileDTO) DecodeFields(r model.FieldReader)
func (ProfileDTO) EncodeFields ¶ added in v0.0.30
func (p ProfileDTO) EncodeFields(w model.FieldWriter)
func (ProfileDTO) IsNil ¶ added in v0.0.30
func (p ProfileDTO) IsNil() bool
type ProfileData ¶ added in v0.0.2
func (*ProfileData) DecodeFields ¶ added in v0.0.29
func (m *ProfileData) DecodeFields(r model.FieldReader)
func (*ProfileData) EncodeFields ¶ added in v0.0.29
func (m *ProfileData) EncodeFields(w model.FieldWriter)
func (*ProfileData) IsNil ¶ added in v0.0.29
func (m *ProfileData) IsNil() bool
func (*ProfileData) ModelName ¶ added in v0.0.29
func (m *ProfileData) ModelName() string
func (*ProfileData) Pointers ¶ added in v0.0.28
func (m *ProfileData) Pointers() []any
func (*ProfileData) Schema ¶ added in v0.0.28
func (m *ProfileData) Schema() []model.Field
func (*ProfileData) Validate ¶ added in v0.0.32
func (m *ProfileData) Validate(action byte) error
type ProfileDataList ¶ added in v0.0.29
type ProfileDataList []*ProfileData
func (*ProfileDataList) Append ¶ added in v0.0.29
func (s *ProfileDataList) Append() model.Fielder
func (*ProfileDataList) DecodeFields ¶ added in v0.0.29
func (s *ProfileDataList) DecodeFields(_ model.FieldReader)
func (*ProfileDataList) EncodeFields ¶ added in v0.0.29
func (s *ProfileDataList) EncodeFields(_ model.FieldWriter)
func (*ProfileDataList) IsNil ¶ added in v0.0.29
func (s *ProfileDataList) IsNil() bool
func (*ProfileDataList) Len ¶ added in v0.0.29
func (s *ProfileDataList) Len() int
func (*ProfileDataList) Pointers ¶ added in v0.0.29
func (s *ProfileDataList) Pointers() []any
func (*ProfileDataList) Schema ¶ added in v0.0.29
func (s *ProfileDataList) Schema() []model.Field
type RegisterData ¶ added in v0.0.2
func (*RegisterData) DecodeFields ¶ added in v0.0.29
func (m *RegisterData) DecodeFields(r model.FieldReader)
func (*RegisterData) EncodeFields ¶ added in v0.0.29
func (m *RegisterData) EncodeFields(w model.FieldWriter)
func (*RegisterData) IsNil ¶ added in v0.0.29
func (m *RegisterData) IsNil() bool
func (*RegisterData) ModelName ¶ added in v0.0.29
func (m *RegisterData) ModelName() string
func (*RegisterData) Pointers ¶ added in v0.0.28
func (m *RegisterData) Pointers() []any
func (*RegisterData) Schema ¶ added in v0.0.28
func (m *RegisterData) Schema() []model.Field
func (*RegisterData) Validate ¶ added in v0.0.32
func (m *RegisterData) Validate(action byte) error
type RegisterDataList ¶ added in v0.0.29
type RegisterDataList []*RegisterData
func (*RegisterDataList) Append ¶ added in v0.0.29
func (s *RegisterDataList) Append() model.Fielder
func (*RegisterDataList) DecodeFields ¶ added in v0.0.29
func (s *RegisterDataList) DecodeFields(_ model.FieldReader)
func (*RegisterDataList) EncodeFields ¶ added in v0.0.29
func (s *RegisterDataList) EncodeFields(_ model.FieldWriter)
func (*RegisterDataList) IsNil ¶ added in v0.0.29
func (s *RegisterDataList) IsNil() bool
func (*RegisterDataList) Len ¶ added in v0.0.29
func (s *RegisterDataList) Len() int
func (*RegisterDataList) Pointers ¶ added in v0.0.29
func (s *RegisterDataList) Pointers() []any
func (*RegisterDataList) Schema ¶ added in v0.0.29
func (s *RegisterDataList) Schema() []model.Field
type Role ¶ added in v0.0.6
func (*Role) DecodeFields ¶ added in v0.0.29
func (m *Role) DecodeFields(r model.FieldReader)
func (*Role) EncodeFields ¶ added in v0.0.29
func (m *Role) EncodeFields(w model.FieldWriter)
type RoleList ¶ added in v0.0.29
type RoleList []*Role
func (*RoleList) DecodeFields ¶ added in v0.0.29
func (s *RoleList) DecodeFields(_ model.FieldReader)
func (*RoleList) EncodeFields ¶ added in v0.0.29
func (s *RoleList) EncodeFields(_ model.FieldWriter)
type RolePermission ¶ added in v0.0.6
func ReadOneRolePermission ¶ added in v0.0.6
func ReadOneRolePermission(qb *orm.QB, model *RolePermission) (*RolePermission, error)
func (*RolePermission) DecodeFields ¶ added in v0.0.29
func (m *RolePermission) DecodeFields(r model.FieldReader)
func (*RolePermission) EncodeFields ¶ added in v0.0.29
func (m *RolePermission) EncodeFields(w model.FieldWriter)
func (*RolePermission) IsNil ¶ added in v0.0.29
func (m *RolePermission) IsNil() bool
func (*RolePermission) ModelName ¶ added in v0.0.29
func (m *RolePermission) ModelName() string
func (*RolePermission) Pointers ¶ added in v0.0.6
func (m *RolePermission) Pointers() []any
func (*RolePermission) Schema ¶ added in v0.0.6
func (m *RolePermission) Schema() []model.Field
func (*RolePermission) SchemaExt ¶ added in v0.0.30
func (m *RolePermission) SchemaExt() []model.FieldExt
func (*RolePermission) Validate ¶ added in v0.0.32
func (m *RolePermission) Validate(action byte) error
type RolePermissionList ¶ added in v0.0.29
type RolePermissionList []*RolePermission
func ReadAllRolePermission ¶ added in v0.0.6
func ReadAllRolePermission(qb *orm.QB) (RolePermissionList, error)
func (*RolePermissionList) Append ¶ added in v0.0.29
func (s *RolePermissionList) Append() model.Fielder
func (*RolePermissionList) At ¶ added in v0.0.29
func (s *RolePermissionList) At(i int) model.Fielder
func (*RolePermissionList) DecodeFields ¶ added in v0.0.29
func (s *RolePermissionList) DecodeFields(_ model.FieldReader)
func (*RolePermissionList) EncodeFields ¶ added in v0.0.29
func (s *RolePermissionList) EncodeFields(_ model.FieldWriter)
func (*RolePermissionList) IsNil ¶ added in v0.0.29
func (s *RolePermissionList) IsNil() bool
func (*RolePermissionList) Len ¶ added in v0.0.29
func (s *RolePermissionList) Len() int
func (*RolePermissionList) Pointers ¶ added in v0.0.29
func (s *RolePermissionList) Pointers() []any
func (*RolePermissionList) Schema ¶ added in v0.0.29
func (s *RolePermissionList) Schema() []model.Field
type SecurityEvent ¶ added in v0.0.22
type SecurityEvent struct {
Type SecurityEventType
IP string // client IP, empty if not available
UserID string // empty if user not yet identified
Provider string // OAuth provider name, for OAuth events
Resource string // RBAC resource, for EventAccessDenied
Timestamp int64 // time.Now().Unix()
}
func (*SecurityEvent) EncodeFields ¶ added in v0.1.0
func (e *SecurityEvent) EncodeFields(w model.FieldWriter)
func (*SecurityEvent) IsNil ¶ added in v0.1.0
func (e *SecurityEvent) IsNil() bool
type SecurityEventType ¶ added in v0.0.22
type SecurityEventType uint8
const ( EventJWTTampered SecurityEventType = iota // validateJWT: jwt.Forged (never jwt.Expired) EventOAuthReplay // consumeState: state already consumed (2nd use) EventOAuthExpiredState // consumeState: state found but past ExpiresAt EventOAuthCrossProvider // consumeState: provider mismatch (state preserved) EventIPMismatch // LoginLAN: IP not registered EventNonActiveAccess // Login/LoginLAN: status != "active" EventAccessDenied // AccessCheck: RBAC denied with valid session EventPermissionCorrupt // HasPermission: permissions.action is not a CRUD string EventRateLimited // POST /login: Config.RateLimit rejected the attempt before bcrypt )
type Session ¶ added in v0.0.2
type Session struct {
Id string
UserId string
ExpiresAt int64
Ip string
UserAgent string
CreatedAt int64
}
func ReadOneSession ¶ added in v0.0.6
func (*Session) DecodeFields ¶ added in v0.0.29
func (m *Session) DecodeFields(r model.FieldReader)
func (*Session) EncodeFields ¶ added in v0.0.29
func (m *Session) EncodeFields(w model.FieldWriter)
type SessionList ¶ added in v0.0.29
type SessionList []*Session
func ReadAllSession ¶ added in v0.0.6
func ReadAllSession(qb *orm.QB) (SessionList, error)
func (*SessionList) Append ¶ added in v0.0.29
func (s *SessionList) Append() model.Fielder
func (*SessionList) DecodeFields ¶ added in v0.0.29
func (s *SessionList) DecodeFields(_ model.FieldReader)
func (*SessionList) EncodeFields ¶ added in v0.0.29
func (s *SessionList) EncodeFields(_ model.FieldWriter)
func (*SessionList) IsNil ¶ added in v0.0.29
func (s *SessionList) IsNil() bool
func (*SessionList) Len ¶ added in v0.0.29
func (s *SessionList) Len() int
func (*SessionList) Pointers ¶ added in v0.0.29
func (s *SessionList) Pointers() []any
func (*SessionList) Schema ¶ added in v0.0.29
func (s *SessionList) Schema() []model.Field
type User ¶
type User struct {
Id string
Email string
Name string
Phone string
Status string
CreatedAt int64
Roles []Role
Permissions []Permission
}
func (*User) DecodeFields ¶ added in v0.0.29
func (m *User) DecodeFields(r model.FieldReader)
func (*User) EncodeFields ¶ added in v0.0.29
func (m *User) EncodeFields(w model.FieldWriter)
type UserList ¶ added in v0.0.29
type UserList []*User
func (*UserList) DecodeFields ¶ added in v0.0.29
func (s *UserList) DecodeFields(_ model.FieldReader)
func (*UserList) EncodeFields ¶ added in v0.0.29
func (s *UserList) EncodeFields(_ model.FieldWriter)
type UserRole ¶ added in v0.0.6
func ReadOneUserRole ¶ added in v0.0.6
func (*UserRole) DecodeFields ¶ added in v0.0.29
func (m *UserRole) DecodeFields(r model.FieldReader)
func (*UserRole) EncodeFields ¶ added in v0.0.29
func (m *UserRole) EncodeFields(w model.FieldWriter)
type UserRoleList ¶ added in v0.0.29
type UserRoleList []*UserRole
func ReadAllUserRole ¶ added in v0.0.6
func ReadAllUserRole(qb *orm.QB) (UserRoleList, error)
func (*UserRoleList) Append ¶ added in v0.0.29
func (s *UserRoleList) Append() model.Fielder
func (*UserRoleList) DecodeFields ¶ added in v0.0.29
func (s *UserRoleList) DecodeFields(_ model.FieldReader)
func (*UserRoleList) EncodeFields ¶ added in v0.0.29
func (s *UserRoleList) EncodeFields(_ model.FieldWriter)
func (*UserRoleList) IsNil ¶ added in v0.0.29
func (s *UserRoleList) IsNil() bool
func (*UserRoleList) Len ¶ added in v0.0.29
func (s *UserRoleList) Len() int
func (*UserRoleList) Pointers ¶ added in v0.0.29
func (s *UserRoleList) Pointers() []any
func (*UserRoleList) Schema ¶ added in v0.0.29
func (s *UserRoleList) Schema() []model.Field
Click to show internal directories.
Click to hide internal directories.