Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CodeValidator ¶
type CodeValidator interface { // Validate validates whether the code matched with the key Validate(key, code string) error }
CodeValidator defences behaviors of a code validator
type Config ¶
type Config struct { // Service is a custom service for auth module Service // SigningKey is for generating and validating jwt token SigningKey string // SigningMethod is used to check token signing method // Optional. Default: "HS256" // Possible values: "HS256", "HS384", "HS512", "ES256", "ES384", "ES512", "RS256", "RS384", "RS512" SigningMethod string // Expiration is the effective duration of jwt token Expiration time.Duration }
Config defines the config for auth module
type Repo ¶
type Repo interface { // RegisterByPassword gets a new user by username and password RegisterByPassword(username, pass string) (int, error) // RegisterByMobileCode gets a new user by mobile RegisterByMobile(mobile string) (int, error) // RegisterByEmailCode gets a new user by email RegisterByEmail(email string) (int, error) // LoginByPassword login system by username and password // and return user id if authentication success LoginByPassword(username, pass string) (int, error) // LoginByMobileCode login system by mobile number // and return user id if authentication success LoginByMobile(mobile string) (int, error) // LoginByEmailCode login system by email address // and return user id if authentication success LoginByEmail(email string) (int, error) }
Repo is the repository interface for auth behaviors
type Service ¶
type Service interface { // RegisterByPassword gets a new user by username and password RegisterByPassword(username, pass string) (int, error) // RegisterByMobileCode gets a new user by mobile and code RegisterByMobileCode(mobile, code string) (int, error) // RegisterByEmailCode gets a new user by email and code RegisterByEmailCode(email, code string) (int, error) // LoginByPassword login system by username and password // and return user id if authentication success LoginByPassword(username, pass string) (int, error) // LoginByMobileCode login system by mobile number and validate code // and return user id if authentication success LoginByMobileCode(mobile, code string) (int, error) // LoginByEmailCode login system by email address and validate code // and return user id if authentication success LoginByEmailCode(email, code string) (int, error) }
Service defines auth behaviors
Click to show internal directories.
Click to hide internal directories.