misc

package
v0.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PasswordMinChar is the minimum number of characters the password should have
	PasswordMinChar = 12

	// PasswordMaxChar is the maximum number of characters the password should have
	PasswordMaxChar = 30

	// PasswordMinUniqueChar is the minimum number of unique characters the password should have
	PasswordMinUniqueChar = 7
)

Variables

View Source
var PasswordTooltip = fmt.Sprintf(passwordTooltipTemplate, PasswordMinChar, PasswordMaxChar, PasswordMinUniqueChar)

PasswordTooltip is an explanation snippet of the rules to a valid password

Functions

func ConvertInterfaceArrayToStringArray

func ConvertInterfaceArrayToStringArray(toConvert []interface{}) []string

ConvertInterfaceArrayToStringArray a helper method to perform conversions between []interface{} and []string

func CountUniqueCharacters added in v0.5.0

func CountUniqueCharacters(str string) int

CountUniqueCharacters counts the unique characters in a string

func ExtractClaimsTokenFromRequest added in v0.4.0

func ExtractClaimsTokenFromRequest(secret string, r *http.Request) (jwt.MapClaims, error)

ExtractClaimsTokenFromRequest extract a jwt token from a given request

func GenerateSalt

func GenerateSalt() string

GenerateSalt a salt string with 16 bytes of crypto/rand data.

func GenerateToken added in v0.4.0

func GenerateToken(secret string, data jwt.MapClaims) (string, error)

GenerateToken generates a jwt token

func GetChangePasswordToken added in v0.5.4

func GetChangePasswordToken(secret, username, redirectTo string) string

GetEmailConfirmationToken builds a token for changing password

func GetEmailConfirmationToken added in v0.4.0

func GetEmailConfirmationToken(secret, username, challenge string) string

GetEmailConfirmationToken builds a token for email confirmation

func GetEncryptedPassword

func GetEncryptedPassword(secretKey, password, salt string) string

GetEncryptedPassword builds an encrypted password with hmac(sha512)

func GetJSONStr

func GetJSONStr(toEncode interface{}) string

GetJSONStr gets the full json string from the toEncode structure

func ParseToken added in v0.5.4

func ParseToken(tokenString, secret string) (jwt.MapClaims, error)

ParseToken extract the claims from a token string

func UnmarshalChangePasswordToken added in v0.5.4

func UnmarshalChangePasswordToken(claims jwt.MapClaims) (string, string, error)

UnmarshalChangePasswordToken verify it is an change password token and extract the extras information

func UnmarshalEmailConfirmationToken added in v0.4.0

func UnmarshalEmailConfirmationToken(claims jwt.MapClaims) (username, challenge string)

UnmarshalEmailConfirmationToken verify it is an email confirmation token and extract the extras information

func UnmarshalPayloadFromRequest added in v0.5.4

func UnmarshalPayloadFromRequest(p IPayload, r *http.Request) error

UnmarshalPayloadFromRequest initializes payload from an http request form and triggers the check function of the payload

func ValidatePassword added in v0.5.0

func ValidatePassword(password, username, email string) error

ValidatePassword verify if a password is valid

func VerifyEmail added in v0.5.4

func VerifyEmail(email string) error

VerifyEmail verify if the string is actually an email

Types

type BasePage added in v0.5.4

type BasePage struct {
	HTML template.HTML // a page should have an HTML
}

BasePage holds the basic information from a page

func (*BasePage) SetHTML added in v0.5.4

func (p *BasePage) SetHTML(html template.HTML)

SetHTML exposes the attribute HTML

type GrantScope

type GrantScope struct {
	Description string
	Details     string
	Scope       string
}

GrantScope defines the structure of a grant scope

type GrantScopes

type GrantScopes map[string]GrantScope

GrantScopes defines a map of grant scopes

func (GrantScopes) GetScopeListFromGrantScopeMap

func (gss GrantScopes) GetScopeListFromGrantScopeMap() []string

GetScopeListFromGrantScopeMap builds a list of scopes from a grant scope map

type IPage added in v0.5.4

type IPage interface {
	SetHTML(html template.HTML)
}

IPage defines what a page should expose

type IPayload added in v0.5.4

type IPayload interface {
	Check() error
}

IPayload defines what should a payload expose

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL