Documentation ¶
Index ¶
Constants ¶
View Source
const ( // AccessTokenExpiry is how long access tokens last. AccessTokenExpiry = 15 // 15 minutes // RefreshTokenExpiry is the period of time that refresh tokens are valid. RefreshTokenExpiry = 60 * 24 * 3 // 3 days )
View Source
const ( // RoleUser is a constant value for the user role RoleUser = "user" // RoleAdmin is a constant value for the admin role RoleAdmin = "admin" // RoleAnon is a constant value for an anonymous role RoleAnon = "anonymous" )
Variables ¶
View Source
var ValidRoles = [2]string{RoleUser, RoleAdmin}
ValidRoles is a list of allowed roles for project users and api keys
Functions ¶
func CompareHashAndPassword ¶
CompareHashAndPassword compares the hash value to the password.
func HashPassword ¶
HashPassword returns the bcrypt hash of the password.
func RecaptchaSiteVerify ¶
RecaptchaSiteVerify verifies the client response with recaptcha
Types ¶
type JWT ¶
type JWT struct {
// contains filtered or unexported fields
}
JWT wraps functions need to create and parse JWTs
func (*JWT) CreateAccessToken ¶
CreateAccessToken creates a new JWT to be used as an access token.
func (*JWT) CreateJWT ¶
CreateJWT creates a new JWT. This function will add the `exp` key to the claims based on the expiry time.
func (*JWT) CreateRefreshToken ¶
CreateRefreshToken creates a new JWT to be used as the refresh token. The refresh token can be used to retrieve a new access token.
func (*JWT) TokenLookup ¶
TokenLookup returns an error if the JWT is invalid.
Click to show internal directories.
Click to hide internal directories.