Documentation ¶
Index ¶
- func GenerateSignedE2ETestToken(identity Identity, extraClaims ...ExtraClaim) (string, error)
- type ExtraClaim
- func WithAccountIDClaim(accountID string) ExtraClaim
- func WithAudClaim(aud []string) ExtraClaim
- func WithCompanyClaim(company string) ExtraClaim
- func WithEmailClaim(email string) ExtraClaim
- func WithExpClaim(exp time.Time) ExtraClaim
- func WithFamilyNameClaim(familyName string) ExtraClaim
- func WithGivenNameClaim(givenName string) ExtraClaim
- func WithIATClaim(iat time.Time) ExtraClaim
- func WithNotBeforeClaim(nbf time.Time) ExtraClaim
- func WithOriginalSubClaim(originalSub string) ExtraClaim
- func WithPreferredUsernameClaim(username string) ExtraClaim
- func WithSubClaim(sub string) ExtraClaim
- func WithUserIDClaim(userID string) ExtraClaim
- type Identity
- type MyClaims
- type PublicKey
- type TokenManager
- func (tg *TokenManager) AddPrivateKey(kid string) (*rsa.PrivateKey, error)
- func (tg *TokenManager) GenerateSignedToken(identity Identity, kid string, extraClaims ...ExtraClaim) (string, error)
- func (tg *TokenManager) GenerateToken(identity Identity, kid string, extraClaims ...ExtraClaim) *jwt.Token
- func (tg *TokenManager) Key(kid string) (*rsa.PrivateKey, error)
- func (tg *TokenManager) NewKeyServer() *httptest.Server
- func (tg *TokenManager) RemovePrivateKey(kid string)
- func (tg *TokenManager) SignToken(token *jwt.Token, kid string) (string, error)
- type WebKeySet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateSignedE2ETestToken ¶
func GenerateSignedE2ETestToken(identity Identity, extraClaims ...ExtraClaim) (string, error)
Types ¶
type ExtraClaim ¶
type ExtraClaim func(token *jwt.Token)
ExtraClaim a function to set claims in the token to generate
func WithAccountIDClaim ¶
func WithAccountIDClaim(accountID string) ExtraClaim
WithAccountIDClaim sets the `account_id` claim in the token to generate
func WithAudClaim ¶
func WithAudClaim(aud []string) ExtraClaim
WithAudClaim sets the `aud` claim in the token to generate
func WithCompanyClaim ¶
func WithCompanyClaim(company string) ExtraClaim
WithCompanyClaim sets the `company` claim in the token to generate
func WithEmailClaim ¶
func WithEmailClaim(email string) ExtraClaim
WithEmailClaim sets the `email` claim in the token to generate
func WithExpClaim ¶
func WithExpClaim(exp time.Time) ExtraClaim
WithExpClaim sets the `exp` claim in the token to generate
func WithFamilyNameClaim ¶
func WithFamilyNameClaim(familyName string) ExtraClaim
WithFamilyNameClaim sets the `familyName` claim in the token to generate
func WithGivenNameClaim ¶
func WithGivenNameClaim(givenName string) ExtraClaim
WithGivenNameClaim sets the `givenName` claim in the token to generate
func WithIATClaim ¶
func WithIATClaim(iat time.Time) ExtraClaim
WithIATClaim sets the `iat` claim in the token to generate
func WithNotBeforeClaim ¶
func WithNotBeforeClaim(nbf time.Time) ExtraClaim
WithNotBeforeClaim sets the `nbf` claim in the token to generate
func WithOriginalSubClaim ¶
func WithOriginalSubClaim(originalSub string) ExtraClaim
WithOriginalSubClaim sets the `original_sub` claim in the token to generate
func WithPreferredUsernameClaim ¶
func WithPreferredUsernameClaim(username string) ExtraClaim
WithPreferredUsernameClaim sets the `preferred username` claim in the token to generate
func WithSubClaim ¶
func WithSubClaim(sub string) ExtraClaim
WithSubClaim sets the `sub` claim in the token to generate
func WithUserIDClaim ¶
func WithUserIDClaim(userID string) ExtraClaim
WithUserIDClaim sets the `user_id` claim in the token to generate
type MyClaims ¶
type MyClaims struct { jwt.RegisteredClaims IdentityID string `json:"uuid,omitempty"` PreferredUsername string `json:"preferred_username,omitempty"` SessionState string `json:"session_state,omitempty"` Type string `json:"typ,omitempty"` Approved bool `json:"approved,omitempty"` Name string `json:"name,omitempty"` Company string `json:"company,omitempty"` GivenName string `json:"given_name,omitempty"` FamilyName string `json:"family_name,omitempty"` Email string `json:"email,omitempty"` EmailVerified bool `json:"email_verified,omitempty"` OriginalSub string `json:"original_sub"` UserID string `json:"user_id"` AccountID string `json:"account_id"` }
type PublicKey ¶
PublicKey represents an RSA public key with a Key ID
func GetE2ETestPublicKey ¶
func GetE2ETestPublicKey() []*PublicKey
GetE2ETestPublicKey returns the public key and kid used for e2e tests
type TokenManager ¶
type TokenManager struct {
// contains filtered or unexported fields
}
TokenManager represents the test token and key manager.
func NewTokenManager ¶
func NewTokenManager() *TokenManager
NewTokenManager creates a new TokenManager.
func (*TokenManager) AddPrivateKey ¶
func (tg *TokenManager) AddPrivateKey(kid string) (*rsa.PrivateKey, error)
AddPrivateKey creates and stores a new key with the given kid.
func (*TokenManager) GenerateSignedToken ¶
func (tg *TokenManager) GenerateSignedToken(identity Identity, kid string, extraClaims ...ExtraClaim) (string, error)
GenerateSignedToken generates a JWT user token and signs it using the given private key.
func (*TokenManager) GenerateToken ¶
func (tg *TokenManager) GenerateToken(identity Identity, kid string, extraClaims ...ExtraClaim) *jwt.Token
GenerateToken generates a default token.
func (*TokenManager) Key ¶
func (tg *TokenManager) Key(kid string) (*rsa.PrivateKey, error)
Key retrieves the key associated with the given kid.
func (*TokenManager) NewKeyServer ¶
func (tg *TokenManager) NewKeyServer() *httptest.Server
NewKeyServer creates and starts a http key server
func (*TokenManager) RemovePrivateKey ¶
func (tg *TokenManager) RemovePrivateKey(kid string)
RemovePrivateKey removes a key from the list of known keys.