Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateShortID ¶
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 ¶
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.
type KeyManagerConfiguration ¶
type KeyManagerConfiguration interface { GetAuthClientPublicKeysURL() string GetEnvironment() string }
KeyManagerConfiguration represents a partition of the configuration that is used for configuring the KeyManager.
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.