Documentation ¶
Index ¶
Constants ¶
View Source
const ( SessionCookieKey = "X-Session" DefaultDuration = 24 * time.Hour )
View Source
const ( TfaCookieKey = "X-Tfa" TfaImageSize = 200 )
View Source
const ( UserActive = "active" UserRoles = "roles" UserEmail = "email" UserPassword = "password" UserTfa = "tfa" UserTfaSecret = "tfa_secret" UserTfaCodes = "tfa_codes" UserTfaUrl = "tfa_url" UserLastActivity = "last_activity" )
View Source
const ( SessionCacheKey = "session" TfaCacheKey = "tfa" )
Variables ¶
View Source
var ( ErrorMissingSessionCookie = errors.New("session cookie does not exist") ErrorMissingTfaCookie = errors.New("tfa cookie does not exist") ErrorCredentialsMismatch = errors.New("client is not equal with session") ErrorMissingUser = errors.New("user doesn't exist") ErrorMismatchPassword = errors.New("passwords aren't equal") ErrorUserAlreadyExists = errors.New("user already exists") ErrorInvalidUser = errors.New("invalid user") ErrorInvalidOtp = errors.New("invalid otp") ErrorInvalidCredentials = errors.New("invalid credentials") )
Functions ¶
func CreateTable ¶
func MustCreateTable ¶
func MustDropTable ¶
Types ¶
type Manager ¶
type Manager interface { Session() SessionManager Tfa() TfaManager User() UserManager CustomUser(id int, email string) UserManager Manager() UserManager In(email, password string, roles ...Role) (In, error) Out() error MustIn(email, password string, roles ...Role) In MustOut() }
type Role ¶
type SessionManager ¶
type TfaManager ¶
type TfaManager interface { GetPendingUserId() (int, error) GetPendingVerification() (bool, error) GetActive() (bool, error) Enable(id ...int) error Disable(id ...int) error Verify(otp string) (string, error) VerifyCodes(email, codes string) (bool, error) CreateQrImageBase64(id ...int) (string, error) MustGetPendingUserId() int MustGetPendingVerification() bool MustGetActive() bool MustEnable(id ...int) MustDisable(id ...int) MustVerify(otp string) string MustVerifyCodes(email, codes string) bool MustCreateQrImageBase64(id ...int) string }
type User ¶
type User struct { Id int `json:"id" db:"id"` Active bool `json:"active" db:"active"` Roles []string `json:"roles" db:"roles"` Email string `json:"email" db:"email"` Password string `json:"password" db:"password"` Tfa bool `json:"tfa" db:"tfa"` TfaSecret sql.Null[string] `json:"tfaSecret" db:"tfa_secret"` TfaCodes sql.Null[string] `json:"tfaCodes" db:"tfa_codes"` TfaUrl sql.Null[string] `json:"tfaUrl" db:"tfa_url"` LastActivity time.Time `json:"lastActivity" db:"last_activity"` CreatedAt time.Time `json:"createdAt" db:"created_at"` UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` }
type UserManager ¶
type UserManager interface { Exists(id ...int) (bool, error) Get(id ...int) (User, error) Create(r User) (int, error) Update(r User, columns ...string) error ResetPassword(token ...string) (string, error) DestroyResetPassword(token string) error UpdatePassword(actualPassword, newPassword string) error ForceUpdatePassword(newPassword string) error Enable(id ...int) error Disable(id ...int) error UpdateActivity(id ...int) error MustExists(id ...int) bool MustGet(id ...int) User MustCreate(r User) int MustUpdate(r User, columns ...string) MustResetPassword(token ...string) string MustDestroyResetPassword(token string) MustUpdatePassword(actualPassword, newPassword string) MustForceUpdatePassword(newPassword string) MustEnable(id ...int) MustDisable(id ...int) MustUpdateActivity(id ...int) }
func CreateUserManager ¶
Click to show internal directories.
Click to hide internal directories.