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
- Variables
- type App
- type Client
- func (c *Client) Apps(ctx context.Context, sub string) ([]App, error)
- func (c *Client) Erased(ctx context.Context, since int64) ([]ErasedSubject, int64, error)
- func (c *Client) GroupChanges(ctx context.Context, position, restoreGeneration string, limit int) (GroupPage, error)
- func (c *Client) Groups(ctx context.Context) ([]Group, error)
- func (c *Client) OrgGroups(ctx context.Context, org string) ([]Group, error)
- func (c *Client) Orgs(ctx context.Context, since int64) ([]Org, int64, error)
- func (c *Client) Peer(ctx context.Context, client string) (Peer, error)
- func (c *Client) People(ctx context.Context, sub, q string, limit int) ([]Person, error)
- func (c *Client) ReportStorage(ctx context.Context, reports []StorageReport) ([]StorageResult, error)
- func (c *Client) Resolve(ctx context.Context, sub string, emails []string) ([]Person, error)
- type ErasedSubject
- type Group
- type GroupChange
- type GroupPage
- type Org
- type Peer
- type Person
- type ResyncError
- type StorageReport
- type StorageResult
Constants ¶
const ( GroupActive = "active" GroupArchived = "archived" )
const ( OrgActive = "active" OrgSuspended = "suspended" OrgDeletionScheduled = "deletion_scheduled" OrgDeleted = "deleted" )
Variables ¶
var ( 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") )
var ErrResync = errors.New("suitedir: groups: resync required after a KyIdentity restore")
ErrResync matches a *ResyncError with errors.Is.
var ErrStorageAnswer = errors.New("suitedir: storage: malformed answer")
var ErrStorageRequest = errors.New("suitedir: storage: invalid reports")
Functions ¶
This section is empty.
Types ¶
type 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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) People ¶
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.
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
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 ¶
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.
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.