authn

package
v0.0.0-...-3ae756e Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: GPL-3.0 Imports: 2 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithUser

func WithUser(ctx context.Context, user User) context.Context

Types

type CtxUser

type CtxUser struct {
	// contains filtered or unexported fields
}

User is the base user implementation.

func NewCtxUser

func NewCtxUser(id string, name string, email string) CtxUser

func (CtxUser) Email

func (user CtxUser) Email() string

func (CtxUser) GetExternalData

func (user CtxUser) GetExternalData(eid string) (string, bool)

func (CtxUser) HasRole

func (user CtxUser) HasRole(role string) bool

HasRole checks if a User is allowed to use a defined role.

func (CtxUser) ID

func (user CtxUser) ID() string

func (CtxUser) Name

func (user CtxUser) Name() string

func (CtxUser) Roles

func (user CtxUser) Roles() []string

func (CtxUser) WithExternalData

func (user CtxUser) WithExternalData(m map[string]string) CtxUser

func (CtxUser) WithRoles

func (user CtxUser) WithRoles(roles ...string) CtxUser

type User

type User interface {
	ID() string
	Name() string
	Email() string
	Roles() []string
	HasRole(string) bool
	GetExternalData(string) (string, bool)
}

User provides access to key user metadata and roles.

func ForContext

func ForContext(ctx context.Context) User

ForContext finds the user from the context. REQUIRES Middleware to have run.

Jump to

Keyboard shortcuts

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