Documentation
¶
Index ¶
- func CreateAuth(userid string, td *TokenDetails) error
- func DeleteAuth(givenUuid string) (int64, error)
- func DeleteTokens(authD *AccessDetails) error
- func ExtractToken(r *http.Request) string
- func FetchAuth(authD *AccessDetails) (string, error)
- func InitDb()
- func VerifyToken(r *http.Request) (*jwt.Token, error)
- type AccessDetails
- type TokenDetails
- type User
- func CreateUser(username string, password string, email string, first_name string, ...) (*User, error)
- func GetAccount(uuid string) (*User, bool)
- func GetAccountByCredential(id string) (*User, bool)
- func GetAccountByLogin(login string) (*User, bool)
- func ListAccounts() []User
- func SearchAccounts(search string) []User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateAuth ¶
func CreateAuth(userid string, td *TokenDetails) error
func DeleteAuth ¶
func DeleteTokens ¶
func DeleteTokens(authD *AccessDetails) error
func ExtractToken ¶
func FetchAuth ¶
func FetchAuth(authD *AccessDetails) (string, error)
func InitDb ¶
func InitDb()
TODO: move database to common location db handler InitDb initializes a global database connection. An existing connection will be closed.
func VerifyToken ¶
Parse, validate, and return a token. keyFunc will receive the parsed token and should return the key for validating.
Types ¶
type AccessDetails ¶
func ExtractTokenMetadata ¶
func ExtractTokenMetadata(r *http.Request) (*AccessDetails, error)
type TokenDetails ¶
type TokenDetails struct { AccessToken string RefreshToken string AccessUuid string RefreshUuid string AtExpires int64 RtExpires int64 }
func CreateToken ¶
func CreateToken(userid string) (*TokenDetails, error)
type User ¶
type User struct { UUID string `json:"-" db:"uuid"` Username string `json:"username" db:"username"` Password string `json:"password" db:"password"` Email string `json:"email" db:"email"` FirstName string `json:"first_name" db:"firstname"` LastName string `json:"last_name" db:"lastname"` IsDisabled bool `json:"-" db:"isdisabled"` CreatedAt time.Time `json:"-" db:"createdat"` UpdatedAt time.Time `json:"-" db:"updatedat"` }
func CreateUser ¶
func GetAccount ¶
GetAccount returns an account with matching UUID Returns false if no account with such UUID exists
func GetAccountByCredential ¶
GetAccountByCredential returns an active account (non disabled, no activation code, no reset password code) with matching username or email address. Returns false if no account with such username or email address exists.
func GetAccountByLogin ¶
GetAccountByUsername returns an active account (non disabled, no activation code, no reset password code) with matching login. Returns false if no account with such login exists.
func ListAccounts ¶
func ListAccounts() []User
ListAccounts returns all accounts stored in the database
func SearchAccounts ¶
SearchAccounts returns all accounts stored in the database where the account name (firstName, middleName, lastName or login) contains the search string.
func (*User) Save ¶
Create stores the account as new Account in the database. If the UUID string is empty a new UUID will be generated.
func (*User) SetPassword ¶
SetPassword hashes the plain text password and sets PWHash to the new value.
func (*User) VerifyPassword ¶
VerifyPassword checks whether the stored hash matches the plain text password