Files
memos/core/configuration/testdata/compat/unreleased/instance.json
T
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

41 lines
1.3 KiB
JSON

{
"identityProviders": [
{
"name": "identity-providers/company-sso",
"type": "OAUTH2",
"title": "Company SSO",
"config": {
"oauth2Config": {
"clientId": "memos",
"clientSecret": "${env:OIDC_CLIENT_SECRET}",
"authUrl": "https://idp.example.com/oauth/authorize",
"tokenUrl": "https://idp.example.com/oauth/token",
"userInfoUrl": "https://idp.example.com/oauth/userinfo",
"scopes": ["openid", "profile", "email"],
"fieldMapping": { "identifier": "sub", "displayName": "name", "email": "email" }
}
}
}
],
"instanceSettings": [
{ "name": "instance/settings/ACCESS", "accessSetting": { "accessMode": "INSTANCE_ACCESS_MODE_PRIVATE" } },
{
"name": "instance/settings/GENERAL",
"generalSetting": {
"disallowPasswordAuth": true,
"disallowUserRegistration": false,
"customProfile": { "title": "Company Memos" }
}
}
],
"users": [
{ "name": "users/admin", "username": "admin", "role": "ADMIN", "password": "${file:/run/secrets/memos-admin-password}" }
],
"linkedIdentities": [
{ "name": "users/admin/linkedIdentities/company-sso", "externalUid": "${env:ADMIN_SSO_SUBJECT}" }
],
"lifecycle": [
{ "resource": "users/admin", "preventDestroy": true, "writeOnlyVersion": 1 }
]
}