security

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Crypto

func Crypto(key []byte) *crypto

Crypto is a function that creates a new instance of the crypto struct. If the key parameter is nil, it generates a random 16-byte key. The generated crypto struct contains the key used for encryption and decryption.

Types

type Claims

type Claims struct {
	Subject string `json:"sub"`
	Scope   []string
	jwt.RegisteredClaims
}

type JsonWebTokenClaims

type JsonWebTokenClaims struct {
	Sub   string
	Scope []string
}

type JsonWebTokenSecurity

type JsonWebTokenSecurity struct {
	Key []byte
}

func (*JsonWebTokenSecurity) Create

func (j *JsonWebTokenSecurity) Create(c *JsonWebTokenClaims, exp int) (string, error)

Create generates a JSON Web Token (JWT) using the provided claims and expiration time. It returns the signed token as a string and an error if any.

func (*JsonWebTokenSecurity) Verify

func (j *JsonWebTokenSecurity) Verify(token string) (c *Claims, err error)

Verify verifies the validity of a JSON Web Token (JWT) and returns the ID of the token's subject. If the token is invalid or expired, an error is returned.

Jump to

Keyboard shortcuts

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