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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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