Documentation
¶
Index ¶
- Variables
- func BuildSessionCookie(cfg config.AuthConfig, session *orm.Session) *http.Cookie
- func CSRFTTL(cfg config.AuthConfig) time.Duration
- func ClearSessionCookie(cfg config.AuthConfig) *http.Cookie
- func CreateSession(accountID string, ip string, userAgent string, cfg config.AuthConfig) (*orm.Session, error)
- func DeleteChallenge(id string) error
- func EnsureUserHandle(user *orm.Account) error
- func ExtractChallenge(clientDataBase64 string) (string, error)
- func HashPassword(password string, cfg config.AuthConfig) (string, string, error)
- func LoadChallengeByChallenge(challenge string, challengeType string) (*orm.AuthChallenge, *webauthn.SessionData, error)
- func LoadChallengeByUser(userID string, challengeType string) (*orm.AuthChallenge, *webauthn.SessionData, error)
- func LoadSession(sessionID string) (*orm.Session, *orm.Account, error)
- func LogAudit(action string, actorUserID *string, targetUserID *string, ...)
- func LogUserAudit(action string, actorUserID *string, targetCommanderID *uint32, ...)
- func NewToken(size int) (string, error)
- func NormalizeConfig(cfg config.AuthConfig) config.AuthConfig
- func NormalizeIP(addr string) string
- func NormalizeUserConfig(cfg config.AuthConfig) config.AuthConfig
- func NormalizeUsername(username string) string
- func RateLimitWindow(cfg config.AuthConfig) time.Duration
- func RefreshCSRF(sessionID string, cfg config.AuthConfig) (string, time.Time, error)
- func RevokeSession(sessionID string) error
- func RevokeSessions(accountID string, exceptSessionID string) error
- func SessionTTL(cfg config.AuthConfig) time.Duration
- func StoreChallenge(userID *string, challengeType string, session webauthn.SessionData, ...) (*orm.AuthChallenge, error)
- func TouchSession(sessionID string, lastSeen time.Time, expiresAt time.Time) error
- func VerifyPassword(password string, encoded string) (bool, error)
- func WebAuthnChallengeTTL(cfg config.AuthConfig) time.Duration
- type Manager
- type RateLimiter
- type WebAuthnProvider
- type WebAuthnUser
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrPasswordTooShort = errors.New("password too short") ErrPasswordTooLong = errors.New("password too long") ErrInvalidHash = errors.New("invalid password hash") )
View Source
var ErrChallengeNotFound = errors.New("challenge not found")
View Source
var ErrSessionNotFound = errors.New("session not found")
Functions ¶
func BuildSessionCookie ¶
func ClearSessionCookie ¶
func ClearSessionCookie(cfg config.AuthConfig) *http.Cookie
func CreateSession ¶
func DeleteChallenge ¶
func EnsureUserHandle ¶
func ExtractChallenge ¶
func HashPassword ¶
func LoadChallengeByChallenge ¶
func LoadChallengeByChallenge(challenge string, challengeType string) (*orm.AuthChallenge, *webauthn.SessionData, error)
func LoadChallengeByUser ¶
func LoadChallengeByUser(userID string, challengeType string) (*orm.AuthChallenge, *webauthn.SessionData, error)
func LogUserAudit ¶
func NormalizeConfig ¶
func NormalizeConfig(cfg config.AuthConfig) config.AuthConfig
func NormalizeIP ¶
func NormalizeUserConfig ¶
func NormalizeUserConfig(cfg config.AuthConfig) config.AuthConfig
func NormalizeUsername ¶
func RateLimitWindow ¶
func RateLimitWindow(cfg config.AuthConfig) time.Duration
func RefreshCSRF ¶
func RevokeSession ¶
func RevokeSessions ¶
func SessionTTL ¶
func SessionTTL(cfg config.AuthConfig) time.Duration
func StoreChallenge ¶
func StoreChallenge(userID *string, challengeType string, session webauthn.SessionData, expiresAt time.Time) (*orm.AuthChallenge, error)
func TouchSession ¶
func WebAuthnChallengeTTL ¶
func WebAuthnChallengeTTL(cfg config.AuthConfig) time.Duration
Types ¶
type Manager ¶
type Manager struct {
Config config.AuthConfig
WebAuthn WebAuthnProvider
Limiter *RateLimiter
Selection protocol.AuthenticatorSelection
}
func NewManager ¶
func NewManager(cfg config.AuthConfig) (*Manager, error)
func (*Manager) EnsureWebAuthn ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
func NewRateLimiter ¶
func NewRateLimiter() *RateLimiter
type WebAuthnProvider ¶
type WebAuthnProvider interface {
BeginRegistration(user webauthn.User, opts ...webauthn.RegistrationOption) (*protocol.CredentialCreation, *webauthn.SessionData, error)
FinishRegistration(user webauthn.User, session webauthn.SessionData, r *http.Request) (*webauthn.Credential, error)
BeginLogin(user webauthn.User, opts ...webauthn.LoginOption) (*protocol.CredentialAssertion, *webauthn.SessionData, error)
BeginDiscoverableLogin(opts ...webauthn.LoginOption) (*protocol.CredentialAssertion, *webauthn.SessionData, error)
FinishLogin(user webauthn.User, session webauthn.SessionData, r *http.Request) (*webauthn.Credential, error)
FinishPasskeyLogin(handler webauthn.DiscoverableUserHandler, session webauthn.SessionData, r *http.Request) (webauthn.User, *webauthn.Credential, error)
}
type WebAuthnUser ¶
type WebAuthnUser struct {
ID []byte
Name string
DisplayName string
Credentials []webauthn.Credential
}
func BuildWebAuthnUser ¶
func BuildWebAuthnUser(account orm.Account, credentials []orm.WebAuthnCredential) (WebAuthnUser, error)
func (WebAuthnUser) WebAuthnCredentials ¶
func (user WebAuthnUser) WebAuthnCredentials() []webauthn.Credential
func (WebAuthnUser) WebAuthnDisplayName ¶
func (user WebAuthnUser) WebAuthnDisplayName() string
func (WebAuthnUser) WebAuthnID ¶
func (user WebAuthnUser) WebAuthnID() []byte
func (WebAuthnUser) WebAuthnName ¶
func (user WebAuthnUser) WebAuthnName() string
Click to show internal directories.
Click to hide internal directories.