use claims map instead of struct
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
+13
-1
@@ -1,5 +1,17 @@
|
||||
package oidc
|
||||
|
||||
const (
|
||||
Iss = "iss"
|
||||
Sub = "sub"
|
||||
Email = "email"
|
||||
Name = "name"
|
||||
PreferredUsername = "preferred_username"
|
||||
UIDNumber = "uidnumber"
|
||||
GIDNumber = "gidnumber"
|
||||
Groups = "groups"
|
||||
OwncloudUUID = "ownclouduuid"
|
||||
)
|
||||
|
||||
// The ProviderMetadata describes an idp.
|
||||
// see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
|
||||
type ProviderMetadata struct {
|
||||
@@ -179,5 +191,5 @@ type StandardClaims struct {
|
||||
GIDNumber string `json:"gidnumber,omitempty"`
|
||||
|
||||
// OcisID is a unique, persistent, non reassignable user id
|
||||
OcisID string `json:"ocis.id,omitempty"`
|
||||
OcisID string `json:"ownclouduuid,omitempty"`
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ import "context"
|
||||
// contextKey is the key for oidc claims in a context
|
||||
type contextKey struct{}
|
||||
|
||||
// NewContext makes a new context that contains the OpenID Connect claims.
|
||||
func NewContext(parent context.Context, c *StandardClaims) context.Context {
|
||||
// NewContext makes a new context that contains the OpenID connect claims in a map.
|
||||
func NewContext(parent context.Context, c map[string]interface{}) context.Context {
|
||||
return context.WithValue(parent, contextKey{}, c)
|
||||
}
|
||||
|
||||
// FromContext returns the StandardClaims stored in a context, or nil if there isn't one.
|
||||
func FromContext(ctx context.Context) *StandardClaims {
|
||||
s, _ := ctx.Value(contextKey{}).(*StandardClaims)
|
||||
// FromContext returns the claims map stored in a context, or nil if there isn't one.
|
||||
func FromContext(ctx context.Context) map[string]interface{} {
|
||||
s, _ := ctx.Value(contextKey{}).(map[string]interface{})
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user