Documentation ¶
Index ¶
- func Copy(elements map[string]interface{}) (result map[string]interface{})
- func Filter(elements map[string]interface{}, keys ...string) map[string]interface{}
- func ToString(i interface{}) string
- func ToTime(i interface{}) time.Time
- type ES256JWTStrategy
- func (j *ES256JWTStrategy) Decode(ctx context.Context, token string) (*jwt.Token, error)
- func (j *ES256JWTStrategy) Generate(ctx context.Context, claims jwt.Claims, header Mapper) (string, string, error)
- func (j *ES256JWTStrategy) GetSignature(ctx context.Context, token string) (string, error)
- func (j *ES256JWTStrategy) GetSigningMethodLength() int
- func (j *ES256JWTStrategy) Hash(ctx context.Context, in []byte) ([]byte, error)
- func (j *ES256JWTStrategy) Validate(ctx context.Context, token string) (string, error)
- type Headers
- type IDTokenClaims
- type JWTClaims
- func (c *JWTClaims) Add(key string, value interface{})
- func (c *JWTClaims) FromMap(m map[string]interface{})
- func (c *JWTClaims) FromMapClaims(mc jwt.MapClaims)
- func (c JWTClaims) Get(key string) interface{}
- func (c *JWTClaims) ToMap() map[string]interface{}
- func (c JWTClaims) ToMapClaims() jwt.MapClaims
- func (c *JWTClaims) With(expiry time.Time, scope, audience []string) JWTClaimsContainer
- func (c *JWTClaims) WithDefaults(iat time.Time, issuer string) JWTClaimsContainer
- func (c *JWTClaims) WithScopeField(scopeField JWTScopeFieldEnum) JWTClaimsContainer
- type JWTClaimsContainer
- type JWTClaimsDefaults
- type JWTScopeFieldEnum
- type JWTStrategy
- type Mapper
- type RS256JWTStrategy
- func (j *RS256JWTStrategy) Decode(ctx context.Context, token string) (*jwt.Token, error)
- func (j *RS256JWTStrategy) Generate(ctx context.Context, claims jwt.Claims, header Mapper) (string, string, error)
- func (j *RS256JWTStrategy) GetSignature(ctx context.Context, token string) (string, error)
- func (j *RS256JWTStrategy) GetSigningMethodLength() int
- func (j *RS256JWTStrategy) Hash(ctx context.Context, in []byte) ([]byte, error)
- func (j *RS256JWTStrategy) Validate(ctx context.Context, token string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ES256JWTStrategy ¶ added in v0.32.0
type ES256JWTStrategy struct {
PrivateKey *ecdsa.PrivateKey
}
ES256JWTStrategy is responsible for generating and validating JWT challenges
func (*ES256JWTStrategy) Generate ¶ added in v0.32.0
func (j *ES256JWTStrategy) Generate(ctx context.Context, claims jwt.Claims, header Mapper) (string, string, error)
Generate generates a new authorize code or returns an error. set secret
func (*ES256JWTStrategy) GetSignature ¶ added in v0.32.0
GetSignature will return the signature of a token
func (*ES256JWTStrategy) GetSigningMethodLength ¶ added in v0.32.0
func (j *ES256JWTStrategy) GetSigningMethodLength() int
GetSigningMethodLength will return the length of the signing method
type Headers ¶
type Headers struct {
Extra map[string]interface{}
}
Headers is the jwt headers
func NewHeaders ¶ added in v0.19.0
func NewHeaders() *Headers
func (Headers) ToMapClaims ¶ added in v0.3.0
ToMapClaims will return a jwt-go MapClaims representation
type IDTokenClaims ¶
type IDTokenClaims struct { JTI string Issuer string Subject string Audience []string Nonce string ExpiresAt time.Time IssuedAt time.Time RequestedAt time.Time AuthTime time.Time AccessTokenHash string AuthenticationContextClassReference string AuthenticationMethodsReference string CodeHash string Extra map[string]interface{} }
IDTokenClaims represent the claims used in open id connect requests
func (*IDTokenClaims) Add ¶
func (c *IDTokenClaims) Add(key string, value interface{})
Add will add a key-value pair to the extra field
func (*IDTokenClaims) Get ¶
func (c *IDTokenClaims) Get(key string) interface{}
Get will get a value from the extra field based on a given key
func (*IDTokenClaims) ToMap ¶
func (c *IDTokenClaims) ToMap() map[string]interface{}
ToMap will transform the headers to a map structure
func (IDTokenClaims) ToMapClaims ¶ added in v0.3.0
func (c IDTokenClaims) ToMapClaims() jwt.MapClaims
ToMapClaims will return a jwt-go MapClaims representation
type JWTClaims ¶
type JWTClaims struct { Subject string Issuer string Audience []string JTI string IssuedAt time.Time NotBefore time.Time ExpiresAt time.Time Scope []string Extra map[string]interface{} ScopeField JWTScopeFieldEnum }
JWTClaims represent a token's claims.
func (*JWTClaims) FromMapClaims ¶ added in v0.6.17
FromMapClaims will populate claims from a jwt-go MapClaims representation
func (JWTClaims) ToMapClaims ¶ added in v0.3.0
ToMapClaims will return a jwt-go MapClaims representation
func (*JWTClaims) With ¶ added in v0.26.0
func (c *JWTClaims) With(expiry time.Time, scope, audience []string) JWTClaimsContainer
func (*JWTClaims) WithDefaults ¶ added in v0.26.0
func (c *JWTClaims) WithDefaults(iat time.Time, issuer string) JWTClaimsContainer
func (*JWTClaims) WithScopeField ¶ added in v0.35.1
func (c *JWTClaims) WithScopeField(scopeField JWTScopeFieldEnum) JWTClaimsContainer
type JWTClaimsContainer ¶ added in v0.26.0
type JWTClaimsContainer interface { // With returns a copy of itself with expiresAt, scope, audience set to the given values. With(expiry time.Time, scope, audience []string) JWTClaimsContainer // WithDefaults returns a copy of itself with issuedAt and issuer set to the given default values. If those // values are already set in the claims, they will not be updated. WithDefaults(iat time.Time, issuer string) JWTClaimsContainer // WithScopeField configures how a scope field should be represented in JWT. WithScopeField(scopeField JWTScopeFieldEnum) JWTClaimsContainer // ToMapClaims returns the claims as a github.com/dgrijalva/jwt-go.MapClaims type. ToMapClaims() jwt.MapClaims }
type JWTClaimsDefaults ¶ added in v0.26.0
type JWTScopeFieldEnum ¶ added in v0.35.1
type JWTScopeFieldEnum int
Enum for different types of scope encoding.
const ( JWTScopeFieldUnset JWTScopeFieldEnum = iota JWTScopeFieldList JWTScopeFieldString JWTScopeFieldBoth )
type JWTStrategy ¶ added in v0.19.0
type JWTStrategy interface { Generate(ctx context.Context, claims jwt.Claims, header Mapper) (string, string, error) Validate(ctx context.Context, token string) (string, error) Hash(ctx context.Context, in []byte) ([]byte, error) Decode(ctx context.Context, token string) (*jwt.Token, error) GetSignature(ctx context.Context, token string) (string, error) GetSigningMethodLength() int }
type Mapper ¶
type Mapper interface { ToMap() map[string]interface{} Add(key string, value interface{}) Get(key string) interface{} }
Mapper is the interface used internally to map key-value pairs
type RS256JWTStrategy ¶
type RS256JWTStrategy struct {
PrivateKey *rsa.PrivateKey
}
RS256JWTStrategy is responsible for generating and validating JWT challenges
func (*RS256JWTStrategy) Generate ¶
func (j *RS256JWTStrategy) Generate(ctx context.Context, claims jwt.Claims, header Mapper) (string, string, error)
Generate generates a new authorize code or returns an error. set secret
func (*RS256JWTStrategy) GetSignature ¶
GetSignature will return the signature of a token
func (*RS256JWTStrategy) GetSigningMethodLength ¶
func (j *RS256JWTStrategy) GetSigningMethodLength() int
GetSigningMethodLength will return the length of the signing method