auth

package
v0.0.0-...-a649508 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseJWK

type BaseJWK struct {
	// Algorithm is the algorithm intended for use with the key.
	Algorithm string `json:"alg"`
	// KeyType is the cryptographic algorithm family used with the key.
	KeyType string `json:"kty"`
	// KeyID matches a specific key.
	KeyID string `json:"kid"`
}

BaseJWK defines JSON web key fields returned by all key types.

type Claims

type Claims struct {
	jwt.StandardClaims
}

Claims are JSON web token claims.

func NewClaims

func NewClaims(opts ClaimsOptions) *Claims

NewClaims generates new claims for a JSON web token.

type ClaimsOptions

type ClaimsOptions struct {
	Lifespan time.Duration
	Id       string
}

ClaimsOptions are options for creating a JSON web token.

type JWKS

type JWKS struct {
	Keys []interface{} `json:"keys"`
}

JWKS is a JSON web key set.

type Key

type Key interface {
	// GetSigningMethod gets the signing method.
	GetSigningMethod() jwt.SigningMethod
	// GetJWK gets JSON web key fields.
	GetJWK() interface{}
	// GetKeyID gets the key identifier.
	GetKeyID() string
	// GetVerificationKey gets the JSON web token verification key.
	GetVerificationKey() interface{}
	// Sign signs a JSON web tokens.
	SignToken(token *jwt.Token) (string, error)
}

Key is a JSON web key.

type KeySet

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

KeySet is a JSON web key set.

func NewKeySet

func NewKeySet(keys []Key) *KeySet

NewKeySet creates a new JSON web key set.

func (KeySet) GetJWKS

func (ks KeySet) GetJWKS() (string, error)

GetJWKS gets the JSON web key set.

func (KeySet) GetVerificationKey

func (ks KeySet) GetVerificationKey(token *jwt.Token) (interface{}, error)

GetVerificationKey gets the JSON web token verification key.

func (KeySet) NewToken

func (ks KeySet) NewToken(claimOpts ClaimsOptions) (*Token, error)

NewToken creates a new JSON web token with claims.

func (KeySet) ParseToken

func (keySet KeySet) ParseToken(tokenString string) (*Token, error)

ParseToken parses and validates a JSON web token.

type RSAJWK

type RSAJWK struct {
	BaseJWK
	// Modulus is the RSA key's modulus value.
	Modulus string `json:"n"`
	// Exponent is the RSA key's exponent value.
	Exponent string `json:"e"`
	// X5T is the X.509 certificate SHA-1 thumbprint.
	X5T string `json:"x5t"`
}

RSAJWK defines additional JWK fields included in RSA JSON web keys.

type RSAKey

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

RSAKey is an RSA key.

func GenerateRandomRSAKey

func GenerateRandomRSAKey() (*RSAKey, error)

GenerateRandomRSAKey generates a random RSA JSON web key.

func (RSAKey) GetExponent

func (r RSAKey) GetExponent() string

GetExponent gets the Base64urlUInt-encoded RSA exponent value.

func (RSAKey) GetJWK

func (r RSAKey) GetJWK() interface{}

GetJWK gets JSON web key fields.

func (RSAKey) GetKeyID

func (r RSAKey) GetKeyID() string

GetKeyID gets the key identifier.

func (RSAKey) GetModulus

func (r RSAKey) GetModulus() string

GetModulus gets the Base64urlUInt-encoded RSA modulus value.

func (RSAKey) GetPublicKey

func (r RSAKey) GetPublicKey() *rsa.PublicKey

GetPublicKey gets the public RSA key.

func (RSAKey) GetSigningMethod

func (r RSAKey) GetSigningMethod() jwt.SigningMethod

GetSigningMethod gets the RSA signing method.

func (RSAKey) GetVerificationKey

func (r RSAKey) GetVerificationKey() interface{}

GetVerificationKey gets the JSON web token verification key.

func (RSAKey) GetX5T

func (r RSAKey) GetX5T() string

GetX5T gets the X.509 certificate SHA-1 thumbprint. https://datatracker.ietf.org/doc/html/rfc7517#section-4.8

func (RSAKey) SignToken

func (r RSAKey) SignToken(token *jwt.Token) (string, error)

SignToken signs a JSON web tokens.

type Token

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

Token is a JSON web token.

func NewToken

func NewToken(key Key, claimOpts ClaimsOptions) *Token

NewToken creates a new JSON web token with claims.

func (Token) Claims

func (t Token) Claims() (*Claims, bool)

Claims gets a token's claims.

func (Token) Sign

func (t Token) Sign() (string, error)

Sign gets the signed JSON web token string.

Jump to

Keyboard shortcuts

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