jwt

package
v0.3.8-dev0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignatureAlgorithm = jose.RS256
)

Variables

This section is empty.

Functions

func LoadPrivateKey

func LoadPrivateKey(data []byte) (*jose.JSONWebKey, error)

LoadPrivateKey loads a private key from PEM/DER/JWK-encoded data.

func LoadPublicKey

func LoadPublicKey(data []byte) (*jose.JSONWebKey, error)

LoadPublicKey loads a public key from PEM/DER/JWK-encoded data.

Types

type AuthToken

type AuthToken struct {
	*jwt.Claims
	*StandardClaims
	*ClusterClaim
	Scope      string `json:"scope"`        // Space-separated list of scopes associated with the token.
	IsAPIToken bool   `json:"is_api_token"` // Bool to indicate if the token is an API token.
}

func (*AuthToken) Validate

func (t *AuthToken) Validate(issuer string) error

type ClusterClaim

type ClusterClaim struct {
	ClusterId       string `json:"cluster_id,omitempty"`       // Id of the cluster.
	ClusterName     string `json:"cluster_name,omitempty"`     // Name of the cluster.
	ClusterUserName string `json:"cluster_username,omitempty"` // Name of the user in the cluster.
	ClusterRole     string `json:"cluster_role,omitempty"`     // Role the user has in the cluster.
}

type JWTSigner

type JWTSigner interface {
	// GenerateSignedToken generates a signed JWT containing the given claims
	GenerateSignedToken(interface{}) (string, error)
}

JWTSigner is an interface for JWT signers

func NewSigner

func NewSigner(privateKeyFilename string) JWTSigner

NewSigner creates a thin wrapper around Square's go-jose library to issue JWT.

type JWTVerifier

type JWTVerifier interface {
	Verify(string, interface{}) error
	JWKS() *jose.JSONWebKeySet
	Close()
}

JWTVerifier verifies a JWT and parses claims

func NewVerifier

func NewVerifier(publicKeyFilename string) (JWTVerifier, error)

NewVerifier creates a new verifier for raw JWT

type StandardClaims

type StandardClaims struct {
	Name            string            `json:"name,omitempty"`             // User’s display name.
	Email           string            `json:"email,omitempty"`            // The email of the user.
	EmailVerified   bool              `json:"email_verified,omitempty"`   // If the upstream provider has verified the email.
	Groups          []string          `json:"groups,omitempty"`           // A list of strings representing the groups a user is a member of.
	FederatedClaims map[string]string `json:"federated_claims,omitempty"` // Claims from any upstream IDP.
}

https://www.iana.org/assignments/jwt/jwt.xhtml

type TestEnv

type TestEnv struct {
	*test.TestEnv
	// contains filtered or unexported fields
}

func NewTestEnv

func NewTestEnv(testEnv *test.TestEnv) (*TestEnv, error)

func (*TestEnv) CreateSigner

func (env *TestEnv) CreateSigner() JWTSigner

func (*TestEnv) CreateVerifier

func (env *TestEnv) CreateVerifier() (JWTVerifier, error)

func (*TestEnv) RotateCertificate

func (env *TestEnv) RotateCertificate() error

func (*TestEnv) Shutdown

func (env *TestEnv) Shutdown() error

Jump to

Keyboard shortcuts

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