Documentation
¶
Index ¶
- Constants
- Variables
- func DoesHashMatch(hash, password string) bool
- func DoesPasswordMatch(user *database.User, password string) bool
- func GenerateOTP(user *database.User) (*otp.Key, error)
- func HashPassword(password string) (string, error)
- func IsOTPValid(user *database.User, otp string) bool
- func SigninEmailPassword(email string, password string) (*database.User, error)
- func Signup(name string, email string, password string) (*database.User, error)
- type Token
Constants ¶
View Source
const Issuer = "codelympics.dev"
Issuer is the issuer of the JWT token
View Source
const Validity = 24 * time.Hour
Validity is how long a key is valid
Variables ¶
View Source
var ErrHeaderStructureIncorrect = errors.New("header structure incorrect")
ErrHeaderStructureIncorrect means an incorrectly formatter error
View Source
var PublicKey *rsa.PublicKey
PublicKey used to verify tokens
Functions ¶
func DoesHashMatch ¶
DoesHashMatch checks if the hash matches the password
func DoesPasswordMatch ¶
DoesPasswordMatch checks if the hashed stored password and the supplied plain text password match
func GenerateOTP ¶
GenerateOTP creates an OTP secret for the user
func HashPassword ¶
HashPassword takes a password and hashes it
func IsOTPValid ¶
IsOTPValid checks if OTP is valid
func SigninEmailPassword ¶
SigninEmailPassword gets a user with a certain email and checks their password
Types ¶
type Token ¶
type Token struct { jwt.Payload ID string `json:"id,omitempty"` FullName string `json:"full_name,omitempty"` Email string `json:"email,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` Scopes []string `json:"scopes"` }
Token is the structure for the JWT token
func TokenFromHeader ¶
TokenFromHeader gets a token from the HTTP Authorization header
Click to show internal directories.
Click to hide internal directories.