Documentation ¶
Index ¶
- Variables
- func WriteErr(w http.ResponseWriter, err error, code int)
- func WriteJSON(w http.ResponseWriter, v interface{})
- type Auth
- func (a *Auth) LoginStep1SendVerificationCode(ctx context.Context, email, returnUrl string) error
- func (a *Auth) LoginStep2ConfirmCode(ctx context.Context, email string, code string) (bool, *TokenResponse, error)
- func (a *Auth) ParseTemplate(link, code string) string
- func (a *Auth) RefreshToken(ctx context.Context, rt string) (*TokenResponse, error)
- type AuthMiddleware
- type Code
- type Config
- type Db
- type EmailData
- type EmailValidator
- type ErrResponse
- type Handler
- type IAuthDb
- type ICodeSender
- type IEmailValidator
- type IUserCreator
- type IUserIdentityVerifier
- type Key
- type Token
- type TokenResponse
- type UserIdentityVerifier
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorAuthHeaderMissing = errors.New("authorization header is missing") ErrorInvalidAuthHeader = errors.New("invalid authorization header format") )
Functions ¶
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, v interface{})
Types ¶
type Auth ¶
type Auth struct { Db IAuthDb Sender ICodeSender Uc IUserCreator Ev IEmailValidator Uiv IUserIdentityVerifier EmailTemplate *template.Template Cfg *Config }
func New ¶
func New(db IAuthDb, sender ICodeSender, uc IUserCreator, ev IEmailValidator, uiv IUserIdentityVerifier, et *template.Template, cfg *Config) *Auth
func NewWithMemDbAndDefaultTemplate ¶
func NewWithMemDbAndDefaultTemplate(sender ICodeSender, uc IUserCreator, cfg *Config) *Auth
func (*Auth) LoginStep1SendVerificationCode ¶
func (*Auth) LoginStep2ConfirmCode ¶
func (*Auth) ParseTemplate ¶
func (*Auth) RefreshToken ¶
type AuthMiddleware ¶
type AuthMiddleware struct {
Cfg *Config
}
func NewChiMiddleware ¶
func NewChiMiddleware(cfg *Config) *AuthMiddleware
func (*AuthMiddleware) VerifyAuthenticationToken ¶
func (am *AuthMiddleware) VerifyAuthenticationToken(next http.Handler) http.Handler
type Config ¶
type Config struct { AppName string Logo string Brand string BrandLink string CodeValidityPeriod time.Duration AccessTokenValidityPeriod time.Duration RefreshTokenValidityPeriod time.Duration AccessTokenSecret string RefreshTokenSecret string RateLimitPerSecond int ReturnUrls []string UseIdentity bool }
type Db ¶
type Db struct {
// contains filtered or unexported fields
}
func (*Db) GetVerificationCode ¶
func (*Db) RemoveVerificationCode ¶
type EmailValidator ¶
type EmailValidator struct {
Ev IEmailValidator
}
func NewEmailValidator ¶
func NewEmailValidator() *EmailValidator
func (*EmailValidator) Validate ¶
func (ev *EmailValidator) Validate(email string) bool
type ErrResponse ¶
type ErrResponse struct {
Error string `json:"error"`
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func (*Handler) ConfirmCode ¶
func (h *Handler) ConfirmCode(w http.ResponseWriter, r *http.Request)
func (*Handler) RefreshToken ¶
func (h *Handler) RefreshToken(w http.ResponseWriter, r *http.Request)
func (*Handler) SetupRoutes ¶
func (h *Handler) SetupRoutes(router chi.Router)
type ICodeSender ¶
type IEmailValidator ¶
type IUserCreator ¶
type IUserIdentityVerifier ¶
type TokenResponse ¶
type UserIdentityVerifier ¶
type UserIdentityVerifier struct { Uv IUserIdentityVerifier // contains filtered or unexported fields }
func NewUserIdentityVerifier ¶
func NewUserIdentityVerifier() *UserIdentityVerifier
func (*UserIdentityVerifier) CanLogin ¶
func (uv *UserIdentityVerifier) CanLogin(email string) (bool, string, error)
func (*UserIdentityVerifier) SetEmail ¶
func (uv *UserIdentityVerifier) SetEmail(email string)
Click to show internal directories.
Click to hide internal directories.