suitedir

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 14 Imported by: 1 module, 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 suitedir is the client for KyIdentity's suite directory: which suite apps a user may open, the organisation's people for a picker, its suite groups (per org, or changed across orgs, on a multi-tenant KyIdentity), the URL and shared syncauth secret of a paired app, and, on a multi-tenant KyIdentity, its organisations and erased subjects, plus storage usage reports and reserved grants. Server to server, with the calling app's own OAuth client credentials (client_secret_basic). Contract: KyIdentity-server docs/SUITE-DIRECTORY.md.

Index

Constants

View Source
const (
	GroupActive   = "active"
	GroupArchived = "archived"
)
View Source
const (
	OrgActive            = "active"
	OrgSuspended         = "suspended"
	OrgDeletionScheduled = "deletion_scheduled"
	OrgDeleted           = "deleted"
)

Variables

View Source
var (
	// ErrUnauthorized is a 401: KyIdentity refused the client credentials.
	ErrUnauthorized = errors.New("suitedir: client credentials refused")
	// ErrNoPeer is a 404 no_peer: the pair is unknown, or the peer is disabled or has no
	// HTTPS origin. Fall back to the app's own configuration.
	ErrNoPeer = errors.New("suitedir: no peer")
	// ErrInsecureIssuer is an issuer that is not HTTPS (loopback http excepted).
	ErrInsecureIssuer = errors.New("suitedir: issuer must be https")
)
View Source
var ErrResync = errors.New("suitedir: groups: resync required after a KyIdentity restore")

ErrResync matches a *ResyncError with errors.Is.

View Source
var ErrStorageAnswer = errors.New("suitedir: storage: malformed answer")
View Source
var ErrStorageRequest = errors.New("suitedir: storage: invalid reports")

Functions

This section is empty.

Types

type App

type App struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	URL  string `json:"url"`
}

App is one launchable suite app. ID is its OAuth client ID.

type Client

type Client struct {
	Issuer       string
	ClientID     string
	ClientSecret string
	HTTP         *http.Client
}

Client calls one KyIdentity. A nil HTTP is a ten-second client; products with an outbound policy pass their own. Redirects are refused whatever client is passed.

func (*Client) Apps

func (c *Client) Apps(ctx context.Context, sub string) ([]App, error)

Apps lists the apps sub may open; an empty sub lists every launchable app. Entries without an id, a name or an HTTPS URL are dropped.

func (*Client) Erased

func (c *Client) Erased(ctx context.Context, since int64) ([]ErasedSubject, int64, error)

Erased lists erasures after since on a multi-tenant KyIdentity, in revision order. It follows up to 100 pages and returns the last revision read, or since for an empty result. On any error it returns nil and the original since. Save the revision only after applying the notices. After a restore, start at zero and read until empty.

func (*Client) GroupChanges added in v0.13.0

func (c *Client) GroupChanges(ctx context.Context, position, restoreGeneration string, limit int) (GroupPage, error)

GroupChanges lists one page of the calling app's suite groups that changed after position ("" for all), across every org Orgs lists, in revision order, on a multi-tenant KyIdentity (a single-tenant one answers 404). limit is 1 to 500, or 0 for 500. Any malformed entry fails the whole page, so a stored position never passes a group the app did not apply. Archived groups carry no members; apply them, never act on absence.

func (*Client) Groups

func (c *Client) Groups(ctx context.Context) ([]Group, error)

Groups lists the suite groups for the calling app. Malformed entries are dropped, so an app must archive only on an explicit GroupArchived, never on absence.

func (*Client) OrgGroups

func (c *Client) OrgGroups(ctx context.Context, org string) ([]Group, error)

OrgGroups lists org's suite groups on a multi-tenant KyIdentity, as Groups does. An org not listed by Orgs is an error (404 unknown_org).

func (*Client) Orgs

func (c *Client) Orgs(ctx context.Context, since int64) ([]Org, int64, error)

Orgs lists the orgs that changed after revision since (0 for all), following pages, in revision order. It returns the revision to pass next time: the last one listed, or since when nothing changed. A call cut short at its page bound returns one less than the last revision, so orgs sharing that revision on a later page are not skipped; the next call lists the ones already seen again, which an app applies as the same state. Any malformed entry fails the whole call, so an app never skips past an org it did not apply. Multi-tenant installs only; a single-tenant one answers 404.

func (*Client) Peer

func (c *Client) Peer(ctx context.Context, client string) (Peer, error)

Peer fetches the connection details for the paired app client.

func (*Client) People

func (c *Client) People(ctx context.Context, sub, q string, limit int) ([]Person, error)

People searches the people the user sub may see from this app: q is 2 to 64 characters, limit 1 to 20 or 0 for KyIdentity's default of 10. Entries without a sub or email are dropped.

func (*Client) ReportStorage

func (c *Client) ReportStorage(ctx context.Context, reports []StorageReport) ([]StorageResult, error)

ReportStorage validates the entire request and answer, returning no partial result on any malformed/missing/duplicate entry. It makes one bounded, authenticated POST without redirects or automatic retry. The caller owns batching, durable sequence/usage snapshots, retries with the same sequence and bytes, local grant admission, and renewal scheduling.

func (*Client) Resolve

func (c *Client) Resolve(ctx context.Context, sub string, emails []string) ([]Person, error)

Resolve maps 1 to 100 email addresses to people; unmatched addresses are absent. No addresses is an empty answer without a request.

type ErasedSubject

type ErasedSubject struct {
	Sub      string `json:"sub"`
	OrgID    string `json:"org_id"`
	Revision int64  `json:"revision"`
}

ErasedSubject identifies an erased KyIdentity account. The notice outlives the account.

type Group

type Group struct {
	ID      string   `json:"id"`
	Name    string   `json:"name"`
	Slug    string   `json:"slug"`
	State   string   `json:"state"`
	Members []string `json:"members"`
}

Group is a suite group (KyIdentity docs/SUITE-DIRECTORY.md). Match resources on ID only. State is GroupActive, with Members the subjects to grant the ordinary member role, or GroupArchived: make the resource read-only with no members, and keep it.

type GroupChange added in v0.13.0

type GroupChange struct {
	OrgID string `json:"org_id"`
	Group
	Revision int64 `json:"revision"`
}

GroupChange is a suite group of one org, as GroupChanges lists it: a full snapshot of the entry Groups would give, and the install-wide revision of its last change.

type GroupPage added in v0.13.0

type GroupPage struct {
	Groups []GroupChange
	// Position is where the next call starts: store it only once every group of this page
	// is applied. It is the position asked for when the page is empty.
	Position string
	// More is a full page: call again from Position now.
	More bool
	// RestoreGeneration is "" until KyIdentity is restored. Pass it with every later call.
	RestoreGeneration string
}

GroupPage is one page of GroupChanges.

type Org

type Org struct {
	ID         string          `json:"id"`
	Status     string          `json:"status"`
	Revision   int64           `json:"revision"`
	HomeRegion string          `json:"home_region"`
	Enabled    bool            `json:"enabled"`
	Quotas     json.RawMessage `json:"quotas"`
}

Org is an organisation of a multi-tenant KyIdentity, as /api/suite/orgs lists it to the calling app. Enabled and Quotas (an opaque JSON object) are that app's only. Stop serving an org whose Status is not OrgActive; drop its data only at OrgDeleted. HomeRegion is the region every multi-region app keeps the org in; it never changes. It is "" from a KyIdentity older than home regions, which no regioned peer serves (Peer.URLFor).

type Peer

type Peer struct {
	Client  string
	URL     string
	Secret  []byte
	Regions map[string]string
}

Peer is a paired suite app. Secret is the pair's 32-byte syncauth key. Regions, from a multi-tenant KyIdentity, maps home regions to the origin serving each; use URLFor.

func (Peer) URLFor

func (p Peer) URLFor(region string) (string, bool)

URLFor is where to reach the peer for an org homed in region (Org.HomeRegion). A peer without Regions is its one URL; with Regions, only the region's own entry, and false when it has none: never URL, which serves another region.

type Person

type Person struct {
	Sub   string `json:"sub"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

Person is a member of the organisation who may open the calling app. Sub is their KyIdentity subject.

type ResyncError added in v0.13.0

type ResyncError struct{ Generation string }

ResyncError is a 409 org_resync_required: KyIdentity was restored after the position was taken. Reapply every group from position "" with Generation, as after Orgs' reset.

func (*ResyncError) Error added in v0.13.0

func (e *ResyncError) Error() string

func (*ResyncError) Is added in v0.13.0

func (e *ResyncError) Is(target error) bool

type StorageReport

type StorageReport struct {
	OrgID     string `json:"org_id"`
	UsedBytes int64  `json:"used_bytes"`
	Seq       int64  `json:"seq"`
	WantBytes int64  `json:"want_bytes"`
}

StorageReport is one app's actual committed usage and requested additional reservation. Seq is a strictly increasing value from the app's shared DB, never a replica clock. Contract: KyIdentity's POST /api/suite/storage, docs/SUITE-DIRECTORY.md.

type StorageResult

type StorageResult struct {
	OrgID                                                  string
	Result                                                 string // ok, stale, unknown_org
	Seq, CeilingBytes, TTLSeconds, PoolBytes, OrgUsedBytes int64
	OverSince                                              *int64
}

StorageResult answers exactly one report. Unknown orgs carry no grant. On stale, the app retains its existing grant until expiry and needs operator sequence recovery. Grant expiry starts when the app sent the request, never at response arrival.

Jump to

Keyboard shortcuts

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