identity

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessAll          = "All"
	AccessOwner        = "Owner"
	AccessOwnerOrAdmin = "OwnerOrAdmin"
)

Variables

This section is empty.

Functions

func GetUserID

func GetUserID(ctx context.Context) string

func GetUsername

func GetUsername(ctx context.Context) string

GetUsername returns the attached user name, or SYSTEM for internal requests.

func WithUser

func WithUser(ctx context.Context, user *UserInfo) context.Context

WithUser returns a context carrying user identity and task access policy.

Types

type AccessMode

type AccessMode string

Access modes describe which task owners an authenticated user may access.

type UserInfo

type UserInfo struct {
	// Public users are unauthenticated callers, including callers of public endpoints.
	IsPublic bool
	// Administrators are defined by the configuration file:
	// Basic-auth users with Admin set, or usernames listed under OIDC Admins.
	IsAdmin bool
	// Username of an authenticated user (the subject field from a JWT for OIDC).
	Username string
	// OIDC bearer token, used when requesting task input data.
	Token string
	// AccessMode is assigned by server authentication after validating config.
	AccessMode AccessMode
}

UserInfo describes the authenticated caller and the task access policy selected by server configuration.

func GetUser

func GetUser(ctx context.Context) *UserInfo

GetUser returns the user attached to ctx, or the internal SYSTEM identity when no user is attached.

func (*UserInfo) CanSeeAllTasks

func (u *UserInfo) CanSeeAllTasks() bool

CanSeeAllTasks reports whether the user can list all tasks without checking each task's owner.

func (*UserInfo) IsAccessible

func (u *UserInfo) IsAccessible(dataOwner string) bool

IsAccessible reports whether the user can access data owned by dataOwner.

Jump to

Keyboard shortcuts

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