identity

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package identity bridges kernel.Principal to the v0 int-ID, single-role model during the Phase 2 transition. Services resolving acting identity parse through here so the "invalid user ID" failure stays in one place. Phase 3 modules own their ID shapes; new code must prefer Principal fields over these helpers.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidUserID = kernel.ErrInvalidPrincipalID

ErrInvalidUserID is returned when a principal carries a non-decimal ID. Handlers map it to the same 400 invalid_user_id response the pre-Phase-2 handler-side parse produced. It aliases the kernel sentinel so module services (which cannot import this package) map through the same value.

Functions

func IntID

func IntID(principal kernel.Principal) (int, error)

IntID parses the principal's decimal ID for repository calls.

func New

func New(
	userID int,
	username string,
	role string,
) kernel.Principal

New builds a principal from v0 int-ID parts. Importers and tests use it to construct the acting identity they already hold as parts.

func PrimaryRole

func PrimaryRole(principal kernel.Principal) string

PrimaryRole returns the principal's first role, or "" when anonymous. v0 roles are single-valued; multi-role resolution belongs to the users module (Phase 3).

Types

This section is empty.

Jump to

Keyboard shortcuts

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