Add PgStore with hashed token sessions, IAM bootstrap, and store factory wiring; remove in-memory token map and allow_dev_switch from login payload.
43 lines
1.5 KiB
Go
43 lines
1.5 KiB
Go
package auth
|
|
|
|
// AccountStatus 账号状态
|
|
type AccountStatus string
|
|
|
|
const (
|
|
StatusActive AccountStatus = "active"
|
|
StatusPendingApproval AccountStatus = "pending_approval"
|
|
StatusDisabled AccountStatus = "disabled"
|
|
)
|
|
|
|
// UserAccount 用户账号与受控职位实体
|
|
type UserAccount struct {
|
|
ID int64 `json:"id"`
|
|
Username string `json:"username"`
|
|
Name string `json:"name"`
|
|
PasswordHash string `json:"password_hash,omitempty"`
|
|
Status AccountStatus `json:"status"`
|
|
MustChangePassword bool `json:"must_change_password"`
|
|
RoleID string `json:"role_id"`
|
|
Position string `json:"position"`
|
|
EmployeeID string `json:"employee_id,omitempty"`
|
|
Department string `json:"department,omitempty"`
|
|
Email string `json:"email,omitempty"`
|
|
Avatar string `json:"avatar,omitempty"`
|
|
CreatedAt string `json:"created_at"`
|
|
UpdatedAt string `json:"updated_at"`
|
|
}
|
|
|
|
// SystemAuthConfig 系统全局认证与准入配置
|
|
type SystemAuthConfig struct {
|
|
AllowRegistration bool `json:"allow_registration"`
|
|
RequireApproval bool `json:"require_approval"`
|
|
}
|
|
|
|
// SessionInfo 登录会话与身份上下文
|
|
type SessionInfo struct {
|
|
Token string `json:"token"`
|
|
User *UserAccount `json:"user"`
|
|
MustChangePassword bool `json:"must_change_password"`
|
|
Env string `json:"env"`
|
|
}
|