auth

package
v0.0.0-...-e35233a Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateShortID

func GenerateShortID(prefix string) string

GenerateShortID generates a short ID. If the provided prefix is not an empty string then the generated ID will be in the following format: <prefix>-<id>. For example for "rhd" prefix: "rhd-5294981621"

func GenerateShortIDWithDate

func GenerateShortIDWithDate(prefix string) string

GenerateShortID generates a short ID. If the provided prefix is not an empty string then the generated ID will be in the following format: <prefix>-<date>-<id>. Where <date> is the current date in the following format: "Mmm-dd". For example for "rhd" prefix: "rhd-Jan02-5294981621"

Types

type DefaultTokenParserConfiguration

type DefaultTokenParserConfiguration interface {
	GetAuthClientPublicKeysURL() string
	GetEnvironment() string
}

DefaultTokenParserConfiguration represents a partition of the configuration that is used for configuring the default TokenParser.

type JSONKeys

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

JSONKeys the remote keys encoded in a json document

type KeyManager

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

KeyManager manages the public keys for token validation.

func NewKeyManager

func NewKeyManager(config KeyManagerConfiguration) (*KeyManager, error)

NewKeyManager creates a new KeyManager and retrieves the public keys from the given URL.

func (*KeyManager) Key

func (km *KeyManager) Key(kid string) (*rsa.PublicKey, error)

Key retrieves the public key for a given kid.

type KeyManagerConfiguration

type KeyManagerConfiguration interface {
	GetAuthClientPublicKeysURL() string
	GetEnvironment() string
}

KeyManagerConfiguration represents a partition of the configuration that is used for configuring the KeyManager.

type PublicKey

type PublicKey struct {
	KeyID string
	Key   *rsa.PublicKey
}

PublicKey represents an RSA public key with a Key ID

type TokenClaims

type TokenClaims struct {
	Name          string `json:"name"`
	Username      string `json:"preferred_username"`
	GivenName     string `json:"given_name"`
	FamilyName    string `json:"family_name"`
	Email         string `json:"email"`
	EmailVerified bool   `json:"email_verified"`
	Company       string `json:"company"`
	jwt.StandardClaims
}

TokenClaims represents access token claims

func (*TokenClaims) Valid

func (c *TokenClaims) Valid() error

Valid checks whether the token claims are valid

type TokenParser

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

TokenParser represents a parser for JWT tokens.

func DefaultTokenParser

func DefaultTokenParser() (*TokenParser, error)

DefaultTokenParser returns the existing TokenManager instance.

func InitializeDefaultTokenParser

func InitializeDefaultTokenParser(config DefaultTokenParserConfiguration) (*TokenParser, error)

InitializeDefaultTokenParser creates the default token parser if it has not created yet. This function must be called in main to make sure the default parser is created during service startup. It will try to create the default parser only once even if called multiple times.

func NewTokenParser

func NewTokenParser(keyManager *KeyManager) (*TokenParser, error)

NewTokenParser creates a new TokenParser.

func (*TokenParser) FromString

func (tp *TokenParser) FromString(jwtEncoded string) (*TokenClaims, error)

FromString parses a JWT, validates the signaure and returns the claims struct.

Jump to

Keyboard shortcuts

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