Documentation
¶
Index ¶
- Variables
- func Has2FA(user User) bool
- type AuthConfig
- type AuthUser
- type Authenticator
- func (a *Authenticator) LoginAPI(router H.Router)
- func (a *Authenticator) MakeChangePasswordHandler() H.HandlerFunc
- func (a *Authenticator) MakeComplete2FAHandler() H.HandlerFunc
- func (a *Authenticator) MakeInit2FAHandler() H.HandlerFunc
- func (a *Authenticator) MakeLogin2FAHandler() H.HandlerFunc
- func (a *Authenticator) MakeLoginHandler() H.HandlerFunc
- func (a *Authenticator) MakeLogoutHandler() H.HandlerFunc
- func (a *Authenticator) MakeMiddleware() H.Middleware
- func (a *Authenticator) MakeResetPasswordHandler() H.HandlerFunc
- func (a *Authenticator) MakeSend2FACodeHandler() H.HandlerFunc
- func (a *Authenticator) MakeSocialLoginHandlers(router H.Router)
- type AvatarUser
- type Claims
- type EmailClient
- type EmailUser
- type FirstLastNameUser
- type FullNameUser
- type Init2FAResponse
- type IntIDUser
- type JWT
- func (j *JWT) GetClaims(token string) (*StandardClaims, error)
- func (j *JWT) GetClaimsFromCookie(r *http.Request, name string) (*StandardClaims, error)
- func (j *JWT) GetClaimsFromHeader(r *http.Request, name string) (*StandardClaims, error)
- func (j *JWT) GetClaimsFromRequest(r *http.Request) (*StandardClaims, error)
- func (j *JWT) MakeToken(claims *StandardClaims) (string, error)
- func (j *JWT) NewClaims() *StandardClaims
- func (j *JWT) SetCookie(w http.ResponseWriter, claims *StandardClaims) error
- type LocaleUser
- type LoginParams
- type LoginResponse
- type PasswordAuth
- type PasswordResetData
- type PhoneUser
- type SMSClient
- type SocialLoginConfig
- type SocialUser
- type SocialUserSource
- type StandardClaims
- func (c *StandardClaims) Extend()
- func (c *StandardClaims) GetAvatar() string
- func (c *StandardClaims) GetEmailAddress() string
- func (c *StandardClaims) GetFirstName() string
- func (c *StandardClaims) GetFullName() string
- func (c *StandardClaims) GetLastName() string
- func (c *StandardClaims) GetLocale() string
- func (c *StandardClaims) GetPhoneNumber() string
- func (c *StandardClaims) GetTimeZone() string
- func (c *StandardClaims) GetUUID() uuid.UUID
- func (c *StandardClaims) GetUserID() int64
- func (c *StandardClaims) GetUsername() string
- func (c *StandardClaims) SetFullName(name string)
- func (c *StandardClaims) SetUser(user User)
- func (c *StandardClaims) Valid() error
- type Template
- type TemplateConfig
- type TimeZoneUser
- type TwoFactorAuth
- type TwoFactorData
- type TwoFactorUser
- type UUIDUser
- type User
- type UserSource
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidToken = errors.New("invalid token")
View Source
var ErrTokenExpired = errors.New("token expired")
View Source
var ErrUnknownUser = errors.New("unknown user")
Functions ¶
Types ¶
type AuthConfig ¶
type AuthConfig struct {
AuthKey string `json:"key" arg:"key"`
TTL int `json:"ttl" arg:"ttl"`
Issuer string `json:"issuer" arg:"issuer"`
Cookie string `json:"cookie" arg:"cookie"`
Header string `json:"header" arg:"header"`
EmailSender string `json:"email_sender" arg:"email-sender"`
ResetTTL int `json:"reset_ttl" arg:"reset-ttl"`
ResetTemplate TemplateConfig `json:"reset_template" arg:"reset-template"`
TwoFactorTemplate TemplateConfig `json:"two_factor_template" arg:"two-factor-template"`
SocialLogin map[string]*SocialLoginConfig `json:"social"`
}
func (*AuthConfig) Init ¶ added in v2.1.0
func (cfg *AuthConfig) Init(serverRoot string) error
type AuthUser ¶
type AuthUser interface {
User
GetAuth() (authenticator.Authenticator, error)
SetAuth(authenticator.Authenticator) error
}
type Authenticator ¶
type Authenticator struct {
UserSource UserSource
EmailClient EmailClient
SMSClient SMSClient
Domain string
JWT *JWT
SocialConfig map[string]*SocialLoginConfig
EmailSender string
ResetTTL time.Duration
ResetTextTemplate Template
ResetHTMLTemplate Template
ResetSMSTemplate Template
TwoFactorTextTemplate Template
TwoFactorHTMLTemplate Template
TwoFactorSMSTemplate Template
}
func NewAuthenticator ¶
func NewAuthenticator(cfg AuthConfig, src UserSource) (*Authenticator, error)
func (*Authenticator) LoginAPI ¶
func (a *Authenticator) LoginAPI(router H.Router)
func (*Authenticator) MakeChangePasswordHandler ¶
func (a *Authenticator) MakeChangePasswordHandler() H.HandlerFunc
func (*Authenticator) MakeComplete2FAHandler ¶
func (a *Authenticator) MakeComplete2FAHandler() H.HandlerFunc
func (*Authenticator) MakeInit2FAHandler ¶
func (a *Authenticator) MakeInit2FAHandler() H.HandlerFunc
func (*Authenticator) MakeLogin2FAHandler ¶
func (a *Authenticator) MakeLogin2FAHandler() H.HandlerFunc
func (*Authenticator) MakeLoginHandler ¶
func (a *Authenticator) MakeLoginHandler() H.HandlerFunc
func (*Authenticator) MakeLogoutHandler ¶
func (a *Authenticator) MakeLogoutHandler() H.HandlerFunc
func (*Authenticator) MakeMiddleware ¶
func (a *Authenticator) MakeMiddleware() H.Middleware
func (*Authenticator) MakeResetPasswordHandler ¶
func (a *Authenticator) MakeResetPasswordHandler() H.HandlerFunc
func (*Authenticator) MakeSend2FACodeHandler ¶
func (a *Authenticator) MakeSend2FACodeHandler() H.HandlerFunc
func (*Authenticator) MakeSocialLoginHandlers ¶
func (a *Authenticator) MakeSocialLoginHandlers(router H.Router)
type AvatarUser ¶
type EmailClient ¶
type FirstLastNameUser ¶
type FullNameUser ¶
type Init2FAResponse ¶
type JWT ¶
type JWT struct {
// contains filtered or unexported fields
}
func (*JWT) GetClaimsFromCookie ¶
func (*JWT) GetClaimsFromHeader ¶
func (*JWT) GetClaimsFromRequest ¶
func (j *JWT) GetClaimsFromRequest(r *http.Request) (*StandardClaims, error)
func (*JWT) NewClaims ¶
func (j *JWT) NewClaims() *StandardClaims
func (*JWT) SetCookie ¶
func (j *JWT) SetCookie(w http.ResponseWriter, claims *StandardClaims) error
type LocaleUser ¶
type LoginParams ¶
type LoginResponse ¶
type LoginResponse struct {
Username string `json:"username"`
Claims *StandardClaims `json:"claims"`
Token string `json:"token"`
Needs2FA bool `json:"needs_two_factor,omitempty"`
}
type PasswordAuth ¶ added in v2.1.0
type PasswordResetData ¶
type SocialLoginConfig ¶
type SocialUser ¶
type SocialUserSource ¶
type SocialUserSource interface {
UserSource
GetSocialUser(driver, id, username string) (AuthUser, error)
}
type StandardClaims ¶
type StandardClaims struct {
jwt.StandardClaims
AuthTime int64 `json:"auth_time,omitempty"`
Provider string `json:"x-provider,omitempty"`
TTL int64 `json:"x-ttl,omitempty"`
TwoFactor bool `json:"x-2fa,omitempty"`
UserID int64 `json:"x-userid,omitempty"`
UserUUID uuid.UUID `json:"x-useruuid,omitempty"`
FirstName string `json:"given_name,omitempty"`
LastName string `json:"family_name,omitempty"`
FullName string `json:"name,omitempty"`
Username string `json:"preferred_username,omitempty"`
Email string `json:"email,omitempty"`
Phone string `json:"phone_number,omitempty"`
TimeZone string `json:"zoneinfo,omitempty"`
Locale string `json:"locale,omitempty"`
Avatar string `json:"picture,omitempty"`
Extra map[string]interface{} `json:"x-extra,omitempty"`
}
func NewStandardClaims ¶
func NewStandardClaims(issuer string, dur time.Duration) *StandardClaims
func (*StandardClaims) Extend ¶
func (c *StandardClaims) Extend()
func (*StandardClaims) GetAvatar ¶
func (c *StandardClaims) GetAvatar() string
func (*StandardClaims) GetEmailAddress ¶
func (c *StandardClaims) GetEmailAddress() string
func (*StandardClaims) GetFirstName ¶
func (c *StandardClaims) GetFirstName() string
func (*StandardClaims) GetFullName ¶
func (c *StandardClaims) GetFullName() string
func (*StandardClaims) GetLastName ¶
func (c *StandardClaims) GetLastName() string
func (*StandardClaims) GetLocale ¶
func (c *StandardClaims) GetLocale() string
func (*StandardClaims) GetPhoneNumber ¶
func (c *StandardClaims) GetPhoneNumber() string
func (*StandardClaims) GetTimeZone ¶
func (c *StandardClaims) GetTimeZone() string
func (*StandardClaims) GetUUID ¶
func (c *StandardClaims) GetUUID() uuid.UUID
func (*StandardClaims) GetUserID ¶
func (c *StandardClaims) GetUserID() int64
func (*StandardClaims) GetUsername ¶
func (c *StandardClaims) GetUsername() string
func (*StandardClaims) SetFullName ¶
func (c *StandardClaims) SetFullName(name string)
func (*StandardClaims) SetUser ¶
func (c *StandardClaims) SetUser(user User)
func (*StandardClaims) Valid ¶
func (c *StandardClaims) Valid() error
type TemplateConfig ¶
type TemplateConfig struct {
Text string `json:"text" arg:"text"`
HTML string `json:"html" arg:"html"`
SMS string `json:"sms" arg:"sms"`
}
func (*TemplateConfig) GetTemplates ¶
func (cfg *TemplateConfig) GetTemplates() (text, html, sms Template, err error)
func (*TemplateConfig) Init ¶ added in v2.1.0
func (cfg *TemplateConfig) Init(serverRoot string) error
type TimeZoneUser ¶
type TwoFactorAuth ¶ added in v2.1.0
type TwoFactorAuth interface {
authenticator.Authenticator
GenCode() string
Configure() (*authenticator.TwoFactorConfig, error)
IsDirty() bool
}
type TwoFactorData ¶
type TwoFactorUser ¶ added in v2.1.0
type TwoFactorUser interface {
AuthUser
GetTwoFactorAuth() (authenticator.Authenticator, error)
SetTwoFactorAuth(authenticator.Authenticator) error
InitTwoFactorAuth() (authenticator.Authenticator, error)
CompleteTwoFactorAuth(code string) error
}
type User ¶
type User interface {
GetUsername() string
}
func UserFromContext ¶
func UserFromRequest ¶
Click to show internal directories.
Click to hide internal directories.