peopleapi

package
v1.171.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 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

Overview

Package peopleapi is the admin REST surface for people (#2269, #2882, #2883): Admin > Users and a person's page. It lists people with the personas they hold and where those come from, adds a person before their first sign-in, assigns personas in the platform or returns a person to their identity provider roles, sets and clears No access, and adds, removes and makes primary the addresses that sign in as a person. Every change is recorded in the audit log.

Index

Constants

View Source
const (
	WhyDenies     = "denies"
	WhyNotAllowed = "not_allowed"
)

Why a persona held does not grant something.

View Source
const (
	SourceAssigned = "assigned"
	SourceIDP      = "identity_provider"
	SourceNoAccess = "no_access"
)

Where a person's personas come from.

View Source
const (
	FilterAll         = "all"
	FilterAssigned    = "assigned"
	FilterIDP         = "identity_provider"
	FilterNotSignedIn = "not_signed_in"
	FilterNoAccess    = "no_access"
)

List filters.

Variables

This section is empty.

Functions

func Register

func Register(mux *http.ServeMux, wrap func(http.Handler) http.Handler, cfg Config)

Register mounts the people routes, each behind wrap, the admin API's authentication.

func RegisterSelf

func RegisterSelf(mux *http.ServeMux, cfg SelfConfig)

RegisterSelf mounts the signed-in person's own routes on the portal's authenticated mux.

Types

type AccessReport

type AccessReport struct {
	Email       string       `json:"email"`
	Personas    []PersonaRef `json:"personas"`
	Combined    bool         `json:"combined"`
	Tools       []AccessRow  `json:"tools"`
	Connections []AccessRow  `json:"connections"`
	Portal      []PortalRow  `json:"portal"`
	Split       *Split       `json:"split,omitempty"`
}

AccessReport is a person's access and which persona grants it.

type AccessRow

type AccessRow struct {
	Name      string       `json:"name"`
	GrantedBy []string     `json:"granted_by"`
	Rule      string       `json:"rule,omitempty"`
	Not       []NotGranted `json:"not_granted"`
}

AccessRow is one tool or connection and the personas that grant it.

type AddPersonInput

type AddPersonInput struct {
	Email     string   `json:"email"`
	FirstName string   `json:"first_name"`
	LastName  string   `json:"last_name"`
	Personas  []string `json:"personas"`
}

AddPersonInput adds a person before their first sign-in.

type AddressInput

type AddressInput struct {
	Address string `json:"address"`
}

AddressInput names an address.

type Change

type Change struct {
	Email    string   `json:"email"`
	Name     string   `json:"name"`
	Personas []string `json:"personas"`
	// GainsConnections are connections they would reach and do not now;
	// LosesConnections the reverse. The tool counts are the same for tools.
	GainsConnections []string `json:"gains_connections"`
	LosesConnections []string `json:"loses_connections"`
	GainsTools       int      `json:"gains_tools"`
	LosesTools       int      `json:"loses_tools"`
}

Change is one person whose access a switch would change.

type Config

type Config struct {
	// Service carries out the changes. nil mounts nothing.
	Service *people.Service
	// Author resolves the acting administrator's address.
	Author func(*http.Request) string
	// Audit records each change; nil records nothing.
	Audit middleware.AuditLogger
	// Notify tells a person an address was added to their account; nil
	// sends nothing.
	Notify func(r *http.Request, primary, address, by string)
	// Access reads what the deployment serves, for a person's access.
	Access Inventory
	// Settings reads and writes personas.combine; nil serves no settings.
	Settings SettingsStore
	// Now is the clock; nil is time.Now.
	Now func() time.Time
}

Config carries the service and the parent-owned helpers.

type Counts

type Counts struct {
	All         int `json:"all"`
	Assigned    int `json:"assigned"`
	IDP         int `json:"identity_provider"`
	NotSignedIn int `json:"not_signed_in"`
	NoAccess    int `json:"no_access"`
}

Counts are the people each filter holds.

type HeldWithAs

type HeldWithAs struct {
	Email string   `json:"email"`
	Also  []string `json:"also"`
}

HeldWithAs is a person holding the persona together with others.

type Inventory

type Inventory struct {
	// Tools are the registered tool names.
	Tools func() []string
	// Connections are the connection names.
	Connections func(ctx context.Context) []string
}

Inventory is what the deployment serves, read when a person's access is.

type NoAccess

type NoAccess struct {
	By string     `json:"by"`
	At *time.Time `json:"at,omitempty"`
}

NoAccess says who set No access and when.

type NotGranted

type NotGranted struct {
	Persona string `json:"persona"`
	Why     string `json:"why" enums:"denies,not_allowed"`
	Rule    string `json:"rule,omitempty"`
}

NotGranted says why one persona held does not grant a row.

type NotifyInput

type NotifyInput struct {
	Address string `json:"address"`
}

NotifyInput chooses where notifications go.

type PeopleList

type PeopleList struct {
	People  []PersonRow `json:"people"`
	Total   int         `json:"total"`
	Counts  Counts      `json:"counts"`
	Combine string      `json:"combine" enums:"priority,all"`
}

PeopleList is the list response.

type PersonDetail

type PersonDetail struct {
	PersonRow
	// Addresses are the aliases with when each was added and signed in.
	Addresses []people.Address `json:"addresses"`
	// NotifyTo is where the person's notifications go.
	NotifyTo string `json:"notify_to"`
	// RoleGrants say which identity provider role gave which persona at the
	// last sign-in.
	RoleGrants []RoleGrant `json:"role_grants"`
	// The personas the person would hold from their identity provider roles:
	// what returning them to those roles gives.
	FromIDP []PersonaRef `json:"identity_provider_personas"`
}

PersonDetail is a person's page.

type PersonRow

type PersonRow struct {
	Email     string       `json:"email" example:"dana@example.com"`
	Primary   string       `json:"primary_email" example:"dana@example.com"`
	FirstName string       `json:"first_name"`
	LastName  string       `json:"last_name"`
	Aliases   []string     `json:"aliases"`
	Personas  []PersonaRef `json:"personas"`
	// Source is assigned, identity_provider or no_access.
	Source     string     `json:"source" enums:"assigned,identity_provider,no_access"`
	Roles      []string   `json:"identity_provider_roles"`
	SignedIn   bool       `json:"signed_in"`
	LastSeenAt *time.Time `json:"last_seen_at,omitempty"`
	NoAccess   *NoAccess  `json:"no_access,omitempty"`
}

PersonRow is one person in Admin > Users.

type PersonaInput

type PersonaInput struct {
	Personas []string `json:"personas"`
}

PersonaInput assigns personas.

type PersonaPeople

type PersonaPeople struct {
	Persona  string   `json:"persona"`
	Assigned []string `json:"assigned"`
	// Roles are the identity provider roles that give the persona, and
	// SignedInWith how many people's roles at their last sign-in did.
	Roles        []string     `json:"roles"`
	SignedInWith int          `json:"signed_in_with"`
	HeldWith     []HeldWithAs `json:"held_with"`
}

PersonaPeople is who holds one persona.

type PersonaRef

type PersonaRef struct {
	Name        string `json:"name" example:"sales"`
	DisplayName string `json:"display_name" example:"Sales"`
	External    bool   `json:"external,omitempty"`
}

PersonaRef is a persona as a list shows it.

type PersonasSettings

type PersonasSettings struct {
	// Combine is the mode applied now.
	Combine   string     `json:"combine" enums:"priority,all"`
	UpdatedBy string     `json:"updated_by,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

PersonasSettings is Admin > Settings > Personas.

type PortalRow

type PortalRow struct {
	Area      string   `json:"area"`
	Level     string   `json:"level"`
	GrantedBy []string `json:"granted_by"`
}

PortalRow is one portal area, its level and the personas giving it.

type Preview

type Preview struct {
	Combine string   `json:"combine"`
	Changes []Change `json:"changes"`
}

Preview is who a switch to Combine would change, from the roles recorded at each person's last sign-in.

type Refused

type Refused struct {
	httpjson.ProblemDetail
	Code string       `json:"code"`
	Seen *people.Seen `json:"seen,omitempty"`
}

Refused is a refusal's body: the rule, its sentence, and for an address refused what the platform found.

type RoleGrant

type RoleGrant struct {
	Role    string `json:"role"`
	Persona string `json:"persona,omitempty"`
}

RoleGrant is one identity provider role and the persona it gives.

type Self

type Self struct {
	Email    string       `json:"email"`
	Primary  string       `json:"primary_email"`
	Personas []PersonaRef `json:"personas"`
	// Source is assigned or identity_provider.
	Source    string           `json:"source" enums:"assigned,identity_provider"`
	Addresses []people.Address `json:"addresses"`
	NotifyTo  string           `json:"notify_to"`
}

Self is a signed-in person's own account: what the account menu and Settings > Your addresses show.

type SelfConfig

type SelfConfig struct {
	Service *people.Service
	// Caller is the signed-in person's record address and roles; empty when
	// nobody is signed in.
	Caller func(*http.Request) (email string, roles []string)
}

SelfConfig carries what the self routes read.

type SettingsInput

type SettingsInput struct {
	Combine string `json:"combine" enums:"priority,all"`
}

SettingsInput changes personas.combine.

type SettingsStore

type SettingsStore interface {
	// Get returns the saved mode, who saved it and when; an empty Combine
	// when it was never saved.
	Get(ctx context.Context) (PersonasSettings, error)
	Set(ctx context.Context, mode, by string) error
}

SettingsStore reads and writes the personas settings section.

type Split

type Split struct {
	Tool           string `json:"tool"`
	Connection     string `json:"connection"`
	ToolFrom       string `json:"tool_from"`
	ConnectionFrom string `json:"connection_from"`
}

Split is a call no persona allows although the person holds the tool and the connection, each through a different persona.

Jump to

Keyboard shortcuts

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