security

package
v0.0.0-...-524bf5b Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package security provides functions for encryption of passwords and JWT token handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncryptPassword

func EncryptPassword(password string) (string, error)

EncryptPassword encrypts the given password with Bcrypt algorithm and returns the generated hash.

func GenerateJWT

func GenerateJWT(username string, authenticated bool) (string, error)

GenerateJWT generates new JWT with a username as a claim and authenticated claim set to false, because 2FA is needed to be fully authenticated. The JWT has an expiration time equal to the expirationDuration variable. The signing algorithm is HS256.

func HashAndPasswordMatch

func HashAndPasswordMatch(hash, password string) bool

HashAndPasswordMatch takes a hash and a password and determines if the hash matches the entered password.

func ValidateToken

func ValidateToken(tokenString string) (*claims, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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