Documentation
¶
Index ¶
- Variables
- func BindingExternalAccount(uuid string, sso_id string) error
- func CheckPassword(username, passwd string) (uuid string, success bool, err error)
- func CreateAccount(username, passwd string) (user models.User, err error)
- func CreateAccountWithDB(db *gorm.DB, username, passwd string) (user models.User, err error)
- func CreateSession(uuid string, expires int, userAgent, ip, login_method string) (string, error)
- func DeleteAccountByUsername(username string) (err error)
- func DeleteAccountByUsernameWithDB(db *gorm.DB, username string) (err error)
- func DeleteAllSessions() error
- func DeleteOtherSessions(uuid, keep string) error
- func DeleteSession(session string) (err error)
- func Disable2Fa(uuid string) error
- func Enable2Fa(uuid, secret string) error
- func ForceResetPassword(username, passwd string) (err error)
- func Generate2Fa() (string, image.Image, error)
- func GetAllSessions() (sessions []models.Session, err error)
- func GetSession(session string) (uuid string, err error)
- func GetUserBySSO(ssoID string) (user models.User, err error)
- func GetUserBySession(session string) (models.User, error)
- func GetUserByUUID(uuid string) (user models.User, err error)
- func PasswordRetryAfter() time.Duration
- func RemoveExpiredSessions() error
- func Replace2Fa(uuid, secret, expected string) error
- func UnbindExternalAccount(uuid string) error
- func UpdateLatest(session, useragent, ip string) error
- func UpdateUser(uuid string, name, password, sso_type *string) error
- func Verify2Fa(uuid, code string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var ErrPasswordBusy = errors.New("password service is busy")
ErrPasswordBusy reports that the KDF admission queue stayed full for the whole wait window. It is deliberately distinct from "wrong password" so callers can answer "try again" instead of consuming a login attempt.
var ( // TwoFactorIssuer 是认证器 App 里显示的发行方名称。 // 必须是 Nekomari 而不是上游的 Komari Monitor:这个字符串会被用户永久保存在 // 认证器里,写错品牌等于让每个用户都看到上游的名字。 TwoFactorIssuer = "Nekomari" )
Functions ¶
func BindingExternalAccount ¶
func CheckPassword ¶
CheckPassword 检查密码是否正确
密码正确返回用户 UUID 和 true;密码错误返回空字符串和 false。 KDF 并发槽位排队超时返回 ErrPasswordBusy,调用方必须把它当作「稍后重试」, 不能当作密码错误 —— 否则并发登录时所有人(含管理员)都会看到「密码错误」。
func CreateAccountWithDB ¶
func CreateSession ¶
CreateSession 创建新会话
func DeleteAccountByUsername ¶
func DeleteAllSessions ¶
func DeleteAllSessions() error
func DeleteOtherSessions ¶ added in v0.1.14
DeleteOtherSessions revokes every session of one account except keep. Replacing a second factor is an account-security change, so anyone else holding a session for that account must re-authenticate; the caller's own session survives so the change does not log the operator out of the page that made it.
func Disable2Fa ¶
func ForceResetPassword ¶
ForceResetPassword 强制重置用户密码
func GetAllSessions ¶
GetAllSessions 获取所有会话
func GetSession ¶
GetSession 根据会话 ID 获取 UUID
func PasswordRetryAfter ¶ added in v0.1.14
PasswordRetryAfter is how long a caller should wait before retrying a check that returned ErrPasswordBusy.
func RemoveExpiredSessions ¶
func RemoveExpiredSessions() error
func Replace2Fa ¶ added in v0.1.14
Replace2Fa overwrites an existing factor. It is only reachable from the password-authorised re-enrollment path (see Rebind2FA in web/api/admin): a lost authenticator cannot produce the code that /2fa/disable requires, so without a replacement path the only recovery was the disable2FA CLI command on the host. Callers must have established the account's identity first; this function deliberately performs no verification of its own.
The update is conditional on the factor still being the one the re-enrollment started against, so a pending token cannot clobber a factor that changed while it was outstanding.
func UnbindExternalAccount ¶
func UpdateLatest ¶
func UpdateUser ¶
Types ¶
This section is empty.