authn

package
v0.0.0-...-96f2668 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWrongContext         = errors.Unauthorized(reason, "wrong context for middleware")
	ErrMissingJwtToken      = errors.Unauthorized(reason, "no jwt token in context")
	ErrExtractSubjectFailed = errors.Unauthorized(reason, "extract subject failed")
)
View Source
var (
	ErrInvalidAuthUser = errors.Unauthorized(reason, "invalid auth user")
)

Functions

func Client

func Client(authenticator authn.Authenticator, opts ...Option) middleware.Middleware

Client is a client authenticator middleware.

func FromContext

func FromContext(ctx context.Context) (*authn.AuthClaims, bool)

func NewContext

func NewContext(ctx context.Context, claims *authn.AuthClaims) context.Context

func Server

func Server(authenticator authn.Authenticator, userCreator authn.SecurityUserCreator) middleware.Middleware

Server is a server authenticator middleware.

Types

type ContextWithToken

type ContextWithToken func(context.Context, string) context.Context

type Option

type Option func(*options)

func WithAuthClaims

func WithAuthClaims(claims authn.AuthClaims) Option

func WithContextToken

func WithContextToken(f ContextWithToken) Option

type Result

type Result struct {
	UserId uint32
	Name   string
}

func AuthFromContext

func AuthFromContext(ctx context.Context) (*Result, error)

Jump to

Keyboard shortcuts

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