security

package
v0.1.59 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAccessToken

func CreateAccessToken(ident *datatypes.UUID, duration time.Duration, scope *string) (string, error)

CreateAccessToken creates a new JWT token

func CreateRefreshToken

func CreateRefreshToken(ident *datatypes.UUID, duration time.Duration, scope *string) (string, error)

CreateRefreshToken creates a new JWT token

func GetClaimsIfAccessTokenIsValid

func GetClaimsIfAccessTokenIsValid(tokenString string) (*jwt.MapClaims, error)

GetClaimsIfAccessTokenIsValid validates this token and get the ISS claim

func GetClaimsIfRefreshTokenIsValid

func GetClaimsIfRefreshTokenIsValid(tokenString string) (*jwt.MapClaims, error)

GetClaimsIfRefreshTokenIsValid validates this token and get the ISS claim

func HashAndSalt

func HashAndSalt(pwd string) (string, error)

HashAndSalt turns password into encrypted hash The salt is included in the hash

func IsSamePassword

func IsSamePassword(plainPwd string, hashedPwd string) bool

IsSamePassword checks if password is the same as in the db

func Setup added in v0.1.44

func Setup(ck *CertAndKeys)

Setup loads the public and private keys fromfile

Types

type CertAndKeys added in v0.1.44

type CertAndKeys struct {
	/* Access tokens */
	AccessTokenPrivKeyPath string
	AccessTokenPubKeyPath  string
	AccessTokenPemPasswd   string

	/* Refresh tokens */
	RefreshTokenPrivKeyPath string
	RefreshTokenPubKeyPath  string
	RefreshTokenPemPasswd   string
}

CertAndKeys are paths for certificates and keys for initialization

type VerifyUserResult added in v0.1.56

type VerifyUserResult int

VerifyUserResult type with enum

const (
	// VerifyUserResultOK found username and password
	VerifyUserResultOK VerifyUserResult = iota
	// VerifyUserResultPasswordNotMatch password does not match
	VerifyUserResultPasswordNotMatch
	// VerifyUserResultEmailNotFound email is not found
	VerifyUserResultEmailNotFound
	// VerifyUserResultOtherError other error
	VerifyUserResultOtherError
)

func GetVerifiedAuthUser added in v0.1.36

func GetVerifiedAuthUser(userModel models.IModel) (models.IModel, VerifyUserResult)

GetVerifiedAuthUser authenticates the user

Jump to

Keyboard shortcuts

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