token

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateKeyForTokens

func CreateKeyForTokens() ([]byte, []byte, error)

CreateKeyForTokens creates an elliptic curve (EC) key that can be used for signing tokens. The token functions in this library will accept any valid key, EC or not, and do not require that the key be created by this function.

func CreateTokenFromKey

func CreateTokenFromKey(key []byte, subject string) (string, error)

CreateTokenFromKey creates a new JSON Web Token (JWT) and signs it with the given key. The key should be a decoded PEM key, in DER form, such as the one produced by the CreateKeyForToken() function below.

func GetKeyFromPEM

func GetKeyFromPEM(pemKey []byte) ([]byte, error)

GetKeyFromPEM will read the key from a PEM block.

func VerifyToken

func VerifyToken(tokenString string, key []byte) error

VerifyToken verifies that a given JWT was signed with the specified key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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