security

package
v0.0.0-...-ed8586a Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccessTokenExpired = errors.New("security.jwt.access_token_expired")
	ErrAccessTokenInvalid = errors.New("security.jwt.access_token_invalid")
)

Functions

This section is empty.

Types

type Bcrypt

type Bcrypt struct{}

func NewBcrypt

func NewBcrypt() Bcrypt

func (*Bcrypt) Compare

func (b *Bcrypt) Compare(raw string, hashed string) error

Compare compares a raw string with a hashed string.

func (*Bcrypt) Hash

func (b *Bcrypt) Hash(raw string) ([]byte, error)

Hash hashes a raw string.

type JWT

type JWT struct {
	// contains filtered or unexported fields
}

func NewJWT

func NewJWT(accessToken, refreshToken JWTTokenConfig) JWT

func (*JWT) GenerateAccessToken

func (j *JWT) GenerateAccessToken(userID entity.UserID) (string, time.Time, error)

func (*JWT) GenerateRefreshToken

func (j *JWT) GenerateRefreshToken(userID entity.UserID) (string, time.Time, error)

func (*JWT) VerifyAccessToken

func (j *JWT) VerifyAccessToken(rawToken string) (entity.UserID, error)

type JWTTokenConfig

type JWTTokenConfig struct {
	Key string
	Exp int
}

Jump to

Keyboard shortcuts

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