engine

package
v2.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// BearerWord the bearer key word for authorization
	BearerWord string = "Bearer"

	// BearerFormat authorization token format
	BearerFormat string = "Bearer %s"

	// AuthorizationKey holds the key used to store the token in the request header
	AuthorizationKey = "Authorization"

	// Reason holds the error reason.
	Reason = "UNAUTHORIZED"
)
View Source
const (
	ContextTypeGrpc = iota
	ContextTypeMicro
)

Variables

This section is empty.

Functions

func AuthFromMD

func AuthFromMD(ctx context.Context, ctxType ContextType) (string, error)

AuthFromMD .

func MDWithAuth

func MDWithAuth(ctx context.Context, tokenStr string, ctxType ContextType) context.Context

MDWithAuth .

func NewContext

func NewContext(ctx context.Context, claims Claims) context.Context

NewContext injects the provided claims in to the parent context.

Types

type Authenticator

type Authenticator interface {
	// Authenticate returns a claims info and nil error (if available).
	Authenticate(ctx context.Context, ctxType ContextType) (Claims, error)

	// CreateIdentityWithContext injects user claims into context.
	CreateIdentityWithContext(ctx context.Context, ctxType ContextType, claims Claims) (context.Context, error)

	// CreateIdentity inject user claims into token string.
	CreateIdentity(claims Claims) (string, error)
}

Authenticator interface

type Claims

type Claims interface {
	GetSubject() string
}

Claims interface

func FromContext

func FromContext(ctx context.Context) (claims Claims, ok bool)

FromContext extracts the claims from the provided context (if any).

type ContextType

type ContextType int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL