tokensupport

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ScopeBundle          string = "bundle"
	ScopeDecision        string = "az"
	ScopeAdmin           string = "root"
	EnvTknKeyDirectory   string = "HEXA_TKN_DIRECTORY"
	EnvTknPrivateKeyFile string = "HEXA_TKN_PRIVKEYFILE"
	EnvTknPubKeyFile     string = "HEXA_TKN_PUBKEYFILE"
	EnvTknJwksUrl        string = "HEXA_TKN_JWKS_URL"

	DefTknPrivateKeyFile string = "issuer-priv.pem"
	DefTknPublicKeyFile  string = "issuer-cert.pem"
	EnvTknEnforceMode    string = "HEXA_TKN_MODE"
	EnvTknIssuer         string = "HEXA_TKN_ISSUER"

	ModeEnforceAnonymous = "ANON"
	ModeEnforceBundle    = "BUNDLE"
	ModeEnforceAll       = "ALL"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JwtAuthToken

type JwtAuthToken struct {
	Scopes []string `json:"roles,omitempty"`
	Email  string   `json:"email,omitempty"`
	jwt.RegisteredClaims
}

type TokenHandler

type TokenHandler struct {
	TokenIssuer    string
	PrivateKey     *rsa.PrivateKey
	PublicKey      keyfunc.Keyfunc
	Authorizer     *oauth2support.ResourceJwtAuthorizer
	KeyDir         string
	PrivateKeyPath string
	PublicKeyPath  string
	Mode           string
}

func GenerateIssuerKeys

func GenerateIssuerKeys(name string, keepExisting bool) (*TokenHandler, error)

GenerateIssuerKeys will create a new JWT issuer private and public key set. Set keepExisting to true to enable auto-generation on first execution.

func LoadIssuer

func LoadIssuer(name string) (*TokenHandler, error)

func (*TokenHandler) IssueToken

func (a *TokenHandler) IssueToken(scopes []string, email string) (string, error)

func (*TokenHandler) PrivateKeyExists

func (a *TokenHandler) PrivateKeyExists() bool

Jump to

Keyboard shortcuts

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