21 lines
376 B
Go
21 lines
376 B
Go
package authctx
|
|
|
|
import "context"
|
|
|
|
type Actor struct {
|
|
TenantID string
|
|
UID string
|
|
JTI string
|
|
}
|
|
|
|
type actorKey struct{}
|
|
|
|
func WithActor(ctx context.Context, actor Actor) context.Context {
|
|
return context.WithValue(ctx, actorKey{}, actor)
|
|
}
|
|
|
|
func ActorFromContext(ctx context.Context) (Actor, bool) {
|
|
actor, ok := ctx.Value(actorKey{}).(Actor)
|
|
return actor, ok
|
|
}
|