authorization

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotServiceActor = apperror.Authorization("This operation requires a service actor.")
	ErrNotAdminActor   = apperror.Authorization("This operation requires an admin actor.")

	ErrAuthenticationRequired  = apperror.Authentication("Authentication required.")
	ErrInsufficientTokenScope  = apperror.Authentication("Insufficient token scope.")
	ErrInsufficientPermissions = apperror.Authorization("Insufficient permissions.")
)

Functions

func ContextWithActor

func ContextWithActor(ctx context.Context, a *Actor) context.Context

ContextWithActor returns a new context with the given Actor attached.

Types

type Actor

type Actor struct {
	ID          uuid.UUID
	Type        ActorType
	ClientID    string
	Scopes      []string
	Permissions []string
	IsAdmin     bool
	Locale      string
}

Actor is the authenticated caller's security context passed into use cases. Populated by the interface layer (HTTP, Console, gRPC, etc.) after authentication.

Type distinguishes human users from automated service callers.

Scopes define what the credential is permitted to do. A standard interactive login carries broad default scopes (full access to own resources). A restricted credential carries only explicitly granted scopes.

Permissions define what the actor itself is permitted to do, regardless of the credential. Populated for user actors from the identity provider. Always empty for service actors.

IsAdmin is true when the actor holds the service-wide admin realm role. Locale is the user's preferred locale from the JWT locale claim (e.g. "en-US"). Empty for service actors.

func ActorFromContext

func ActorFromContext(ctx context.Context) *Actor

ActorFromContext retrieves the authenticated Actor from the context, or returns nil if not present.

type ActorType

type ActorType string

ActorType represents the type of the authenticated actor.

const (
	ActorTypeUser    ActorType = "user"
	ActorTypeService ActorType = "service"
)

Jump to

Keyboard shortcuts

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