ucjwt

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(ctx context.Context,
	privateKey *rsa.PrivateKey,
	keyID string,
	tokenID uuid.UUID,
	claims oidc.TokenClaims,
	jwtIssuerURL string,
	validFor int64) (string, error)

CreateToken creates a new JWT

func ExtractBearerToken

func ExtractBearerToken(h *http.Header) (string, error)

ExtractBearerToken extracts a bearer token from an HTTP request or returns an error if none is found or if it's malformed. NOTE: this doesn't enforce that it's a JWT, much less a valid one.

func IsExpired

func IsExpired(jwt string) (bool, error)

IsExpired returns `true, nil` if the supplied JWT has valid claims and is expired, `false, nil` if it has valid claims and is unexpired, and `true, err` if the claims aren't parseable. NOTE: It does NOT validate the token's signature!

func ParseClaimsUnverified

func ParseClaimsUnverified(token string) (*oidc.TokenClaims, error)

ParseClaimsUnverified extracts the claims from a token without validating its signature or anything else.

func ParseClaimsVerified

func ParseClaimsVerified(token string, key *rsa.PublicKey) (*oidc.TokenClaims, error)

ParseClaimsVerified extracts the claims from a token and verifies the signature, expiration, etc.

Types

type Config added in v0.6.6

type Config struct {
	ClientID     string    `yaml:"client_id" validate:"notempty"`
	ClientSecret string    `yaml:"client_secret" validate:"notempty"` // TODO: convert to secret.String
	TenantURL    string    `yaml:"tenant_url" validate:"notempty"`
	TenantID     uuid.UUID `yaml:"tenant_id" validate:"notnil"`
	CompanyID    uuid.UUID `yaml:"company_id" validate:"notnil"`
}

Config represents config for Console Authentication & Authorization.

Jump to

Keyboard shortcuts

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