crypto

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PropJwtPublicKey  = "jwt.key.public"
	PropJwtPrivateKey = "jwt.key.private"
	PropJwtIssue      = "jwt.key.issuer"
)

JWT Configuration Properties

Variables

View Source
var (
	ErrMissingPrivateKey  = errors.New("missing private key")
	ErrMissingPublicKey   = errors.New("missing public key")
	ErrExtractClaimFailed = errors.New("unable to extract claims from token")
)
View Source
var (
	PUB_PEM_BEGIN = "-----BEGIN PUBLIC KEY-----"
	PUB_PEM_END   = "-----END PUBLIC KEY-----"

	PRIV_PEM_BEGIN = "-----BEGIN PRIVATE KEY-----"
	PRIV_PEM_END   = "-----END PRIVATE KEY-----"

	ErrDecodePemFailed = errors.New("failed to decode public key pem")
	ErrInvalidKey      = errors.New("invalid key")
)

Functions

func JwtEncode

func JwtEncode(claims jwt.MapClaims, exp time.Duration) (string, error)

func LoadPrivKey

func LoadPrivKey(content string) (*rsa.PrivateKey, error)

func LoadPubKey

func LoadPubKey(content string) (*rsa.PublicKey, error)

func ValidateIssuer

func ValidateIssuer() jwt.ParserOption

Types

type ParsedJwt

type ParsedJwt struct {
	Valid  bool
	Claims jwt.MapClaims
}

func JwtDecode

func JwtDecode(token string) (ParsedJwt, error)

Jump to

Keyboard shortcuts

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