security

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePasswordAndHash added in v1.1.0

func ComparePasswordAndHash(password, encodedHash string) (match bool, err error)

ComparePasswordAndHash Compares the input password and the previously generated hash and checks if plain password matches the encrypted password

func DecryptAES added in v1.1.0

func DecryptAES(encryptedinput string, secret string) string

DecryptAES decrypts a encrypted aes string data to plain text

func EncryptToAES added in v1.1.0

func EncryptToAES(input string, secret string) string

EncryptToAES encrypts the given plain text data to encrypted string

func GenerateFromPassword added in v1.1.0

func GenerateFromPassword(password string) (encodedHash string, err error)

GenerateFromPassword generates a argon2 hash on the input password

func GenerateRandomSecret added in v1.1.0

func GenerateRandomSecret() string

GenerateRandomSecret generates a random 32 byte secret to use for encryption

func GenerateToken

func GenerateToken(username string) (string, error)

GenerateToken generates a JWT token with a configured token secret

func RandomString added in v1.2.0

func RandomString(len int) string

RandomString Generates a random string of A-Z chars with len = l

func TokenCheck

func TokenCheck(next http.Handler) http.Handler

TokenCheck Middleware to secure endpoints

func ValidateToken

func ValidateToken(token *string) (bool, error)

ValidateToken validates an input token and tries to renew a token if close to expiring

Types

type Claims

type Claims struct {
	Username string `json:"username"`
	jwt.StandardClaims
}

Claims jwt claims container

Jump to

Keyboard shortcuts

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