Documentation ¶
Index ¶
- Constants
- Variables
- func Authorize(ctx context.Context, permission string) (*tokens.Claims, error)
- func ClaimsFrom(ctx context.Context) (*tokens.Claims, bool)
- func Stream(s grpc.ServerStream, ctx context.Context) grpc.ServerStream
- func WithClaims(parent context.Context, claims *tokens.Claims) context.Context
Constants ¶
const ( KeyUnknown contextKey = iota KeyClaims )
Allocate context keys to simplify context key usage in Ensign
Variables ¶
var ( ErrNoClaimsInContext = errors.New("no claims available in context") ErrNotAuthorized = errors.New("claims do not have required permission") )
Functions ¶
func Authorize ¶ added in v0.5.1
Authorize reduces a multistep process into a single step; fetching the claims from the context and checking that the claims have the required permission. If there are no claims in the context or the permission is invalid, then an error is returned.
func ClaimsFrom ¶
ClaimsFrom returns the claims from the context if they exist or false if not.
func Stream ¶
func Stream(s grpc.ServerStream, ctx context.Context) grpc.ServerStream
Stream allows users to override the context on a grpc.ServerStream handler so that it returns a new context rather than the old context. It is advised to use the original stream's context as the new context's parent but this method does not enforce it and instead simply returns the context specified.
Types ¶
This section is empty.