ucjwt

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 12 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.UCTokenClaims,
	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 ParseJWTClaimsUnverified added in v1.1.0

func ParseJWTClaimsUnverified(token string) (jwt.MapClaims, error)

ParseJWTClaimsUnverified extracts the claims as MapClaims from a token without validating its signature or anything else.

func ParseUCClaimsUnverified added in v1.1.0

func ParseUCClaimsUnverified(token string) (*oidc.UCTokenClaims, error)

ParseUCClaimsUnverified extracts the claims as UCTokenClaims from a token without validating its signature or anything else.

func ParseUCClaimsVerified added in v1.1.0

func ParseUCClaimsVerified(token string, key *rsa.PublicKey) (*oidc.UCTokenClaims, error)

ParseUCClaimsVerified extracts the claims as UCTokenClaims 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