Files
memos/core
boojack e52a507924 feat(config): declare linked identities for bootstrap administrators
A configuration file may now declare which identity-provider subject signs
in as a declared user, as a fourth resource kind:

  "linkedIdentities": [
    { "name": "users/admin/linkedIdentities/sso", "externalUid": "subject" }
  ]

An administrator on an SSO-only instance otherwise has no way in before the
first sign-in, which provisions a new account because the sign-in path
matches a provider and subject and nothing else. Matching an email or
username claim was rejected: neither proves ownership on this instance. A
declared subject trusts no claim, and the sign-in path is unchanged.

Rules: the user must be declared in the same configuration, a subject is
declared once, the provider must exist after apply, and a subject already
linked to a different user fails the plan rather than being taken over. A
link made by signing in with the declared subject is adopted; a different
stored subject is replaced. Links are written after users in the apply
transaction. A declared user with a declared link may be created without a
password; it gets an unusable random one, as SSO provisioning does.

The API refuses to create or delete a managed link, and to delete a
provider a declared link names. The account page hides Unlink for a
declared link. LinkedIdentity.external_uid is no longer output only.
2026-10-31 13:33:36 +08:00
..
2026-09-17 23:28:19 +08:00

core

Business rules that do not care about HTTP or SQL. A package lands here when it needs several store calls, or a decision, that more than one transport must apply the same way.

Package Owns
access/ who may read a memo, given viewer, space membership, and share links
notification/ building and dispatching inbox and email notifications
memopayload/ rebuilding a memo's derived payload from its markdown
memoexport/ the Memos Export Format container and records used for export and import
usagelimit/ which usage limits apply to a user, and whether memo counts, memo content, and uploads stay within them
identityprovider/ the rules an identity provider must meet before it is stored, and its API↔store conversion
instancesetting/ the rules each instance setting group must meet before it is stored, AI setting normalization, and the API↔store conversion
user/ the rules a username and password must meet before they are stored
configuration/ declarative configuration: reading files (substitution, strict decoding, schema checks, merging), planning and applying them against the instance, and the API ownership guard

The three validation packages check the complete value as it will be stored. identityprovider and instancesetting also convert between API and store messages, because declarative configuration files are API messages; their FromStore keeps secrets, and API responses redact them in server/api. A write path's own conveniences, such as the API treating an empty secret as "keep the stored one", run before validation, never inside it.

Layering: core may import store, provider, markdown, filter, proto/gen, and internal. It must not import server or cmd. New resource-specific rules extracted from server/api belong here, one package per resource.