Documentation ¶
Index ¶
- Constants
- Variables
- func ComparePassword(password, encryptedPassword string) bool
- func EncryptPassword(password string) (string, error)
- func GetLastUpdate(token *jwt.Token) time.Time
- func GetSignedToken(signingMethod, secret, tokenID string) (string, error)
- func GetTokenID(token *jwt.Token) string
- func GetUserID(token *jwt.Token) string
- func ParseToken(signedToken, secret string) (*jwt.Token, error)
- func RefreshAuthToken(secret, signingMethod, tokenID string, ttl time.Duration) (string, error)
- type BuildTokenFunc
- type Details
- type Device
- type ExtendTokenExpirationDateFunc
- type ExtraPropertiesForTokenWithIDFunc
- type Notification
- type Token
- type User
Constants ¶
const ( // TypeWeb : type of a device TypeWeb = "web" // TypeIOS : type of a device TypeIOS = "ios" // TypeAndroid : type of a device TypeAndroid = "android" // MethodPassword : authentication method by password MethodPassword = "password" // MethodFacebook : authentication method by facebook MethodFacebook = "facebook" // MethodGoogle : authentication method by google MethodGoogle = "google" // InvalidCharactersSetForUsername : forbidden characters in an username. InvalidCharactersSetForUsername = "'‘{}" // MinimumCharactersForPassword : minimum number of characters in a password. MinimumCharactersForPassword = 10 // MinimumCharactersForUsername : minimum number of characters in a username. MinimumCharactersForUsername = 4 // PrivateKeyLength : length of the generated key code. PrivateKeyLength = 128 // RegisterCodeLength : length of the generated register code. RegisterCodeLength = 64 // PasswordEncryptionSalt : salt used to encrypt the password. PasswordEncryptionSalt = "$6$rounds=5000$" // PasswordEncryptionSaltLength : length of the salt used to encrypt the password. PasswordEncryptionSaltLength = 16 // ProcessUpdateEmailAddress : ProcessUpdateEmailAddress = "update_email" // ProcessUpdatePassword : ProcessUpdatePassword = "update_password" // ProcessVerifyEmailAddress : ProcessVerifyEmailAddress = "verify_email" // ProcessDeleteAccount : ProcessDeleteAccount = "delete_account" // ProcessDisableAccount : ProcessDisableAccount = "disable_account" )
Variables ¶
var ( // BuildTokenFromID : returns the content of a auth token from its ID. BuildTokenFromID BuildTokenFunc // ExtraPropertiesForTokenWithID : returns some extra properties to include in the auth token. ExtraPropertiesForTokenWithID ExtraPropertiesForTokenWithIDFunc // ExtendTokenExpirationDateFromID : extends the expiration date of a auth token from its ID. ExtendTokenExpirationDateFromID ExtendTokenExpirationDateFunc )
Functions ¶
func ComparePassword ¶
ComparePassword : return true if the password is equal to the encrypted password.
func EncryptPassword ¶
EncryptPassword : encrypt a password.
func GetLastUpdate ¶
GetLastUpdate : returns the token ID from a JWT token.
func GetSignedToken ¶
GetSignedToken : returns a JWT token with some details of an user and an auth token.
func GetTokenID ¶
GetTokenID : returns the token ID from a JWT token.
func ParseToken ¶
ParseToken : parses and verifies the authentication token and returns the claims.
Types ¶
type BuildTokenFunc ¶
BuildTokenFunc : function to build a token from its ID.
type Details ¶
type Details struct { UserID string Device Device Source string Method string IPAddress string Key string CreationDate time.Time ExpirationDate time.Time }
Details : struct representing the details of an authentication.
type Device ¶
type Device struct { Name string `json:"name"` Details string `json:"details"` Type string `json:"type"` UDID string `json:"udid,omitempty"` RawName string `json:"raw_name"` NotificationSettings Notification `json:"notification_settings"` }
Device : struct of a device.
func (*Device) SetUpNameAndDetails ¶
func (device *Device) SetUpNameAndDetails()
SetUpNameAndDetails : set ups the name and the details.
type ExtendTokenExpirationDateFunc ¶
ExtendTokenExpirationDateFunc : function to extend the expiration date of a token from its ID.
type ExtraPropertiesForTokenWithIDFunc ¶
ExtraPropertiesForTokenWithIDFunc : function to get some extra properties to include in the auth tokens.
type Notification ¶
type Notification struct { Token string `json:"token,omitempty"` Enabled bool `json:"enabled"` Notifications []string `json:"notifications"` }
Notification : settings of the notifications on a device.