Documentation
¶
Index ¶
Constants ¶
View Source
const SKIP_TOTP_LOGIN = 654 // 0
Variables ¶
View Source
var ( GuardNameAlreadyExists = errors.New("guard already exists") GuardNotFound = errors.New("guard not found") InvalidCredentials = errors.New("invalid credentials") InvalidPassword = errors.New("invalid password") HandlerNotAllowed = errors.New("handler not allowed") EmptyHandler = errors.New("handler has no value") Collision = errors.New("collision, too many records") IncorrectCredentials = errors.New("incorrect credentials") InvalidUserId = errors.New("invalid user id") MustValidateTOTP = errors.New("user must validate TOTP first") InvalidTOTPLogin = errors.New("invalid TOTP login request") IncorrectTOTPCode = errors.New("incorrect TOTP code") TOTPLoginDisabled = errors.New("TOTP login is disabled") NotRefreshable = errors.New("refresh token disabled") InvalidAccessToken = errors.New("invalid access token") RefreshTokenExpired = errors.New("refresh token expired") RefreshTokenRevoked = errors.New("refresh token revoked") )
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct {
Guard string `json:"guard"`
UserTable string `json:"user_table"`
UserId any `json:"user_id"`
UserStateHash string `json:"user_state_hash"`
UniqueToken string `json:"unique_token"` // plain, acts like primary key
HashedRefreshToken *string `json:"hashed_refresh_token"` // one-way hash, null = un-refreshable
UserAgent *string
IPAddress *string
ExpiresAt time.Time
CreatedAt time.Time
UpdatedAt *time.Time
RevokedAt *time.Time
LastActivityAt time.Time // at init, = CreatedAt
}
type Fort ¶
type Guard ¶
type Guard interface {
Login(userAgent *string, ip *string, props map[string]any, params ...int) (LoginResult, error)
LoginTOTP(userAgent *string, ip *string, token string, code string) (LoginResult, error)
Refresh(userAgent *string, ip *string, accessToken, refreshToken string) (LoginResult, error)
}
type GuardConfig ¶
type LoginConfig ¶
type LoginResult ¶
type PasswordsHasherComparer ¶
type TOTPConfig ¶
type TOTPConfig struct {
Now func() time.Time
// Number of seconds a TOTP hash is valid for. Defaults to 30 seconds.
Period uint
// Periods before or after the current time to allow. Value of 1 allows up to Period
// of either side of the specified time. Defaults to 0 allowed skews. Values greater
// than 1 are likely sketchy.
Skew uint
// Digits as part of the input. Defaults to 6.
Digits otp.Digits
// Algorithm to use for HMAC. Defaults to SHA1.
Algorithm otp.Algorithm
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.