identity

package
v0.1.8-rc.13 Latest Latest
Warning

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

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

Documentation

Overview

Package identity provides a unified user identity type (Sender) and context helpers shared by the auth middleware and the messenger subsystem. It exists as a standalone package to avoid import cycles between pkg/security/auth (which produces identities) and pkg/messenger (which consumes them in MessageOrigin).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithSender

func WithSender(ctx context.Context, s Sender) context.Context

WithSender returns a new context with the assigned Sender.

Types

type Sender

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

Sender represents the authenticated user or entity interacting with Genie. It unifies platform-level identity (ID, Username, DisplayName) with security metadata (Role, AuthenticatedVia) so that a single type flows through both HTTP-authenticated and messenger-originated requests.

func DemoSender

func DemoSender() Sender

DemoSender returns a Sender that represents the unauthenticated demo user.

func GetSender

func GetSender(ctx context.Context) Sender

GetSender retrieves the Sender from the context. If no sender is found (meaning authentication was completely disabled or the call originated from a messenger path without auth), it returns a safe "demo" user to ensure the rest of the chain doesn't panic on a zero value.

func (Sender) IsDemo

func (s Sender) IsDemo() bool

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

Jump to

Keyboard shortcuts

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