ecdsa_jwt

package
v0.0.0-...-54fe6e2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alg

type Alg string
const (

	// Encrypts token with ecdsa with P-256 curve and SHA256 hash.
	ES256 Alg = "ES256"

	// Encrypts token with ecdsa with P-384 curve and SHA384 hash.
	ES384 Alg = "ES384"

	// Encrypts token with ecdsa with P-521 curve and SHA512 hash.
	ES512 Alg = "ES512"
)

type SigningOptions

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

func NewSigningOptions

func NewSigningOptions(nonceLen int, lifetimeSec int64, alg Alg) *SigningOptions

The nonce is a random string of nonceLen length. If nonceLen is 0, no nonce will be added. Lifetime is the time the token is valid from iat.

func (*SigningOptions) NewToken

func (sigOpts *SigningOptions) NewToken(regClaims map[string]interface{}, privKey *ecdsa.PrivateKey) (string, error)

Creates a new jwt token, adding registered claims and encrypted with given private key. Issued at and expiration (iat + lifetime) will be added automatically.

func (*SigningOptions) Verify

func (sigOpts *SigningOptions) Verify(token string, pubKey *ecdsa.PublicKey) error

Verifies the token with given public key. If the verification fails, or the token signature is invalid will return an error. This method doesn't validate the token claims.

Jump to

Keyboard shortcuts

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