Files
opencloud/ocis-pkg/oidc/context.go
A.Unger c284b4d07b Add 'ocis-pkg/' from commit '72d605ba3857d0b972ddd72e226d8a5360fb480d'
git-subtree-dir: ocis-pkg
git-subtree-mainline: 4c12bed11b
git-subtree-split: 72d605ba38
2020-09-18 12:34:50 +02:00

18 lines
527 B
Go

package oidc
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 {
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)
return s
}