authcontext

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithPrincipal

func WithPrincipal(ctx context.Context, p Principal) context.Context

WithPrincipal returns a new context with the assigned Principal.

Types

type Principal

type Principal struct {
	// ID is a unique identifier for the user (e.g. Email, Username, API Key abbreviation, or "demo-user")
	ID string
	// Name is a human-readable display name, if available.
	Name string
	// Role defines the access tier of the user (e.g. "admin", "user", "agent", "demo")
	Role string
	// AuthenticatedVia describes which strategy verified this principal ("oidc", "jwt", "apikey", "password", "none")
	AuthenticatedVia string
}

Principal represents the authenticated user or entity interacting with Genie.

func GetPrincipal

func GetPrincipal(ctx context.Context) Principal

GetPrincipal retrieves the Principal from the context. If no principal is found (meaning authentication was completely disabled or misconfigured), it returns a safe "demo" user to ensure the rest of the chain doesn't panic on nil.

func (Principal) IsDemo

func (p Principal) IsDemo() bool

IsDemo returns true if this principal is the default unauthenticated Demo User.

Jump to

Keyboard shortcuts

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