Documentation
¶
Index ¶
- func GenerateTOTPSecret() (string, error)
- func TOTPProvisioningURI(issuer, username, secret string) string
- func ValidatePassword(cfg *config.Config, password string) error
- func VerifyTOTP(secret, code string, now time.Time) bool
- type Identity
- type Middleware
- func (m *Middleware) Authenticate(w http.ResponseWriter, r *http.Request) (*Identity, error)
- func (m *Middleware) Authorize(r *http.Request) error
- func (m *Middleware) CompletePasswordReset(req types.PasswordResetCompleteRequest) error
- func (m *Middleware) DisableTOTP(identity *Identity, username string) error
- func (m *Middleware) EnableTOTP(identity *Identity, username, code string) error
- func (m *Middleware) Login(w http.ResponseWriter, r *http.Request, username, password, totpCode string) (*Identity, error)
- func (m *Middleware) Logout(w http.ResponseWriter, r *http.Request) error
- func (m *Middleware) RevokeAllSessions() int
- func (m *Middleware) RevokeUserSessions(username string) int
- func (m *Middleware) SessionTTL() time.Duration
- func (m *Middleware) SetupTOTP(identity *Identity, username string) (*types.TOTPSetupResponse, error)
- func (m *Middleware) StartPasswordReset(identity *Identity, username string) (*types.PasswordResetStartResponse, error)
- func (m *Middleware) Wrap(next http.Handler) http.Handler
- func (m *Middleware) WrapCapability(next http.Handler, requiredCapability string) http.Handler
- func (m *Middleware) WrapRole(next http.Handler, requiredRole string) http.Handler
- type Session
- type SessionManager
- func (m *SessionManager) Authenticate(token string, now time.Time) (Session, bool)
- func (m *SessionManager) Issue(identity Identity, now time.Time) (Session, error)
- func (m *SessionManager) Revoke(token string)
- func (m *SessionManager) RevokeAll() int
- func (m *SessionManager) RevokeUser(username string) int
- func (m *SessionManager) TTL() time.Duration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateTOTPSecret ¶
func TOTPProvisioningURI ¶
Types ¶
type Identity ¶
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
func New ¶
func New(cfg *config.Config) *Middleware
func (*Middleware) Authenticate ¶
func (m *Middleware) Authenticate(w http.ResponseWriter, r *http.Request) (*Identity, error)
func (*Middleware) CompletePasswordReset ¶
func (m *Middleware) CompletePasswordReset(req types.PasswordResetCompleteRequest) error
func (*Middleware) DisableTOTP ¶
func (m *Middleware) DisableTOTP(identity *Identity, username string) error
func (*Middleware) EnableTOTP ¶
func (m *Middleware) EnableTOTP(identity *Identity, username, code string) error
func (*Middleware) Login ¶
func (m *Middleware) Login(w http.ResponseWriter, r *http.Request, username, password, totpCode string) (*Identity, error)
func (*Middleware) Logout ¶
func (m *Middleware) Logout(w http.ResponseWriter, r *http.Request) error
func (*Middleware) RevokeAllSessions ¶
func (m *Middleware) RevokeAllSessions() int
func (*Middleware) RevokeUserSessions ¶
func (m *Middleware) RevokeUserSessions(username string) int
func (*Middleware) SessionTTL ¶
func (m *Middleware) SessionTTL() time.Duration
func (*Middleware) SetupTOTP ¶
func (m *Middleware) SetupTOTP(identity *Identity, username string) (*types.TOTPSetupResponse, error)
func (*Middleware) StartPasswordReset ¶
func (m *Middleware) StartPasswordReset(identity *Identity, username string) (*types.PasswordResetStartResponse, error)
func (*Middleware) WrapCapability ¶
type Session ¶
type Session struct {
Token string `yaml:"token"`
CSRFToken string `yaml:"csrf_token"`
Username string `yaml:"username"`
Name string `yaml:"name"`
Email string `yaml:"email"`
Role string `yaml:"role"`
Capabilities []string `yaml:"capabilities,omitempty"`
MFAComplete bool `yaml:"mfa_complete,omitempty"`
IssuedAt time.Time `yaml:"issued_at"`
LastSeen time.Time `yaml:"last_seen"`
ExpiresAt time.Time `yaml:"expires_at"`
}
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager(path string, ttl time.Duration) *SessionManager
func (*SessionManager) Authenticate ¶
func (*SessionManager) Revoke ¶
func (m *SessionManager) Revoke(token string)
func (*SessionManager) RevokeAll ¶
func (m *SessionManager) RevokeAll() int
func (*SessionManager) RevokeUser ¶
func (m *SessionManager) RevokeUser(username string) int
func (*SessionManager) TTL ¶
func (m *SessionManager) TTL() time.Duration
Click to show internal directories.
Click to hide internal directories.