feat(iam): role groups and profile sync for Nextcloud, OpenCloud, Gitea, GitLab and Mattermost

- nextcloud: user_ldap maps phone, address, website, organisation, role, biography, quota and avatar; admin rights from the administrator role group
- opencloud: oidc role assignment from realm roles with a catch-all user mapping, default user role off, display name from the directory
- gitea: OIDC group, admin and restricted groups, LDAP restricted filter and avatar attribute
- gitlab: profile synced from the provider, deploy-time admin and external reconcile with unit tests
- mattermost: deploy-time system admin reconcile through a tested plan filter

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-24 18:35:55 +02:00
1 parent 42833ba973
commit 5f152d9f28
52 files changed
+1390 -70

No files matched your search

+2
View File
@@ -15,6 +15,8 @@ This role deploys Gitea using Docker. It automates the setup and update processe
- **Automated Updates & Re-creation:** Simplify maintenance with automated update and container recreation procedures.
- **Built-in Database Access:** Seamlessly interact with the underlying MariaDB for your Git service.
- **Integrated Configuration:** Easily manage settings via environment variables and Docker Compose templates.
- **Role Mapping:** Every realm user signs in as a regular Gitea user. Members of the `administrator` role group become Gitea administrators and members of the `restricted` role group become restricted users at each sign-in, through the LDAP admin and restricted filters and through the admin and restricted groups of the OIDC source, which reads the groups claim.
- **Directory Profile:** The LDAP source syncs name, mail, SSH keys and the `jpegPhoto` avatar, and accounts from LDAP or OIDC cannot change their username or full name or delete themselves in Gitea.
- **MCP server contract:** Declares the `/mcp` path over streamable HTTP as an internal, bearer-token-authenticated endpoint served by the `svc-ai-mcp-adapter` instance running as compose service `giteamcp`. The adapter listens on container port `8080` and is never published to a host port or fronted by the public reverse proxy; clients reach it as `http://giteamcp:8080/mcp` on the container network. It is off by default and switches on only where Hermes Agent or OpenClaw is part of the deployment.
- **Adapter in front of the sidecar:** The `gitea-mcp` sidecar runs as compose service `giteamcpupstream` on the role's own network only, so nothing but the adapter reaches it. It answers `initialize` and `tools/list` to any caller because it holds no credential of its own and expects each client to supply a Gitea token per request, which makes it unsafe to expose directly. The adapter is what authenticates: a client presents the `mcp_bearer` credential and is refused with 401 otherwise, and the adapter presents the minted Gitea token upstream via `ADAPTER_UPSTREAM_KEY`.
- **Administrator-issued token:** The role mints a Gitea personal access token named `gitea-mcp` for the `administrator` account with the read-only scope set `read:repository,read:issue,read:user,read:organization,read:notification`, and persists it in the token store MCP clients read. Every deploy asks the API whether the stored token still authenticates, revokes the stale entry under that name, and re-mints when the API rejects it. The deploy fails if the fresh token is rejected too.
+6
View File
@@ -0,0 +1,6 @@
# TODO
- No Playwright scenario proves the OIDC source's group claim, admin group, restricted group or `GITEA__oauth2_client__USERNAME`: an OIDC sign-in of a directory account ends on Gitea's account-link page (`ACCOUNT_LINKING=login`, the LDAP sync created the account first), so no persona reaches a signed-in surface through OIDC. Options: a scenario that completes the link page with the LDAP credentials once and then signs in through the OIDC button.
- No Playwright scenario proves `GITEA__admin__EXTERNAL_USER_DISABLE_FEATURES`: Gitea enforces it on the settings pages only, not on `PATCH /api/v1/user/settings` (read from `routers/api/v1/user/settings.go`), and the UI sign-in is blocked for the personas. Options: the same link-and-sign-in scenario, asserting the disabled full-name field on `/user/settings`.
- No Playwright scenario proves that the LDAP bind password stays out of the deploy log and the process list of the node: `tasks/setup/ldap.yml` now hands it to `gitea admin auth add-ldap` and `update-ldap` through the environment, and a browser cannot observe either surface. Options: a role-local integration test that renders `GITEA_LDAP_AUTH_ARGS` and asserts the credential is absent.
- No Playwright scenario proves the LDAP avatar: no persona carries `jpegPhoto`, and Gitea uploads the LDAP avatar only when it creates the account or syncs it. Options: seed `jpegPhoto` on `biber` in the directory fixture and assert a non-default `avatar_url`.
@@ -19,3 +19,4 @@ require("./test-mcp-guest").register(shared);
require("./test-guest-persona").register(shared);
require("./test-biber-persona").register(shared);
require("./test-administrator-persona").register(shared);
require("./test-rbac-ldap").register(shared);
@@ -0,0 +1,129 @@
const { test, expect } = require("@playwright/test");
const { resolveTimeout } = require("./timeouts");
const {
decodeDotenvQuotedValue,
keycloakAdminAddUserToGroup,
keycloakRemoveUserFromGroupViaRest,
normalizeBaseUrl,
} = require("./personas");
const { skipUnlessServiceEnabled } = require("./service-gating");
const env = {
biberUsername: decodeDotenvQuotedValue(process.env.BIBER_USERNAME),
biberPassword: decodeDotenvQuotedValue(process.env.BIBER_PASSWORD),
keycloakBaseUrl: normalizeBaseUrl(decodeDotenvQuotedValue(process.env.KEYCLOAK_BASE_URL) || ""),
realmName: decodeDotenvQuotedValue(process.env.KEYCLOAK_REALM_NAME),
adminRealm: decodeDotenvQuotedValue(process.env.KEYCLOAK_ADMIN_REALM),
adminClientId: decodeDotenvQuotedValue(process.env.KEYCLOAK_ADMIN_CLI_CLIENT_ID),
superAdminUsername: decodeDotenvQuotedValue(process.env.SUPER_ADMIN_USERNAME),
superAdminPassword: decodeDotenvQuotedValue(process.env.SUPER_ADMIN_PASSWORD),
administratorGroupPath: decodeDotenvQuotedValue(process.env.RBAC_ADMINISTRATOR_GROUP_PATH),
restrictedGroupPath: decodeDotenvQuotedValue(process.env.RBAC_RESTRICTED_GROUP_PATH),
};
async function signInAsBiber(request, shared) {
const credentials = Buffer.from(`${env.biberUsername}:${env.biberPassword}`).toString("base64");
const response = await request.get(`${shared.env.gitEaBaseUrl.replace(/\/$/, "")}/api/v1/user`, {
headers: { Authorization: `Basic ${credentials}`, Accept: "application/json" },
timeout: resolveTimeout(30_000),
});
const body = await response.text();
expect(response.ok(), `biber must sign in to Gitea through the LDAP source, got ${response.status()}: ${body.slice(0, 300)}`).toBe(true);
return JSON.parse(body);
}
async function withBiberInGroup(browser, groupPath, body) {
const adminOpts = { adminRealm: env.adminRealm, adminClientId: env.adminClientId };
const context = await browser.newContext({ ignoreHTTPSErrors: true });
let joined = false;
try {
joined = await keycloakAdminAddUserToGroup(
context.request,
env.keycloakBaseUrl,
env.realmName,
groupPath,
env.biberUsername,
env.superAdminUsername,
env.superAdminPassword,
adminOpts,
);
await body(context.request);
} finally {
if (joined) {
await keycloakRemoveUserFromGroupViaRest(
context.request,
env.keycloakBaseUrl,
env.realmName,
env.superAdminUsername,
env.superAdminPassword,
groupPath,
env.biberUsername,
adminOpts,
).catch((err) => console.warn(`Cleanup removal of biber from ${groupPath} failed: ${err}`));
}
await context.close().catch(() => {});
}
}
exports.register = function (shared) {
test("rbac: biber without a Gitea role signs in as a regular Gitea user", async ({ browser }) => {
skipUnlessServiceEnabled("ldap");
const context = await browser.newContext({ ignoreHTTPSErrors: true });
try {
const self = await signInAsBiber(context.request, shared);
expect(self.login, "the LDAP source must resolve biber's own account").toBe(env.biberUsername);
expect(self.is_admin, "a realm user outside the administrator role group must not be a Gitea administrator").toBe(false);
expect(self.restricted, "a realm user outside the restricted role group must not be restricted").toBe(false);
} finally {
await context.close().catch(() => {});
}
});
test("rbac: membership in the administrator group makes biber a Gitea administrator", async ({ browser }) => {
skipUnlessServiceEnabled("sso");
skipUnlessServiceEnabled("ldap");
await withBiberInGroup(browser, env.administratorGroupPath, async (request) => {
await expect
.poll(async () => (await signInAsBiber(request, shared)).is_admin, {
timeout: resolveTimeout(60_000),
message: `biber in ${env.administratorGroupPath} must become a Gitea administrator at the next sign-in`,
})
.toBe(true);
});
const context = await browser.newContext({ ignoreHTTPSErrors: true });
try {
await expect
.poll(async () => (await signInAsBiber(context.request, shared)).is_admin, {
timeout: resolveTimeout(60_000),
message: "leaving the administrator role group must revoke the Gitea administrator flag at the next sign-in",
})
.toBe(false);
} finally {
await context.close().catch(() => {});
}
});
test("rbac: membership in the restricted group makes biber a restricted Gitea user", async ({ browser }) => {
skipUnlessServiceEnabled("sso");
skipUnlessServiceEnabled("ldap");
await withBiberInGroup(browser, env.restrictedGroupPath, async (request) => {
await expect
.poll(async () => (await signInAsBiber(request, shared)).restricted, {
timeout: resolveTimeout(60_000),
message: `biber in ${env.restrictedGroupPath} must become a restricted Gitea user at the next sign-in`,
})
.toBe(true);
});
const context = await browser.newContext({ ignoreHTTPSErrors: true });
try {
await expect
.poll(async () => (await signInAsBiber(context.request, shared)).restricted, {
timeout: resolveTimeout(60_000),
message: "leaving the restricted role group must lift the restriction at the next sign-in",
})
.toBe(false);
} finally {
await context.close().catch(() => {});
}
});
};
+2
View File
@@ -2,3 +2,5 @@
roles:
mcp:
description: Can drive this application through an MCP client, which acts with the credentials the deployment issued rather than the caller's own
restricted:
description: Signs in as a restricted Gitea user who sees only the organizations and repositories shared with them explicitly
+12 -7
View File
@@ -1,9 +1,12 @@
---
- name: "➕ Add LDAP Authentication Source"
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec -i --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} \
gitea admin auth add-ldap \
{{ GITEA_LDAP_AUTH_ARGS | join(' ') }}
container exec -i -e GITEA_LDAP_BIND_PASSWORD --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} sh -lc '
gitea admin auth add-ldap {{ GITEA_LDAP_AUTH_ARGS | join(' ') }}
'
environment:
GITEA_LDAP_BIND_PASSWORD: "{{ LDAP.BIND_CREDENTIAL }}"
delegate_to: "{{ GITEA_HOST_NODE }}"
register: ldap_manage
failed_when: ldap_manage.rc != 0 and not (ldap_manage.stderr | gitea_auth_noop)
@@ -27,11 +30,13 @@
ldap_source_id: "{{ ldap_source_id_raw.stdout }}"
- name: "🔄 Update LDAP Authentication Source"
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec -i --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} \
gitea admin auth update-ldap \
--id {{ ldap_source_id }} \
{{ GITEA_LDAP_AUTH_ARGS | join(' ') }}
container exec -i -e GITEA_LDAP_BIND_PASSWORD --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} sh -lc '
gitea admin auth update-ldap --id {{ ldap_source_id }} {{ GITEA_LDAP_AUTH_ARGS | join(' ') }}
'
environment:
GITEA_LDAP_BIND_PASSWORD: "{{ LDAP.BIND_CREDENTIAL }}"
delegate_to: "{{ GITEA_HOST_NODE }}"
register: ldap_manage
failed_when: ldap_manage.rc != 0
+2 -15
View File
@@ -3,13 +3,7 @@
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec -i -e GITEA_OIDC_CLIENT_SECRET --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} sh -lc '
gitea admin auth add-oauth \
--provider openidConnect \
--name "{{ OIDC.BUTTON_TEXT }}" \
--key "{{ OIDC.CLIENT.ID }}" \
--secret "$GITEA_OIDC_CLIENT_SECRET" \
--auto-discover-url "{{ OIDC.CLIENT.DISCOVERY_DOCUMENT }}" \
--scopes "openid profile email"
gitea admin auth add-oauth {{ GITEA_OIDC_AUTH_ARGS | join(' ') }}
'
environment:
GITEA_OIDC_CLIENT_SECRET: "{{ OIDC.CLIENT.SECRET }}"
@@ -39,14 +33,7 @@
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
container exec -i -e GITEA_OIDC_CLIENT_SECRET --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} sh -lc '
gitea admin auth update-oauth \
--id {{ oidc_source_id }}\
--provider openidConnect \
--name "{{ OIDC.BUTTON_TEXT }}" \
--key "{{ OIDC.CLIENT.ID }}" \
--secret "$GITEA_OIDC_CLIENT_SECRET" \
--auto-discover-url "{{ OIDC.CLIENT.DISCOVERY_DOCUMENT }}" \
--scopes "openid profile email"
gitea admin auth update-oauth --id {{ oidc_source_id }} {{ GITEA_OIDC_AUTH_ARGS | join(' ') }}
'
environment:
GITEA_OIDC_CLIENT_SECRET: "{{ OIDC.CLIENT.SECRET }}"
+6 -1
View File
@@ -80,9 +80,14 @@ GITEA__ui__DEFAULT_THEME={{ GITEA_THEMES.auto if GITEA_DESIGN_ENABLED | bool els
GITEA__openid__ENABLE_OPENID_SIGNUP={{ GITEA_OIDC_ENABLED | lower }}
GITEA__openid__ENABLE_OPENID_SIGNIN={{ GITEA_OIDC_ENABLED | lower }}
{% if GITEA_OIDC_ENABLED | bool %}
# nocheck: oidc-claim-name-spot Gitea's USERNAME accepts only the fixed keywords userid, nickname, email and preferred_username, not a configurable claim name
GITEA__oauth2_client__USERNAME=preferred_username
{% endif %}
{% if GITEA_IAM_ENABLED | bool %}
EXTERNAL_USER_DISABLE_FEATURES=deletion,manage_credentials,change_username,change_full_name
GITEA__admin__EXTERNAL_USER_DISABLE_FEATURES=deletion,manage_credentials,change_username,change_full_name
{% if ( GITEA_LDAP_ENABLED | bool ) %}
GITEA__ldap__SYNC_USER_ON_LOGIN=true
@@ -31,7 +31,14 @@ GITEA_THEME_LIGHT={{ GITEA_THEMES.light | dotenv_quote }}
GITEA_VERSION={{ lookup('config', application_id, 'services.gitea.version') | dotenv_quote }}
# nocheck: playwright-service-gate — persona drives the OIDC path; LDAP federation is exercised in the LDAP-only matrix variant
KEYCLOAK_ADMIN_CLI_CLIENT_ID={{ OIDC.ADMIN.CLI_CLIENT_ID | dotenv_quote }}
KEYCLOAK_ADMIN_REALM={{ OIDC.ADMIN.REALM | dotenv_quote }}
KEYCLOAK_BASE_URL={{ OIDC.URL | dotenv_quote }}
KEYCLOAK_REALM_NAME={{ OIDC.CLIENT.REALM | dotenv_quote }}
LDAP_SERVICE_ENABLED={{ lookup('config', application_id, 'services.ldap.enabled') | string | lower }}
LOGOUT_SERVICE_ENABLED={{ lookup('config', application_id, 'services.logout.enabled') | string | lower }}
@@ -48,6 +55,13 @@ PERSONA_ADMINISTRATOR_BLOCKED=true
# nocheck: persona-block-rationale — see PERSONA_ADMINISTRATOR_BLOCKED above.
PERSONA_BIBER_BLOCKED=true
# nocheck: playwright-service-gate — SSO surface; auth flow gated by Keycloak realm not Playwright env var
RBAC_ADMINISTRATOR_GROUP_PATH={{ ('/' ~ lookup('rbac_group_path', application_id=application_id, role='administrator')) | dotenv_quote }}
RBAC_RESTRICTED_GROUP_PATH={{ ('/' ~ lookup('rbac_group_path', application_id=application_id, role='restricted')) | dotenv_quote }}
SSO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.sso.enabled') | string | lower }}
SUPER_ADMIN_PASSWORD={{ (OIDC.ADMIN.PASSWORD | dotenv_quote) if (lookup('config', application_id, 'services.sso.enabled') | bool) else '""' }}
SUPER_ADMIN_USERNAME={{ (OIDC.ADMIN.USERNAME | dotenv_quote) if (lookup('config', application_id, 'services.sso.enabled') | bool) else '""' }}
+15 -3
View File
@@ -8,16 +8,28 @@ GITEA_LDAP_AUTH_ARGS:
- "--port {{ LDAP.SERVER.PORT }}"
- '--security-protocol "{{ LDAP.SERVER.SECURITY | trim or "unencrypted" }}"'
- '--bind-dn "{{ LDAP.DN.ADMINISTRATOR.DATA }}"'
- '--bind-password "{{ LDAP.BIND_CREDENTIAL }}"'
- '--bind-password "$GITEA_LDAP_BIND_PASSWORD"'
- '--user-search-base "{{ LDAP.DN.OU.USERS }}"'
- '--user-filter "(&(objectClass=inetOrgPerson)(uid=%s))"'
- '--admin-filter "(memberOf=cn={{ application_id }}-administrator,{{ LDAP.DN.OU.ROLES }})"'
- '--user-filter "(&(objectClass=inetOrgPerson)({{ LDAP.USER.ATTRIBUTES.ID }}=%s))"'
- '--admin-filter "({{ LDAP.USER.ATTRIBUTES.MEMBER_OF }}=cn={{ application_id }}-administrator,{{ LDAP.DN.OU.ROLES }})"'
- '--restricted-filter "({{ LDAP.USER.ATTRIBUTES.MEMBER_OF }}=cn={{ application_id }}-restricted,{{ LDAP.DN.OU.ROLES }})"'
- '--username-attribute "{{ LDAP.USER.ATTRIBUTES.ID }}"'
- '--firstname-attribute "{{ LDAP.USER.ATTRIBUTES.FIRSTNAME }}"'
- '--surname-attribute "{{ LDAP.USER.ATTRIBUTES.SURNAME }}"'
- '--email-attribute "{{ LDAP.USER.ATTRIBUTES.MAIL }}"'
- '--public-ssh-key-attribute "{{ LDAP.USER.ATTRIBUTES.SSH_PUBLIC_KEY }}"'
- '--avatar-attribute "{{ LDAP.USER.ATTRIBUTES.PHOTO }}"'
- "--synchronize-users"
GITEA_OIDC_AUTH_ARGS:
- "--provider openidConnect"
- '--name "{{ OIDC.BUTTON_TEXT }}"'
- '--key "{{ OIDC.CLIENT.ID }}"'
- '--secret "$GITEA_OIDC_CLIENT_SECRET"'
- '--auto-discover-url "{{ OIDC.CLIENT.DISCOVERY_DOCUMENT }}"'
- '--scopes "openid profile email {{ RBAC.GROUP.CLAIM }}"'
- '--group-claim-name "{{ RBAC.GROUP.CLAIM }}"'
- '--admin-group "/{{ lookup(''rbac_group_path'', application_id=application_id, role=''administrator'') }}"'
- '--restricted-group "/{{ lookup(''rbac_group_path'', application_id=application_id, role=''restricted'') }}"'
GITEA_CONTAINER: "{{ lookup('config', application_id, 'services.gitea.name') }}"
GITEA_CONTAINER_ADDRESS: "{{ lookup('container_address', application_id, entity_name) }}"
GITEA_USER: "git"
+2
View File
@@ -14,6 +14,8 @@ This role deploys GitLab from the official Cloud Native GitLab (CNG) CE images a
- **External/central PostgreSQL and Redis:** rails `database.yml`, `resque.yml`, `cable.yml` and the workhorse config are pre-rendered by Ansible and mounted read-only.
- **Consolidated object storage:** artifacts, LFS, uploads, packages, external diffs, dependency proxy, terraform state, CI secure files and pages buckets on any S3-compatible endpoint; named volumes (`gitlab_shared`, `gitlab_uploads`, `gitlab_builds`) carry the data when object storage is disabled.
- **OIDC single sign-on and SMTP:** rendered into `gitlab.yml` and an `smtp_settings.rb` initializer.
- **Provider-Synced Profile:** Every OIDC sign-in syncs the full name and the email from Keycloak, and GitLab shows both read-only.
- **Role Reconcile:** Every deploy makes the members of the `administrator` role group GitLab administrators and the members of the `external` role group external users, and revokes both flags from every other human account except `root` and the platform administrator. A member who has not signed in yet has no GitLab account, so the next deploy after the first sign-in applies the role.
- **Git over SSH:** gitlab-sshd on the public SSH port with role-generated host keys under `<instance>/config/hostkeys/`. Back up that directory: it is not part of any named volume, and a host rebuild or instance purge regenerates the keys, so every git client then sees a host-key-changed warning until it re-trusts the new key.
- **MCP server contract:** Fronts GitLab's built-in MCP server with the repository-owned adapter. Clients reach `/mcp` on the `gitlabmcp` sidecar; the adapter alone talks to `/api/v4/mcp` upstream, so only the contracted tools are reachable.
+1
View File
@@ -3,4 +3,5 @@
- Self sign-up stays open: `Gitlab::CurrentSettings.signup_enabled?` returns `true` and `require_admin_approval_after_user_signup` returns `true` on the deployed instance, so `/users/sign_up` accepts visitors whose accounts wait for an administrator's approval (no takeover). The role sets neither `signup_enabled` in `templates/config/gitlab.yml.j2` nor the application setting. Options: `signup_enabled: false` in `gitlab.yml.j2` (applies to fresh installs only), or converge the application setting from a `rails runner` task.
- `tasks/utils/mcp/provision.yml:17` hands `GITLAB_MCP_TOKEN_OWNER_PASSWORD=<value>` to `container exec` in argv, which the deploy log prints at `-vv`. Options: pass `-e GITLAB_MCP_TOKEN_OWNER_PASSWORD` without a value plus the task's `environment:`.
- Gravatar is on (`gravatar_enabled` returns `true`): the top bar avatar loads from `https://secure.gravatar.com/avatar/<hash>` (measured `naturalWidth` 80 from the Playwright container), so avatars break on an offline host and every page view sends the e-mail hash to a third party. Options: `gravatar: enabled: false` in `templates/config/gitlab.yml.j2` (fresh installs), or converge the application setting `gravatar_enabled`.
- Role groups reach GitLab only at deploy time (`tasks/utils/rbac.yml`): mapping OIDC groups to administrator or external at sign-in (`admin_groups`, `external_groups` of the omniauth provider) is a Premium feature. Options: keep the reconcile; or a scheduled reconcile between deploys.
- The README section "MCP server" names `v19.3.1` and a token on `root`; `meta/services.yml` pins a newer release and `tasks/utils/mcp/provision.yml` mints the token on `mcp-web-app-gitlab`.
@@ -101,8 +101,23 @@ test("guest: public-landing → auth chain → never authenticated", async ({ pa
await runGuestFlow(page);
});
test("biber: app → universal logout", async ({ page }) => {
await runBiberFlow(page);
test("biber: app → no admin or external flag, provider-synced profile → universal logout", async ({ page }) => {
await runBiberFlow(page, {
biberInteraction: async (interactivePage) => {
const response = await interactivePage.request.get(`${appBaseUrl}/api/v4/user`, { timeout: resolveTimeout(30_000) });
const body = await response.text();
expect(response.ok(), `GET /api/v4/user must answer for biber, got ${response.status()}: ${body.slice(0, 300)}`).toBe(true);
const self = JSON.parse(body);
expect(self.is_admin === true, "the deploy-time reconcile must leave biber without GitLab admin rights").toBe(false);
expect(self.external, "the deploy-time reconcile must leave biber outside the external role").toBe(false);
await gotoOnion(interactivePage, `${appBaseUrl}/-/user_settings/profile`);
await expect(
interactivePage.locator("#user_name"),
"sync_profile_attributes must make the provider-synced full name read-only",
).toHaveAttribute("readonly", "readonly", { timeout: resolveTimeout(30_000) });
},
});
});
test("administrator: app → universal logout", async ({ page }) => {
@@ -0,0 +1,41 @@
# Env (from the container):
# GITLAB_RBAC_ADMINISTRATORS JSON list of {username, email} holding the administrator role
# GITLAB_RBAC_EXTERNALS JSON list of {username, email} holding the external role
# GITLAB_RBAC_KEEP_ADMINS JSON list of usernames that stay administrators outside the role group
#
# Exit: 0 with [CHANGED] or [UNCHANGED] on stdout, 1 with [FAIL] on stderr.
require 'json'
require 'set'
def resolve_ids(members)
members.filter_map do |member|
user = User.find_by_username(member.fetch('username'))
email = member.fetch('email')
user ||= User.find_by_any_email(email) unless email.empty?
user&.id
end.to_set
end
administrators = resolve_ids(JSON.parse(ENV.fetch('GITLAB_RBAC_ADMINISTRATORS')))
externals = resolve_ids(JSON.parse(ENV.fetch('GITLAB_RBAC_EXTERNALS')))
keep = JSON.parse(ENV.fetch('GITLAB_RBAC_KEEP_ADMINS')).map(&:downcase).to_set
changes = []
User.where(user_type: :human).find_each do |user|
admin = administrators.include?(user.id) || keep.include?(user.username.downcase)
external = !admin && externals.include?(user.id)
next if user.admin? == admin && user.external? == external
user.admin = admin
user.external = external
abort("[FAIL] could not update '#{user.username}': #{user.errors.full_messages.join(', ')}") unless user.save
changes << "#{user.username} admin=#{admin} external=#{external}"
end
if changes.empty?
puts '[UNCHANGED] every administrator and external flag matches the role groups'
exit(0)
end
puts "[CHANGED] #{changes.join('; ')}"
+2
View File
@@ -2,3 +2,5 @@
roles:
mcp:
description: Can drive this application through an MCP client, which acts with the credentials the deployment issued rather than the caller's own
external:
description: Signs in as a GitLab external user who sees only the projects and groups they are a member of and cannot create projects or groups
+3
View File
@@ -36,6 +36,9 @@
- name: "👤 Give the platform administrator GitLab admin rights"
include_tasks: utils/platform_admin.yml
- name: "🛂 Reconcile GitLab administrators and external users with the role groups"
include_tasks: utils/rbac.yml
- name: "🔌 Provision the MCP server surface"
include_tasks: utils/mcp.yml
when: GITLAB_MCP_ENABLED | bool
+45
View File
@@ -0,0 +1,45 @@
---
- name: "👥 Resolve the members of the {{ application_id }} administrator role"
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'tasks/utils/rbac/members.yml') }}"
vars:
rbac_members_application_id: "{{ application_id }}"
rbac_members_role: administrator
- name: "👥 Keep the members of the {{ application_id }} administrator role"
ansible.builtin.set_fact:
gitlab_rbac_administrators: "{{ rbac_members }}"
- name: "👥 Resolve the members of the {{ application_id }} external role"
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'tasks/utils/rbac/members.yml') }}"
vars:
rbac_members_application_id: "{{ application_id }}"
rbac_members_role: external
- name: "🛂 Reconcile GitLab administrators and external users with the role groups"
ansible.builtin.command:
argv:
- container
- exec
- -i
- -e
- GITLAB_RBAC_ADMINISTRATORS
- -e
- GITLAB_RBAC_EXTERNALS
- -e
- GITLAB_RBAC_KEEP_ADMINS
- "{{ GITLAB_RAILS_LOCAL_CID }}" # nocheck: container-exec-resolver
- "{{ GITLAB_RAILS_BIN }}"
- runner
- "-"
stdin: "{{ lookup('file', 'ruby/reconcile_rbac.rb') }}"
environment:
GITLAB_RBAC_ADMINISTRATORS: "{{ gitlab_rbac_administrators | to_json }}"
GITLAB_RBAC_EXTERNALS: "{{ rbac_members | to_json }}"
GITLAB_RBAC_KEEP_ADMINS: "{{ [GITLAB_ROOT_USERNAME, GITLAB_ADMIN_USERNAME] | to_json }}"
register: gitlab_rbac_reconcile
changed_when: gitlab_rbac_reconcile.stdout is search('\[CHANGED\]')
failed_when: >-
gitlab_rbac_reconcile.rc != 0
or gitlab_rbac_reconcile.stdout is search('\[FAIL\]')
delegate_to: "{{ GITLAB_RAILS_HOST_NODE }}"
run_once: true
@@ -66,6 +66,8 @@ production:
allow_single_sign_on: ["openid_connect"]
block_auto_created_users: false
auto_link_user: ["openid_connect"]
sync_profile_from_provider: ["openid_connect"]
sync_profile_attributes: ["name", "email"]
providers:
- name: "openid_connect"
label: {{ GITLAB_OIDC_LABEL | to_json }}
+1
View File
@@ -13,6 +13,7 @@ This role unite your team with Mattermost, an open-source, self-hosted messaging
- Single-container deployment via Docker Compose
- PostgreSQL database (MySQL/MariaDB not supported since Mattermost v8+)
- SSO via Keycloak using the GitLab OAuth2 provider (see note below)
- **System Admin Reconcile:** Every deploy grants `system_admin` to the members of the `administrator` role group and revokes it from every other human account except the platform administrator, through `mmctl --local roles`. A member who has not signed in yet has no Mattermost account, so the next deploy after the first sign-in applies the role.
- Email notifications via Mailu (optional)
- Persistent storage for config, data, logs, and plugins
- Accessible at `https://mattermost.<your-domain>`
+2
View File
@@ -1,5 +1,7 @@
# TODO
- The `administrator` role group reaches Mattermost only at deploy time (`tasks/05_rbac.yml`, decided by `filter_plugins/mattermost_rbac.py`): Team Edition maps no group claim to a system role at sign-in, so a Keycloak group change takes effect on the next deploy. Options: a scheduled reconcile between deploys.
- `tasks/01_setup.yml:30` passes `lookup('users', 'platform_administrator').password` to `mmctl --local user create --password` on the command line, where the process list of the node shows it (read from the task; `mmctl` reads a password from standard input only for `user change-password`). Options: create the account with a random throwaway password and set the real one through `mmctl --local user change-password` fed on standard input; or create the account through the local API socket.
- `MM_EXPERIMENTALSETTINGS_DISABLELANDINGPAGE` in `templates/env.j2` does not switch the landing page off: the deployed 11.11.1 still hands `EnableDesktopLandingPage: "true"` to its client (measured through `/api/v4/config/client` on the compose stack), so a first visit lands on `/landing` and the specs seed `localStorage.__landingPageSeen__`. Options: set `MM_SERVICESETTINGS_ENABLEDESKTOPLANDINGPAGE=false`; or keep the page and drop the dead variable.
- `templates/javascript.js.j2` inserts the "SSO with ..." link into the sign-in form whenever the form shows, also with `services.sso.enabled` false, where no `MM_GITLABSETTINGS_*` is rendered (measured on the compose stack with `sso` off: `a[href='/oauth/gitlab/login']` is present on `/login`). Options: render the snippet only under `MATTERMOST_OIDC_ENABLED`.
@@ -13,5 +13,6 @@ require("./test-mcp-guest").register(shared);
require("./test-litellm-agent").register(shared);
require("./test-biber-persona").register(shared);
require("./test-administrator-persona").register(shared);
require("./test-rbac-system-admin").register(shared);
require("./test-design").register(shared);
require("./test-seaweedfs");
@@ -0,0 +1,47 @@
const { test, expect } = require("@playwright/test");
const { resolveTimeout } = require("./timeouts");
const { performKeycloakLoginForm } = require("./personas");
const { skipUnlessServiceEnabled } = require("./service-gating");
async function signInThroughKeycloak(page, shared, username, password) {
const baseUrl = shared.expectedMattermostBaseUrl();
await shared.startMattermostSsoFlow(page, baseUrl);
await expect
.poll(() => page.url(), { timeout: resolveTimeout(60_000), message: "Expected the redirect to Keycloak" })
.toContain(shared.expectedOidcAuthUrl());
await performKeycloakLoginForm(page, username, password);
await expect
.poll(() => page.url(), { timeout: resolveTimeout(60_000), message: `Expected the redirect back to ${baseUrl}` })
.toContain(baseUrl);
await shared.dismissMattermostPopups(page);
}
async function ownSystemRoles(page, shared) {
const root = shared.expectedMattermostBaseUrl().replace(/\/$/, "");
const response = await page.request.get(`${root}/api/v4/users/me`, {
headers: { "X-Requested-With": "XMLHttpRequest" },
timeout: resolveTimeout(30_000),
});
const body = await response.text();
expect(response.ok(), `GET /api/v4/users/me must answer for the signed-in account, got ${response.status()}: ${body.slice(0, 300)}`).toBe(true);
return String(JSON.parse(body).roles || "").split(/\s+/);
}
exports.register = function (shared) {
test("rbac: the administrator keeps the Mattermost system_admin role after the deploy-time reconcile", async ({ page }) => {
skipUnlessServiceEnabled("sso");
await signInThroughKeycloak(page, shared, shared.env.adminUsername, shared.env.adminPassword);
expect(await ownSystemRoles(page, shared), "the platform administrator must stay a Mattermost system admin").toContain("system_admin");
await shared.mattermostLogout(page, shared.expectedMattermostBaseUrl());
});
test("rbac: biber without the administrator role holds no Mattermost system_admin role", async ({ page }) => {
skipUnlessServiceEnabled("sso");
await signInThroughKeycloak(page, shared, shared.env.biberUsername, shared.env.biberPassword);
const roles = await ownSystemRoles(page, shared);
expect(roles, "a realm user signs in to Mattermost as a regular member").toContain("system_user");
expect(roles, "a realm user outside the administrator role group must not be a Mattermost system admin").not.toContain("system_admin");
await shared.mattermostLogout(page, shared.expectedMattermostBaseUrl());
});
};
@@ -0,0 +1,46 @@
from __future__ import annotations
import re
from typing import Any
_SYSTEM_ADMIN = re.compile(r"(^|\s)system_admin(\s|$)")
def mattermost_rbac_plan(
users: list[dict[str, Any]], members: list[dict[str, str]], keep: list[str]
) -> dict[str, list[str]]:
"""Split the Mattermost accounts into those to promote and those to demote.
Args:
users: ``mmctl user list --json`` output; a bot carries ``is_bot``.
members: ``[{"username", "email"}]`` of the administrator role.
keep: usernames that keep ``system_admin`` outside the role.
Returns:
``{"promote": [...], "demote": [...]}`` as usernames. ``promote``
lists the human accounts without ``system_admin`` that match a member
by username or e-mail, ``demote`` the human holders of
``system_admin`` that match neither a member nor ``keep``.
"""
keys = [member["username"].lower() for member in members] + [
member["email"].lower() for member in members if member["email"]
]
kept = [name.lower() for name in keep]
promote: list[str] = []
demote: list[str] = []
for user in users:
if "is_bot" in user:
continue
username = user["username"]
admin = _SYSTEM_ADMIN.search(user["roles"]) is not None
member = username in keys or user["email"] in keys
if not admin and member and username not in promote:
promote.append(username)
if admin and not member and username not in kept:
demote.append(username)
return {"promote": promote, "demote": demote}
class FilterModule:
def filters(self):
return {"mattermost_rbac_plan": mattermost_rbac_plan}
+1 -11
View File
@@ -46,18 +46,8 @@
ansible.builtin.meta: flush_handlers
- name: "🖥️ Mattermost stack-host post-deploy"
include_tasks: 00_core/stack_host.yml
when: IS_STACK_HOST | bool
block:
- name: "▶️ Run Mattermost setup routines"
include_tasks: 01_setup.yml
- name: "🔧 Configure Keycloak OIDC mappers for Mattermost"
include_tasks: 02_keycloak.yml
when: MATTERMOST_OIDC_ENABLED | bool
- name: "🧩 Provision the Mattermost addons"
include_tasks: 04_addons.yml
when: MATTERMOST_ADDONS_ENABLED | length > 0
- name: "🤖 Bind the native AI surface to the platform gateway"
include_tasks: utils/ai_gateway.yml
@@ -0,0 +1,14 @@
---
- name: "▶️ Run Mattermost setup routines"
include_tasks: ../01_setup.yml
- name: "🔧 Configure Keycloak OIDC mappers for Mattermost"
include_tasks: ../02_keycloak.yml
when: MATTERMOST_OIDC_ENABLED | bool
- name: "🧩 Provision the Mattermost addons"
include_tasks: ../04_addons.yml
when: MATTERMOST_ADDONS_ENABLED | length > 0
- name: "🛂 Reconcile the Mattermost system admins with the administrator role group"
include_tasks: ../05_rbac.yml
@@ -0,0 +1,44 @@
---
- name: "👥 Mattermost | Resolve the members of the administrator role"
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'tasks/utils/rbac/members.yml') }}"
vars:
rbac_members_application_id: "{{ application_id }}"
rbac_members_role: administrator
- name: "📋 Mattermost | List the accounts and their system roles"
ansible.builtin.command:
argv:
- container
- exec
- -i
- "{{ MATTERMOST_LOCAL_CID }}" # nocheck: container-exec-resolver
- "{{ MATTERMOST_MMCTL }}"
- --local
- --json
- --suppress-warnings
- user
- list
- --all
register: mm_rbac_user_list
changed_when: false
delegate_to: "{{ MATTERMOST_HOST_NODE }}"
- name: "🛂 Mattermost | Reconcile the system_admin role with the administrator role group"
vars:
mm_rbac_plan: "{{ mm_rbac_user_list.stdout | from_json | mattermost_rbac_plan(rbac_members, [lookup('users', 'platform_administrator').username]) }}"
block:
- name: "⬆️ Mattermost | Grant system_admin to the members of the administrator role"
ansible.builtin.shell: | # nocheck: container-exec-resolver MATTERMOST_LOCAL_CID resolved at delegate_to runtime; container_address would return a manager-only subshell
container exec -i {{ MATTERMOST_LOCAL_CID | quote }} \
{{ MATTERMOST_MMCTL }} --local roles system_admin {{ mm_rbac_plan.promote | map('quote') | join(' ') }}
when: mm_rbac_plan.promote | length > 0
changed_when: true
delegate_to: "{{ MATTERMOST_HOST_NODE }}"
- name: "⬇️ Mattermost | Revoke system_admin from accounts outside the administrator role"
ansible.builtin.shell: | # nocheck: container-exec-resolver MATTERMOST_LOCAL_CID resolved at delegate_to runtime; container_address would return a manager-only subshell
container exec -i {{ MATTERMOST_LOCAL_CID | quote }} \
{{ MATTERMOST_MMCTL }} --local roles member {{ mm_rbac_plan.demote | map('quote') | join(' ') }}
when: mm_rbac_plan.demote | length > 0
changed_when: true
delegate_to: "{{ MATTERMOST_HOST_NODE }}"
+2
View File
@@ -13,6 +13,8 @@ This role provisions a complete Nextcloud deployment using Docker Compose. It au
- **Fully Dockerized Deployment:** Simplifies installation using Docker Compose for the Nextcloud application and its MariaDB backend.
- **Secure Access:** Integrates with an NGINX reverse proxy for encrypted, high-performance access.
- **Robust Authentication:** Supports LDAP and OIDC for secure identity and access management.
- **Administrator Role Mapping:** Members of the `administrator` role group are Nextcloud administrators. With LDAP, `user_ldap` reads the role group as its admin group at runtime and a change reaches Nextcloud within `NEXTCLOUD_LDAP_CACHE_TTL` seconds; with `sociallogin`, the groups claim maps to the `admin` group at every login; with `oidc_login` outside the LDAP proxy mode, the `is_admin` attribute reads the groups claim.
- **Directory Profile:** `user_ldap` syncs phone, website, street, organisation, title, description, quota and avatar from the directory, and Nextcloud shows those profile fields read-only.
- **Automated Configuration Management:** Uses additive configuration files to dynamically merge system settings into `config.php`.
- **Integrated Backup & Recovery:** Provides built-in support for backup and restoration operations to safeguard your data.
- **Extensible Plugin Framework:** Easily manage and configure hundreds of Nextcloud plugins using the OCC command line tool.
+6
View File
@@ -0,0 +1,6 @@
# TODO
- A profile change made in Keycloak reaches Nextcloud only on a native LDAP login or the `user_ldap` background sync: `oidc_login` in LDAP proxy mode fetches the DN without attributes, so `processAttributes` does not run at an OIDC login (read from `LoginService::getLDAPUserUid` and `Access::fetchListOfUsers`); `files/playwright/test-ldap-profile.js` proves the password login path only. Options: run `occ ldap:check-user --update` per directory user at deploy time; or an upstream `oidc_login` change that refreshes the LDAP record at login.
- The Nextcloud address field reads one LDAP attribute, so only `street` is synced; postal code, locality, region and country stay out. Options: maintain a composed `postalAddress` in the directory and map that instead.
- No Playwright scenario proves the LDAP avatar (`jpegPhoto`) or the LDAP quota (`nextcloudQuota`): no persona carries either attribute, Keycloak exposes no photo upload, and both reach Nextcloud only through `processAttributes` (first item). Options: seed both attributes on `biber` in the directory fixture and assert them after a native LDAP login.
- The `oidc_login` attributes `is_admin`, `name`, `mail` and `quota` are read only outside the LDAP proxy mode, which no variant in [meta/variants.yml](./meta/variants.yml) deploys (`sso_oidc_plugin` picks `oidc_login` only together with LDAP). Options: a variant that sets `services.sso.oidc.plugin: oidc_login` with `ldap` disabled.
@@ -29,3 +29,5 @@ require("./test-mcp-guest").register(shared);
require("./test-biber-persona").register(shared);
require("./test-administrator-persona").register(shared);
require("./test-seaweedfs");
require("./test-ldap-profile").register(shared);
require("./test-rbac-administrator").register(shared);
@@ -0,0 +1,113 @@
const { test, expect } = require("@playwright/test");
const { resolveTimeout } = require("./timeouts");
const { decodeDotenvQuotedValue, keycloakAdminSetUserAttributes, normalizeBaseUrl } = require("./personas");
const { skipUnlessServiceEnabled } = require("./service-gating");
const DIRECTORY_MANAGED_FIELDS = ["phone", "website", "address", "organisation", "role", "biography"];
const KEYCLOAK_PHONE_ATTRIBUTE = "phoneNumber";
const env = {
keycloakBaseUrl: normalizeBaseUrl(decodeDotenvQuotedValue(process.env.KEYCLOAK_BASE_URL) || ""),
realmName: decodeDotenvQuotedValue(process.env.KEYCLOAK_REALM_NAME),
adminRealm: decodeDotenvQuotedValue(process.env.KEYCLOAK_ADMIN_REALM),
adminClientId: decodeDotenvQuotedValue(process.env.KEYCLOAK_ADMIN_CLI_CLIENT_ID),
superAdminUsername: decodeDotenvQuotedValue(process.env.SUPER_ADMIN_USERNAME),
superAdminPassword: decodeDotenvQuotedValue(process.env.SUPER_ADMIN_PASSWORD),
ldapCacheTtlSeconds: Number(decodeDotenvQuotedValue(process.env.NEXTCLOUD_LDAP_CACHE_TTL)),
};
exports.register = function (shared) {
test("biber: nextcloud profile fields synced from the directory are read-only", async ({ browser }) => {
skipUnlessServiceEnabled("ldap");
const biberContext = await browser.newContext({ ignoreHTTPSErrors: true });
const biberPage = await biberContext.newPage();
try {
await shared.loginToStandaloneNextcloud(biberPage, shared.env.biberUsername, shared.env.biberPassword);
const response = await biberPage.request.get(
new URL("ocs/v2.php/cloud/user/fields?format=json", shared.env.nextcloudBaseUrl).toString(),
{ headers: { "OCS-APIRequest": "true", Accept: "application/json" }, timeout: resolveTimeout(30_000) },
);
const body = await response.text();
expect(response.ok(), `the editable-fields endpoint must answer for biber, got ${response.status()}: ${body.slice(0, 300)}`).toBe(true);
const editable = JSON.parse(body).ocs.data;
expect(editable, "the editable-fields endpoint must list the fields Nextcloud still manages itself").toContain("headline");
for (const field of DIRECTORY_MANAGED_FIELDS) {
expect(editable, `the ${field} field is synced from the directory and must not be editable in Nextcloud`).not.toContain(field);
}
await biberPage.goto(new URL("settings/user", shared.env.nextcloudBaseUrl).toString(), {
waitUntil: "domcontentloaded",
timeout: resolveTimeout(60_000),
});
await shared.waitForVisibleCandidate(
biberPage,
shared.getNextcloudShellCandidates(biberPage),
resolveTimeout(60_000),
"Timed out waiting for biber's personal settings in the Nextcloud shell",
);
await shared.logoutStandaloneNextcloud(biberPage);
} finally {
await biberContext.close().catch(() => {});
}
});
test("biber: a phone number changed in Keycloak reaches Nextcloud on the next directory password login", async ({ browser, request }) => {
skipUnlessServiceEnabled("sso");
skipUnlessServiceEnabled("ldap");
expect(env.ldapCacheTtlSeconds, "NEXTCLOUD_LDAP_CACHE_TTL must be a number of seconds").toBeGreaterThan(0);
const refreshBudgetMs = (env.ldapCacheTtlSeconds + 90) * 1000;
test.setTimeout(refreshBudgetMs + resolveTimeout(120_000)); // the LDAP cache TTL of user_ldap plus one Keycloak attribute write and restore
const phone = `+49301${String(Date.now()).slice(-6)}`;
const basic = Buffer.from(`${shared.env.biberUsername}:${shared.env.biberPassword}`).toString("base64");
const adminOpts = { adminRealm: env.adminRealm, adminClientId: env.adminClientId };
const adminContext = await browser.newContext({ ignoreHTTPSErrors: true });
let previous = null;
try {
previous = await keycloakAdminSetUserAttributes(
adminContext.request,
env.keycloakBaseUrl,
env.realmName,
shared.env.biberUsername,
{ [KEYCLOAK_PHONE_ATTRIBUTE]: phone },
env.superAdminUsername,
env.superAdminPassword,
adminOpts,
);
await expect
.poll(
async () => {
const response = await request.get(new URL("ocs/v2.php/cloud/user?format=json", shared.env.nextcloudBaseUrl).toString(), {
headers: { "OCS-APIRequest": "true", Accept: "application/json", Authorization: `Basic ${basic}` },
timeout: resolveTimeout(30_000),
});
if (!response.ok()) {
return `HTTP ${response.status()}`;
}
return (await response.json()).ocs.data.phone;
},
{
timeout: refreshBudgetMs,
intervals: [5_000],
message: "a password login of biber against the directory must copy the changed telephoneNumber onto the Nextcloud profile",
},
)
.toBe(phone);
} finally {
if (previous) {
await keycloakAdminSetUserAttributes(
adminContext.request,
env.keycloakBaseUrl,
env.realmName,
shared.env.biberUsername,
previous,
env.superAdminUsername,
env.superAdminPassword,
adminOpts,
).catch((err) => console.warn(`Restoring biber's phone number failed: ${err}`));
}
await adminContext.close().catch(() => {});
}
});
};
@@ -0,0 +1,117 @@
const { test, expect } = require("@playwright/test");
const { resolveTimeout } = require("./timeouts");
const {
decodeDotenvQuotedValue,
gotoOnion,
keycloakAdminAddUserToGroup,
keycloakRemoveUserFromGroupViaRest,
normalizeBaseUrl,
} = require("./personas");
const { skipUnlessServiceEnabled } = require("./service-gating");
const env = {
keycloakBaseUrl: normalizeBaseUrl(decodeDotenvQuotedValue(process.env.KEYCLOAK_BASE_URL) || ""),
realmName: decodeDotenvQuotedValue(process.env.KEYCLOAK_REALM_NAME),
adminRealm: decodeDotenvQuotedValue(process.env.KEYCLOAK_ADMIN_REALM),
adminClientId: decodeDotenvQuotedValue(process.env.KEYCLOAK_ADMIN_CLI_CLIENT_ID),
superAdminUsername: decodeDotenvQuotedValue(process.env.SUPER_ADMIN_USERNAME),
superAdminPassword: decodeDotenvQuotedValue(process.env.SUPER_ADMIN_PASSWORD),
administratorGroupPath: decodeDotenvQuotedValue(process.env.RBAC_ADMINISTRATOR_GROUP_PATH),
ldapCacheTtlSeconds: Number(decodeDotenvQuotedValue(process.env.NEXTCLOUD_LDAP_CACHE_TTL)),
};
function adminOverviewUrl(shared) {
return new URL("settings/admin/overview", shared.env.nextcloudBaseUrl).toString();
}
async function adminOverviewStatus(page, shared) {
const response = await gotoOnion(page, adminOverviewUrl(shared), {
waitUntil: "domcontentloaded",
timeout: resolveTimeout(60_000),
}).catch(() => null);
return response ? response.status() : 0;
}
async function logoutFromShell(page, shared) {
await gotoOnion(page, shared.env.nextcloudBaseUrl, { waitUntil: "domcontentloaded", timeout: resolveTimeout(60_000) });
await shared.waitForVisibleCandidate(
page,
shared.getNextcloudShellCandidates(page),
resolveTimeout(60_000),
"Timed out waiting for the signed-in Nextcloud shell before logging out",
);
await shared.logoutStandaloneNextcloud(page);
}
exports.register = function (shared) {
test("rbac: biber without the administrator role is refused the Nextcloud administration settings", async ({ browser }) => {
skipUnlessServiceEnabled("sso");
const biberContext = await browser.newContext({ ignoreHTTPSErrors: true });
const biberPage = await biberContext.newPage();
try {
await shared.loginToStandaloneNextcloud(biberPage, shared.env.biberUsername, shared.env.biberPassword);
expect(
await adminOverviewStatus(biberPage, shared),
"a realm user outside the administrator role group must not reach the Nextcloud administration settings",
).toBe(403);
await logoutFromShell(biberPage, shared);
} finally {
await biberContext.close().catch(() => {});
}
});
test("rbac: membership in the administrator group grants biber the Nextcloud administration settings", async ({ browser }) => {
skipUnlessServiceEnabled("sso");
expect(env.ldapCacheTtlSeconds, "NEXTCLOUD_LDAP_CACHE_TTL must be a number of seconds").toBeGreaterThan(0);
const promotionBudgetMs = (env.ldapCacheTtlSeconds + 90) * 1000;
test.setTimeout(promotionBudgetMs + resolveTimeout(240_000));
const adminOpts = { adminRealm: env.adminRealm, adminClientId: env.adminClientId };
const adminContext = await browser.newContext({ ignoreHTTPSErrors: true });
let joined = false;
try {
joined = await keycloakAdminAddUserToGroup(
adminContext.request,
env.keycloakBaseUrl,
env.realmName,
env.administratorGroupPath,
shared.env.biberUsername,
env.superAdminUsername,
env.superAdminPassword,
adminOpts,
);
const biberContext = await browser.newContext({ ignoreHTTPSErrors: true });
const biberPage = await biberContext.newPage();
try {
await shared.loginToStandaloneNextcloud(biberPage, shared.env.biberUsername, shared.env.biberPassword);
await expect
.poll(() => adminOverviewStatus(biberPage, shared), {
timeout: promotionBudgetMs,
intervals: [5_000],
message: `biber in ${env.administratorGroupPath} must reach the Nextcloud administration settings`,
})
.toBe(200);
await expect(
biberPage.locator('a[href*="/settings/admin/"]').first(),
"the administration settings navigation must render for a member of the administrator role group",
).toBeVisible({ timeout: resolveTimeout(30_000) });
await logoutFromShell(biberPage, shared);
} finally {
await biberContext.close().catch(() => {});
}
} finally {
if (joined) {
await keycloakRemoveUserFromGroupViaRest(
adminContext.request,
env.keycloakBaseUrl,
env.realmName,
env.superAdminUsername,
env.superAdminPassword,
env.administratorGroupPath,
shared.env.biberUsername,
adminOpts,
).catch((err) => console.warn(`Cleanup removal of biber from ${env.administratorGroupPath} failed: ${err}`));
}
await adminContext.close().catch(() => {});
}
});
};
@@ -36,13 +36,13 @@ config:
configvalue: "{{ LDAP.DN.ROOT }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_base_groups"
configvalue: "{{ LDAP.DN.ROOT }}"
configvalue: "{{ LDAP.DN.OU.ROLES }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_base_users"
configvalue: "{{ LDAP.DN.OU.USERS }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_cache_ttl"
configvalue: 600
configvalue: "{{ NEXTCLOUD_LDAP_CACHE_TTL }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_configuration_active"
configvalue: 1
@@ -52,15 +52,36 @@ config:
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_attributes_for_user_search"
configvalue: "{{ LDAP.USER.ATTRIBUTES.ID }}\n{{ LDAP.USER.ATTRIBUTES.FULLNAME }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_admin_group"
configvalue: "{{ application_id }}-administrator"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_attr_address"
configvalue: "{{ LDAP.USER.ATTRIBUTES.STREET }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_attr_biography"
configvalue: "{{ LDAP.USER.ATTRIBUTES.DESCRIPTION }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_attr_organisation"
configvalue: "{{ LDAP.USER.ATTRIBUTES.ORGANIZATION }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_attr_phone"
configvalue: "{{ LDAP.USER.ATTRIBUTES.PHONE }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_attr_role"
configvalue: "{{ LDAP.USER.ATTRIBUTES.TITLE }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_attr_website"
configvalue: "{{ LDAP.USER.ATTRIBUTES.WEBSITE }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_display_name"
configvalue: "cn"
configvalue: "{{ LDAP.USER.ATTRIBUTES.FULLNAME }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_dn"
configvalue: "{{ LDAP.DN.ADMINISTRATOR.DATA }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_email_attr"
configvalue: "mail"
configvalue: "{{ LDAP.USER.ATTRIBUTES.MAIL }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_experienced_admin"
configvalue: 0
@@ -72,16 +93,16 @@ config:
configvalue: "cn"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_group_filter"
configvalue: "(&(|(objectclass=groupOfUniqueNames)(objectclass=posixGroup)))"
configvalue: "(&(objectclass=groupOfNames)(cn={{ application_id }}-*))"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_group_filter_mode"
configvalue: 0
configvalue: 1
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_group_member_assoc_attribute"
configvalue: "uniqueMember"
configvalue: "{{ LDAP.RBAC.MEMBER_ATTRIBUTE }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_groupfilter_objectclass"
configvalue: "groupOfUniqueNames\nposixGroup"
configvalue: "groupOfNames"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_host"
configvalue: "{{ LDAP.SERVER.DOMAIN }}"
@@ -112,6 +133,9 @@ config:
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_port"
configvalue: 389
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_quota_attr"
configvalue: "{{ LDAP.USER.ATTRIBUTES.NEXTCLOUD_QUOTA }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_turn_off_cert_check"
configvalue: 0
@@ -120,7 +144,7 @@ config:
configvalue: 0
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_user_avatar_rule"
configvalue: "default"
configvalue: "data:{{ LDAP.USER.ATTRIBUTES.PHOTO }}"
- appid: "user_ldap"
configkey: "{{ NEXTCLOUD_LDAP_CONFIG_PREFIX }}ldap_user_filter_mode"
configvalue: 0
@@ -55,3 +55,7 @@
- name: 🗂️ Warm LDAP cache (to guaranty that all LDAP users are present)
shell: >
{{ NEXTCLOUD_DOCKER_EXEC_OCC }} ldap:search ""
- name: 🛂 Map the Nextcloud role groups of the directory
shell: >
{{ NEXTCLOUD_DOCKER_EXEC_OCC }} ldap:search --group ""
changed_when: false
@@ -99,15 +99,15 @@ return array (
//
'oidc_login_attributes' => array (
'id' => '{{ LDAP.USER.ATTRIBUTES.ID }}',
'name' => 'name',
'mail' => 'email',
'name' => '{{ OIDC.ATTRIBUTES.NAME }}',
'mail' => '{{ OIDC.ATTRIBUTES.EMAIL }}',
'quota' => '{{ LDAP.USER.ATTRIBUTES.NEXTCLOUD_QUOTA }}',
# 'home' => 'homeDirectory', # Not implemented yet
'ldap_uid' => '{{ OIDC.ATTRIBUTES.USERNAME }}',
# 'groups' => 'ownCloudGroups', # Not implemented yet
# 'login_filter' => 'realm_access_roles',
// 'photoURL' => 'picture',
// 'is_admin' => 'ownCloudAdmin',
'is_admin' => '{{ RBAC.GROUP.CLAIM }}_/{{ lookup('rbac_group_path', application_id=application_id, role='administrator') }}',
),
// Default group to add users to (optional, defaults to nothing)
@@ -137,7 +137,7 @@ return array (
'oidc_login_use_external_storage' => false,
// Set OpenID Connect scope
'oidc_login_scope' => 'openid profile',
'oidc_login_scope' => 'openid profile {{ RBAC.GROUP.CLAIM }} {{ lookup('config', 'web-app-keycloak', 'services.keycloak.scopes.nextcloud') }}',
// Run in LDAP proxy mode
// In this mode, instead of creating users of its own, OIDC login
@@ -19,6 +19,14 @@ EMAIL_SERVICE_ENABLED={{ lookup('config', application_id, 'services.email.enable
INTEGRATION_OPENAI_EXPECT_API_KEY={{ ((lookup('config', application_id, 'services.litellm.enabled') | bool) and not (lookup('config', application_id, 'services.openwebui.enabled') | bool)) | string | lower }}
KEYCLOAK_ADMIN_CLI_CLIENT_ID={{ OIDC.ADMIN.CLI_CLIENT_ID | dotenv_quote }}
KEYCLOAK_ADMIN_REALM={{ OIDC.ADMIN.REALM | dotenv_quote }}
KEYCLOAK_BASE_URL={{ OIDC.URL | dotenv_quote }}
KEYCLOAK_REALM_NAME={{ OIDC.CLIENT.REALM | dotenv_quote }}
LDAP_SERVICE_ENABLED={{ lookup('config', application_id, 'services.ldap.enabled') | string | lower }}
LOGIN_PASSWORD={{ lookup('users', 'platform_administrator').password | dotenv_quote }}
@@ -41,6 +49,8 @@ NEXTCLOUD_BASE_URL={{ lookup('tls', 'web-app-nextcloud', 'url.base') | dotenv_qu
NEXTCLOUD_DIRECT_LOGIN_PASSWORD={{ lookup('users', 'platform_administrator').password | dotenv_quote }}
NEXTCLOUD_LDAP_CACHE_TTL={{ NEXTCLOUD_LDAP_CACHE_TTL }}
NEXTCLOUD_MCP_ENDPOINT_PATH={{ lookup('config', application_id, 'mcp.endpoint.path') | dotenv_quote }}
NEXTCLOUD_MCP_UPSTREAM_PATH={{ lookup('config', application_id, 'mcp.adapter.upstream_path') | dotenv_quote }}
@@ -71,6 +81,8 @@ PERSONA_ADMINISTRATOR_BLOCKED=true
# nocheck: persona-block-rationale — Nextcloud's login surface has three shapes depending on the variant (native / oidc_login / sociallogin, files/playwright/_shared.js:19-23) and the #firstrunwizard modal intercepts pointer events on the user menu the generic logout must click (files/playwright/_shared.js:160-175), so biber's chain is driven by files/playwright/test-login-biber-oidc.js and test-login-biber-ldap.js (see README "Persona contract opt-outs").
PERSONA_BIBER_BLOCKED=true
RBAC_ADMINISTRATOR_GROUP_PATH={{ ('/' ~ lookup('rbac_group_path', application_id=application_id, role='administrator')) | dotenv_quote }}
SEAWEEDFS_APP_ACCESS_KEY={{ lookup('objstore', application_id, 'access_key') | dotenv_quote }}
SEAWEEDFS_APP_BUCKET={{ lookup('objstore', application_id, 'bucket') | dotenv_quote }}
@@ -85,6 +97,10 @@ SEAWEEDFS_SERVICE_ENABLED={{ lookup('config', application_id, 'services.seaweedf
SSO_SERVICE_ENABLED={{ NEXTCLOUD_SSO_ENABLED | string | lower }}
SUPER_ADMIN_PASSWORD={{ (OIDC.ADMIN.PASSWORD | dotenv_quote) if (NEXTCLOUD_SSO_ENABLED | bool) else '""' }}
SUPER_ADMIN_USERNAME={{ (OIDC.ADMIN.USERNAME | dotenv_quote) if (NEXTCLOUD_SSO_ENABLED | bool) else '""' }}
XWIKI_BASE_URL={{ (lookup('tls', 'web-app-xwiki', 'url.base') if (lookup('config', application_id, 'services.xwiki.enabled') | bool) else '') | dotenv_quote }}
XWIKI_PARTNER_HOST={{ lookup('domain', 'web-app-xwiki') | dotenv_quote }}
+1
View File
@@ -34,6 +34,7 @@ NEXTCLOUD_DESIGN_THEMING:
background: backgroundColor
NEXTCLOUD_USER_LDAP_ENABLED: "{{ lookup('config', application_id, 'addons.user_ldap.enabled') }}"
NEXTCLOUD_LDAP_CONFIG_PREFIX: "s01"
NEXTCLOUD_LDAP_CACHE_TTL: 60 # Seconds until a role or profile change in the directory reaches Nextcloud
NEXTCLOUD_HOST_CONF_ADD_PATH: "{{ [ lookup('container', application_id, 'directories.volumes'), 'infinito' ] | path_join }}"
NEXTCLOUD_HOST_NGINX_PATH: "{{ [ lookup('container', application_id, 'directories.volumes'), 'nginx.conf' ] | path_join }}"
+2 -2
View File
@@ -12,8 +12,8 @@ This role deploys OpenCloud using Docker Compose in single-binary mode and expos
- **Sovereign File Sync and Share:** Self-host file sync, shares, and collaborative spaces under your own domain.
- **Single Sign-On:** Users authenticate once via Keycloak and reuse the session across the platform.
- **Central User Directory:** Users and groups are read from a shared OpenLDAP backend, so accounts stay consistent across apps.
- **Auto-Provisioning:** New OIDC users are created on first login with username equal to the LDAP `uid`, and group claims drive role assignment.
- **Central User Directory:** Users and groups are read from a shared OpenLDAP backend, so accounts stay consistent across apps, and the display name comes from the directory full name.
- **Role Mapping:** With SSO, every login sets the OpenCloud role from the Keycloak realm roles: members of the `administrator`, `spaceadmin` and `guest` role groups become `admin`, `spaceadmin` and `user-light`, and every other realm user signs in as `user` through `default-roles-<realm>`. Without SSO, every account signs in as `user`.
- **OpenTalk Cross-Launch:** Start a video meeting in OpenTalk from a file context without re-authenticating when `web-app-opentalk` is deployed alongside.
- **Coexists with Nextcloud:** Runs in parallel with `web-app-nextcloud` on a distinct canonical hostname.
+2 -1
View File
@@ -1,6 +1,7 @@
# web-app-opencloud TODO 📝
- [ ] Promote individual users to OpenCloud admin via OCC after first login. The default driver assigns the standard `user` role to every auto-provisioned account; admin promotion is currently manual.
- [ ] Map role groups without SSO: the role mapping reads `realm_access.roles` from Keycloak, so the SSO-less variants (built-in lico IDP) keep the `default` driver and give every account `user`. Options: a deploy-time reconcile through the Graph `appRoleAssignments` API, which needs a bootstrap admin (`OC_ADMIN_USER_ID`) first.
- [ ] The `oidc` role assignment driver refuses a login whose `realm_access.roles` holds no mapped value (`services/proxy/pkg/userroles/oidcroles.go` at `v7.2.4`). Removing `default-roles-<realm>` from a Keycloak user, or the `roles` client scope from the shared client, therefore locks that user out of OpenCloud. Options: keep the default realm role on every account.
- [ ] Surface an OpenTalk launcher in the OpenCloud sidebar. `WEB_OPTION_OPENTALK_URL` is set, but a clickable launcher needs an upstream OpenCloud Web app or extension.
- [ ] Verify back-channel logout from Keycloak terminates the OpenCloud session in a real browser.
- [ ] Let the App Store load its catalogue. `/app-store/list` shows "No apps found" because the browser refuses `https://raw.githubusercontent.com/opencloud-eu/awesome-apps/main/webApps/apps.json`: the `connect-src` of [meta/csp.yml](./meta/csp.yml) does not list that host. Options: add the host to `connect-src`, or drop `app-store` from the web apps OpenCloud loads.
+24 -7
View File
@@ -1,16 +1,34 @@
# Identity and Access Management 🔐
OpenCloud delegates authentication to the central Keycloak realm and consumes user and group data from the central OpenLDAP directory. Local password login is disabled when `services.sso.enabled` is true (the default), and accounts are auto-provisioned on first OIDC login.
OpenCloud delegates authentication to the central Keycloak realm and consumes user and group data from the central OpenLDAP directory. Local password login is disabled when `services.sso.enabled` is true (the default).
## OIDC 🪪
- Issuer URL: `{{ OIDC.CLIENT.ISSUER_URL }}`
- Client ID: shared `OIDC.CLIENT.ID` (one Keycloak client per realm covers every web app)
- Username claim: `preferred_username`, mapped to OpenCloud `username`
- Role claim: `groups` (Keycloak group memberships flow into OpenCloud roles)
- Auto-provisioning: enabled via `PROXY_AUTOPROVISION_ACCOUNTS=true`
- Username claim: `OIDC.ATTRIBUTES.USERNAME`, matched against the OpenCloud `username`
- Accounts: read from the directory, `PROXY_AUTOPROVISION_ACCOUNTS=false`
- Built-in IDP excluded via `OC_EXCLUDE_RUN_SERVICES=idp`
### Roles 🛂
`meta/rbac.yml` sets `realm_roles: true`, so Keycloak grants the realm role `web-app-opencloud-<role>` to every `/roles/web-app-opencloud/<role>` group. The container writes `OPENCLOUD_ROLE_ASSIGNMENT` from `vars/main.yml` to `/etc/opencloud/proxy.yaml` at every start, and the proxy then sets the role at every login from `realm_access.roles`. The first matching value wins:
| `realm_access.roles` value | OpenCloud role |
|---|---|
| `web-app-opencloud-administrator` | `admin` |
| `web-app-opencloud-spaceadmin` | `spaceadmin` |
| `web-app-opencloud-guest` | `user-light` |
| `default-roles-<realm>` | `user` |
`GRAPH_ASSIGN_DEFAULT_USER_ROLE=false` leaves every assignment to the proxy. Without SSO, the container removes `proxy.yaml` and the `default` driver gives every account `user`.
### Verify the role mapping 🩺
```bash
make compose-exec cmd="container exec opencloud cat /etc/opencloud/proxy.yaml"
```
### Verify OIDC discovery 🩺
```bash
@@ -27,8 +45,7 @@ OpenCloud reads users from the central `svc-db-openldap` service.
- Group base DN: `{{ LDAP.DN.OU.GROUPS }}`
- User filter: `(objectclass=inetOrgPerson)`
- Group filter: `(objectclass=groupOfNames)`
Members of the `application_administrators` group (per requirement 004) gain OpenCloud admin rights when they log in.
- Display name: `LDAP.USER.ATTRIBUTES.FULLNAME` through `OC_LDAP_USER_SCHEMA_DISPLAYNAME`
### Verify LDAP wiring 🩺
@@ -38,4 +55,4 @@ make compose-exec cmd="container exec opencloud opencloud config get ldap"
## Federation 🔗
If a Keycloak user is not present in OpenLDAP, OpenCloud auto-provisions the user on first login using the `preferred_username` claim. To keep usernames stable across Nextcloud, OpenCloud, and OpenTalk, all three apps share the same `OIDC.CLIENT.REALM` and the same `LDAP.DN.OU.USERS` source.
To keep usernames stable across Nextcloud, OpenCloud, and OpenTalk, all three apps share the same `OIDC.CLIENT.REALM` and the same `LDAP.DN.OU.USERS` source.
@@ -28,7 +28,7 @@ function attachDiagnostics(page, _label) {
return diagnostics;
}
async function ssoLoginAndAssertUsername(page, username, password) {
async function ssoLogin(page, username, password) {
const diagnostics = attachDiagnostics(page, username);
// OpenCloud Web's index.html shows a "browser not supported" splash unless
// `forceAllowOldBrowser` is present in localStorage. Playwright's headless
@@ -143,9 +143,58 @@ async function ssoLoginAndAssertUsername(page, username, password) {
// navigation banner instead of body text because OpenCloud shows the
// username inside the user-menu drawer rather than in the page body.
await expect(page.getByRole("banner", { name: /top bar/i })).toBeVisible({ timeout: resolveTimeout(90_000) });
}
async function ssoLoginAndAssertUsername(page, username, password) {
await ssoLogin(page, username, password);
await expect(page.getByRole("link", { name: /personal files/i })).toBeVisible({ timeout: resolveTimeout(30_000) });
}
async function logoutThroughAccountMenu(page) {
await page.locator("#_userMenuButton").click({ timeout: resolveTimeout(30_000) });
await page.locator("#account-info-container #oc-topbar-account-logout").click({ timeout: resolveTimeout(30_000) });
await expect(page.locator("#_userMenuButton"), "the top bar account button must disappear after logout").toBeHidden({
timeout: resolveTimeout(60_000),
});
}
async function ownRoleIds(page) {
const result = await page.evaluate(async () => {
let token = "";
for (const store of [window.sessionStorage, window.localStorage]) {
for (let index = 0; index < store.length; index += 1) {
try {
const value = JSON.parse(store.getItem(store.key(index)) || "null");
if (value && typeof value.access_token === "string") {
token = value.access_token;
}
} catch {}
}
}
if (!token) {
return { error: "no access token in the browser storage" };
}
const headers = { Authorization: `Bearer ${token}` };
const me = await fetch("/graph/v1.0/me", { headers });
if (!me.ok) {
return { error: `GET /graph/v1.0/me answered ${me.status}` };
}
const { id } = await me.json();
const assignments = await fetch("/api/v0/settings/assignments-list", {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({ account_uuid: id }),
});
if (!assignments.ok) {
return { error: `POST /api/v0/settings/assignments-list answered ${assignments.status}` };
}
const body = await assignments.json();
return { roleIds: (body.assignments || []).map((assignment) => assignment.roleId).filter(Boolean) };
});
expect(result.error, `the OpenCloud role probe failed: ${result.error}`).toBeUndefined();
return result.roleIds;
}
module.exports = {
baseUrl,
issuerUrl,
@@ -157,5 +206,8 @@ module.exports = {
issuerPattern,
baseUrlPattern,
attachDiagnostics,
ssoLogin,
ssoLoginAndAssertUsername,
logoutThroughAccountMenu,
ownRoleIds,
};
@@ -1,4 +1,6 @@
require("./test-sso-login");
require("./test-ldap-display-name");
require("./test-rbac-roles");
require("./test-guest-persona");
require("./test-biber-persona");
require("./test-administrator-persona");
@@ -0,0 +1,27 @@
const { test, expect } = require("./onion-test");
const { resolveTimeout } = require("./timeouts");
const { skipUnlessServiceEnabled } = require("./service-gating");
const { biberUsername, biberPassword, logoutThroughAccountMenu, ssoLoginAndAssertUsername } = require("./_shared");
test.use({ ignoreHTTPSErrors: true });
test("biber: opencloud account menu shows the display name read from the directory", async ({ page }) => {
skipUnlessServiceEnabled("sso");
skipUnlessServiceEnabled("ldap");
await ssoLoginAndAssertUsername(page, biberUsername, biberPassword);
await page.locator("#_userMenuButton").click({ timeout: resolveTimeout(30_000) });
const accountMenu = page.locator("#account-info-container");
await expect(accountMenu, "the account menu must open from the top bar").toBeVisible({ timeout: resolveTimeout(30_000) });
await expect
.poll(async () => ((await accountMenu.locator("span > span.block").first().textContent()) || "").trim(), {
timeout: resolveTimeout(30_000),
message: "OpenCloud must read the display name from OC_LDAP_USER_SCHEMA_DISPLAYNAME, so the account menu shows a name",
})
.not.toBe("");
await page.locator("#_userMenuButton").click({ timeout: resolveTimeout(30_000) });
await logoutThroughAccountMenu(page);
});
@@ -0,0 +1,116 @@
const { test, expect } = require("./onion-test");
const { resolveTimeout } = require("./timeouts");
const {
decodeDotenvQuotedValue,
keycloakAdminAddUserToGroup,
keycloakRemoveUserFromGroupViaRest,
normalizeBaseUrl,
} = require("./personas");
const { skipUnlessServiceEnabled } = require("./service-gating");
const {
adminUsername,
adminPassword,
biberUsername,
biberPassword,
logoutThroughAccountMenu,
ownRoleIds,
ssoLogin,
} = require("./_shared");
test.use({ ignoreHTTPSErrors: true });
const OPENCLOUD_ROLE_IDS = {
admin: "71881883-1768-46bd-a24d-a356a2afdf7f",
spaceadmin: "2aadd357-682c-406b-8874-293091995fdd",
user: "d7beeea8-8ff4-406b-8fb6-ab2dd81e6b11",
"user-light": "38071a68-456a-4553-846a-fa67bf5596cc",
};
const env = {
keycloakBaseUrl: normalizeBaseUrl(decodeDotenvQuotedValue(process.env.KEYCLOAK_BASE_URL) || ""),
realmName: decodeDotenvQuotedValue(process.env.KEYCLOAK_REALM_NAME),
adminRealm: decodeDotenvQuotedValue(process.env.KEYCLOAK_ADMIN_REALM),
adminClientId: decodeDotenvQuotedValue(process.env.KEYCLOAK_ADMIN_CLI_CLIENT_ID),
superAdminUsername: decodeDotenvQuotedValue(process.env.SUPER_ADMIN_USERNAME),
superAdminPassword: decodeDotenvQuotedValue(process.env.SUPER_ADMIN_PASSWORD),
};
const PROMOTIONS = [
{ group: "administrator", groupPath: decodeDotenvQuotedValue(process.env.RBAC_ADMINISTRATOR_GROUP_PATH), role: "admin" },
{ group: "spaceadmin", groupPath: decodeDotenvQuotedValue(process.env.RBAC_SPACEADMIN_GROUP_PATH), role: "spaceadmin" },
{ group: "guest", groupPath: decodeDotenvQuotedValue(process.env.RBAC_GUEST_GROUP_PATH), role: "user-light" },
];
async function signedInRoleIds(browser, username, password) {
const context = await browser.newContext({ ignoreHTTPSErrors: true });
try {
const page = await context.newPage();
await ssoLogin(page, username, password);
const roleIds = await ownRoleIds(page);
await logoutThroughAccountMenu(page);
return roleIds;
} finally {
await context.close().catch(() => {});
}
}
test("rbac: biber without a role group signs in to OpenCloud with the User role", async ({ browser }) => {
skipUnlessServiceEnabled("sso");
expect(
await signedInRoleIds(browser, biberUsername, biberPassword),
"default-roles-<realm> must map every realm user without a role group to the OpenCloud User role",
).toEqual([OPENCLOUD_ROLE_IDS.user]);
});
test("rbac: the administrator holds the OpenCloud Admin role", async ({ browser }) => {
skipUnlessServiceEnabled("sso");
expect(
await signedInRoleIds(browser, adminUsername, adminPassword),
"the administrator role group must map to the OpenCloud Admin role",
).toEqual([OPENCLOUD_ROLE_IDS.admin]);
});
for (const promotion of PROMOTIONS) {
test(`rbac: membership in the ${promotion.group} group gives biber the OpenCloud ${promotion.role} role`, async ({ browser }) => {
skipUnlessServiceEnabled("sso");
test.setTimeout(resolveTimeout(240_000));
const adminOpts = { adminRealm: env.adminRealm, adminClientId: env.adminClientId };
const adminContext = await browser.newContext({ ignoreHTTPSErrors: true });
let joined = false;
try {
joined = await keycloakAdminAddUserToGroup(
adminContext.request,
env.keycloakBaseUrl,
env.realmName,
promotion.groupPath,
biberUsername,
env.superAdminUsername,
env.superAdminPassword,
adminOpts,
);
expect(
await signedInRoleIds(browser, biberUsername, biberPassword),
`biber in ${promotion.groupPath} must sign in with the OpenCloud ${promotion.role} role`,
).toEqual([OPENCLOUD_ROLE_IDS[promotion.role]]);
} finally {
if (joined) {
await keycloakRemoveUserFromGroupViaRest(
adminContext.request,
env.keycloakBaseUrl,
env.realmName,
env.superAdminUsername,
env.superAdminPassword,
promotion.groupPath,
biberUsername,
adminOpts,
).catch((err) => console.warn(`Cleanup removal of biber from ${promotion.groupPath} failed: ${err}`));
}
await adminContext.close().catch(() => {});
}
expect(
await signedInRoleIds(browser, biberUsername, biberPassword),
`leaving ${promotion.groupPath} must give biber the OpenCloud User role back at the next sign-in`,
).toEqual([OPENCLOUD_ROLE_IDS.user]);
});
}
+7
View File
@@ -0,0 +1,7 @@
---
realm_roles: true
roles:
spaceadmin:
description: Manages every project space in OpenCloud, including its members and quota
guest:
description: Signs in to OpenCloud as a guest without a personal space, working only in the spaces and shares opened to them
@@ -7,7 +7,7 @@
user: "0:0"
entrypoint:
- /bin/sh
command: ["-c", "opencloud init || true; opencloud server"]
command: ["-c", {{ OPENCLOUD_COMMAND | to_json }}]
{% include 'roles/sys-svc-container/templates/base.yml.j2' %}
{{ lookup('container_ports', ['opencloud', 'http', DOCKER_BIND_HOST]) | indent(4) }}
{{ lookup('container_volumes', service_name) | indent(4) }}
+4 -3
View File
@@ -33,7 +33,8 @@ PROXY_USER_CS3_CLAIM=username
WEB_OIDC_CLIENT_ID={{ OIDC.CLIENT.ID }}
WEB_OIDC_METADATA_URL={{ OIDC.CLIENT.DISCOVERY_DOCUMENT }}
PROXY_AUTOPROVISION_ACCOUNTS=false
GRAPH_ASSIGN_DEFAULT_USER_ROLE=true
GRAPH_ASSIGN_DEFAULT_USER_ROLE=false
OPENCLOUD_PROXY_CONFIG={{ OPENCLOUD_ROLE_ASSIGNMENT | to_json | dotenv_quote }}
WEB_OPTION_ACCOUNT_EDIT_LINK_HREF={{ OIDC.CLIENT.ACCOUNT.PROFILE_URL }}
{% endif %}
@@ -48,13 +49,13 @@ OC_LDAP_USER_OBJECTCLASS=inetOrgPerson
OC_LDAP_USER_SCHEMA_ID={{ LDAP.USER.ATTRIBUTES.ID }}
OC_LDAP_USER_SCHEMA_USERNAME={{ LDAP.USER.ATTRIBUTES.ID }}
OC_LDAP_USER_SCHEMA_MAIL={{ LDAP.USER.ATTRIBUTES.MAIL }}
OC_LDAP_USER_SCHEMA_DISPLAY_NAME={{ LDAP.USER.ATTRIBUTES.FULLNAME }}
OC_LDAP_USER_SCHEMA_DISPLAYNAME={{ LDAP.USER.ATTRIBUTES.FULLNAME }}
OC_LDAP_GROUP_BASE_DN={{ LDAP.DN.OU.GROUPS }}
OC_LDAP_GROUP_FILTER=(objectclass=groupOfNames)
OC_LDAP_GROUP_OBJECTCLASS=groupOfNames
OC_LDAP_GROUP_SCHEMA_ID=cn
OC_LDAP_GROUP_SCHEMA_GROUPNAME=cn
OC_LDAP_GROUP_SCHEMA_MEMBER=member
OC_LDAP_GROUP_SCHEMA_MEMBER={{ LDAP.RBAC.MEMBER_ATTRIBUTE }}
GRAPH_LDAP_SERVER_WRITE_ENABLED=false
OC_LDAP_DISABLE_USER_MECHANISM=none
{% endif %}
@@ -21,7 +21,14 @@ IDM_ADMIN_PASSWORD={{ OPENCLOUD_ADMIN_PASSWORD | dotenv_quote }}
IDM_ADMIN_USERNAME={{ OPENCLOUD_ADMIN_USERNAME | dotenv_quote }}
# nocheck: playwright-service-gate — persona drives the OIDC path; LDAP federation is exercised in the LDAP-only matrix variant
KEYCLOAK_ADMIN_CLI_CLIENT_ID={{ OIDC.ADMIN.CLI_CLIENT_ID | dotenv_quote }}
KEYCLOAK_ADMIN_REALM={{ OIDC.ADMIN.REALM | dotenv_quote }}
KEYCLOAK_BASE_URL={{ OIDC.URL | dotenv_quote }}
KEYCLOAK_REALM_NAME={{ OIDC.CLIENT.REALM | dotenv_quote }}
LDAP_SERVICE_ENABLED={{ lookup('config', application_id, 'services.ldap.enabled') | string | lower }}
LOGIN_PASSWORD={{ lookup('users', 'platform_administrator').password | dotenv_quote }}
@@ -42,5 +49,15 @@ PERSONA_ADMINISTRATOR_BLOCKED=true
# nocheck: persona-block-rationale — see PERSONA_ADMINISTRATOR_BLOCKED above; the OIDC callback chain also runs through OpenCloud's own /oidc-callback → /web-oidc-callback routes rather than the oauth2-proxy /openid-connect/auth pattern the helper detects (files/playwright/_shared.js:103-112).
PERSONA_BIBER_BLOCKED=true
RBAC_ADMINISTRATOR_GROUP_PATH={{ ('/' ~ lookup('rbac_group_path', application_id=application_id, role='administrator')) | dotenv_quote }}
RBAC_GUEST_GROUP_PATH={{ ('/' ~ lookup('rbac_group_path', application_id=application_id, role='guest')) | dotenv_quote }}
RBAC_SPACEADMIN_GROUP_PATH={{ ('/' ~ lookup('rbac_group_path', application_id=application_id, role='spaceadmin')) | dotenv_quote }}
SSO_SERVICE_ENABLED={{ lookup('config', application_id, 'services.sso.enabled') | string | lower }}
SUPER_ADMIN_PASSWORD={{ (OIDC.ADMIN.PASSWORD | dotenv_quote) if (OPENCLOUD_OIDC_ENABLED | bool) else '""' }}
SUPER_ADMIN_USERNAME={{ (OIDC.ADMIN.USERNAME | dotenv_quote) if (OPENCLOUD_OIDC_ENABLED | bool) else '""' }}
+23
View File
@@ -13,6 +13,29 @@ OPENCLOUD_DOMAIN: "{{ lookup('domain', application_id) }}"
OPENCLOUD_OIDC_ENABLED: "{{ lookup('config', application_id, 'services.sso.enabled') }}"
OPENCLOUD_LDAP_ENABLED: "{{ lookup('config', application_id, 'services.ldap.enabled') }}"
OPENCLOUD_PROXY_CONFIG_PATH: "{{ [lookup('volume', application_id, 'config').target, 'proxy.yaml'] | path_join }}"
OPENCLOUD_ROLE_ASSIGNMENT:
role_assignment:
driver: oidc
oidc_role_mapper:
role_claim: realm_access.roles
role_mapping:
- role_name: admin
claim_value: "{{ application_id }}-administrator"
- role_name: spaceadmin
claim_value: "{{ application_id }}-spaceadmin"
- role_name: user-light
claim_value: "{{ application_id }}-guest"
- role_name: user
claim_value: "default-roles-{{ OIDC.CLIENT.REALM }}"
OPENCLOUD_COMMAND: >-
if [ -n "$$OPENCLOUD_PROXY_CONFIG" ];
then printf '%s\n' "$$OPENCLOUD_PROXY_CONFIG" > {{ OPENCLOUD_PROXY_CONFIG_PATH | quote }};
else rm -f {{ OPENCLOUD_PROXY_CONFIG_PATH | quote }};
fi;
opencloud init || true;
opencloud server
OPENCLOUD_ADMIN_USERNAME: "admin"
OPENCLOUD_ADMIN_PASSWORD: "{{ lookup('users', 'platform_administrator').password }}"
Whitespace-only changes.
@@ -0,0 +1,5 @@
from pathlib import Path
PROJECT_ROOT: Path = Path(__file__).resolve().parents[6]
__all__ = ["PROJECT_ROOT"]
@@ -0,0 +1,115 @@
from __future__ import annotations
import importlib.util
import unittest
from . import PROJECT_ROOT
def _load():
path = PROJECT_ROOT / "roles/web-app-mattermost/filter_plugins/mattermost_rbac.py"
spec = importlib.util.spec_from_file_location("mattermost_rbac", str(path))
module = importlib.util.module_from_spec(spec)
assert spec and spec.loader
spec.loader.exec_module(module)
return module
def _user(username, roles="system_user", email=None, **extra):
return {
"username": username,
"email": email if email is not None else f"{username}@example.org",
"roles": roles,
**extra,
}
def _member(username, email=None):
return {
"username": username,
"email": email if email is not None else f"{username}@example.org",
}
class TestMattermostRbacPlan(unittest.TestCase):
def setUp(self):
self.plan = _load().mattermost_rbac_plan
def test_member_without_system_admin_is_promoted(self):
result = self.plan([_user("alice")], [_member("alice")], ["administrator"])
self.assertEqual(result, {"promote": ["alice"], "demote": []})
def test_member_username_matches_case_insensitively(self):
result = self.plan([_user("alice")], [_member("Alice")], [])
self.assertEqual(result["promote"], ["alice"])
def test_member_matches_by_email_when_the_username_differs(self):
result = self.plan(
[_user("a.smith", email="alice@example.org")],
[_member("alice", email="Alice@Example.org")],
[],
)
self.assertEqual(result["promote"], ["a.smith"])
def test_member_matching_by_username_and_email_is_promoted_once(self):
result = self.plan([_user("alice")], [_member("alice")], [])
self.assertEqual(result["promote"], ["alice"])
def test_member_holding_system_admin_is_left_alone(self):
result = self.plan(
[_user("alice", roles="system_user system_admin")], [_member("alice")], []
)
self.assertEqual(result, {"promote": [], "demote": []})
def test_non_member_holding_system_admin_is_demoted(self):
result = self.plan([_user("mallory", roles="system_admin system_user")], [], [])
self.assertEqual(result, {"promote": [], "demote": ["mallory"]})
def test_kept_platform_administrator_is_never_demoted(self):
result = self.plan(
[_user("administrator", roles="system_admin system_user")],
[],
["Administrator"],
)
self.assertEqual(result["demote"], [])
def test_member_matched_by_email_is_not_demoted(self):
result = self.plan(
[_user("a.smith", roles="system_admin", email="alice@example.org")],
[_member("alice", email="alice@example.org")],
[],
)
self.assertEqual(result["demote"], [])
def test_role_names_containing_system_admin_do_not_count(self):
result = self.plan(
[_user("bob", roles="system_user custom_system_admin_viewer")], [], []
)
self.assertEqual(result, {"promote": [], "demote": []})
def test_bots_are_neither_promoted_nor_demoted(self):
result = self.plan(
[
_user("helper-bot", roles="system_admin", is_bot=True),
_user("alice", is_bot=True),
],
[_member("alice")],
[],
)
self.assertEqual(result, {"promote": [], "demote": []})
def test_member_without_email_does_not_match_an_account_without_email(self):
result = self.plan(
[_user("mallory", roles="system_admin", email="")],
[_member("alice", email="")],
[],
)
self.assertEqual(result["demote"], ["mallory"])
def test_non_member_without_system_admin_is_untouched(self):
result = self.plan([_user("biber")], [_member("alice")], [])
self.assertEqual(result, {"promote": [], "demote": []})
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,233 @@
# frozen_string_literal: true
require "json"
require "minitest/autorun"
require "open3"
class GitlabReconcileRbacTest < Minitest::Test
SCRIPT = File.expand_path(
"../../../../../../roles/web-app-gitlab/files/ruby/reconcile_rbac.rb",
__dir__
)
PRELUDE = <<~RUBY
require "json"
class FakeErrors
def full_messages
["Email is invalid"]
end
end
class FakeUser
attr_reader :id, :username, :emails, :user_type
attr_accessor :admin, :external
def initialize(row)
@id = row.fetch("id")
@username = row.fetch("username")
@emails = row.fetch("emails")
@user_type = row.fetch("user_type")
@admin = row.fetch("admin")
@external = row.fetch("external")
@saves = row.fetch("saves")
end
def admin?
@admin
end
def external?
@external
end
def save
@saves
end
def errors
FakeErrors.new
end
end
class FakeRelation
def initialize(users)
@users = users
end
def find_each(&block)
@users.each(&block)
end
end
class User
ALL = JSON.parse(ENV.fetch("USERS")).map { |row| FakeUser.new(row) }
def self.find_by_username(username)
ALL.find { |user| user.username.casecmp?(username) }
end
def self.find_by_any_email(email)
ALL.find { |user| user.emails.any? { |known| known.casecmp?(email) } }
end
def self.where(conditions)
raise ArgumentError, conditions.inspect unless conditions == { user_type: :human }
FakeRelation.new(ALL.select { |user| user.user_type == "human" })
end
end
RUBY
# @param id [Integer] primary key of the account
# @param username [String] GitLab username
# @param emails [Array<String>] every e-mail GitLab knows for the account
# @param admin [Boolean] admin flag before the reconcile
# @param external [Boolean] external flag before the reconcile
# @param user_type [String] "human" or a bot type the reconcile must skip
# @param saves [Boolean] whether User#save succeeds
# @return [Hash] one account row for the stubbed User model
def account(id, username, emails: ["#{username}@example.org"], admin: false, external: false,
user_type: "human", saves: true)
{
"id" => id, "username" => username, "emails" => emails, "admin" => admin,
"external" => external, "user_type" => user_type, "saves" => saves,
}
end
# @param username [String] username of the role group member
# @param email [String] e-mail of the role group member
# @return [Hash] one entry of an rbac_members list
def member(username, email: "#{username}@example.org")
{ "username" => username, "email" => email }
end
# @param users [Array<Hash>] accounts the stubbed User model holds
# @param administrators [Array<Hash>] members of the administrator role
# @param externals [Array<Hash>] members of the external role
# @param keep [Array<String>] usernames that stay administrators outside the role
# @return [Array(String, String, Process::Status)] stdout, stderr and status
def reconcile(users:, administrators: [], externals: [], keep: [])
Open3.capture3(
{
"USERS" => users.to_json,
"GITLAB_RBAC_ADMINISTRATORS" => administrators.to_json,
"GITLAB_RBAC_EXTERNALS" => externals.to_json,
"GITLAB_RBAC_KEEP_ADMINS" => keep.to_json,
},
RbConfig.ruby, "-e", "#{PRELUDE}\nload ARGV[0]", SCRIPT
)
end
def test_a_member_matched_by_username_is_promoted
stdout, stderr, status = reconcile(
users: [account(1, "biber", emails: ["unrelated@example.org"])],
administrators: [member("biber", email: "other@example.org")]
)
assert_predicate status, :success?, stderr
assert_equal "[CHANGED] biber admin=true external=false\n", stdout
end
def test_a_member_matched_by_email_is_promoted
stdout, stderr, status = reconcile(
users: [account(1, "biber", emails: ["biber@example.org"])],
administrators: [member("keycloak-name", email: "Biber@Example.org")]
)
assert_predicate status, :success?, stderr
assert_equal "[CHANGED] biber admin=true external=false\n", stdout
end
def test_a_member_without_email_and_unknown_username_matches_nobody
stdout, stderr, status = reconcile(
users: [account(1, "biber", emails: [""])],
administrators: [member("ghost", email: "")]
)
assert_predicate status, :success?, stderr
assert_match(/\A\[UNCHANGED\]/, stdout)
end
def test_an_admin_outside_the_role_is_demoted
stdout, stderr, status = reconcile(users: [account(1, "biber", admin: true)])
assert_predicate status, :success?, stderr
assert_equal "[CHANGED] biber admin=false external=false\n", stdout
end
def test_a_kept_administrator_outside_the_role_stays_admin
stdout, stderr, status = reconcile(
users: [account(1, "root", admin: true)],
keep: ["ROOT"]
)
assert_predicate status, :success?, stderr
assert_match(/\A\[UNCHANGED\]/, stdout)
end
def test_a_kept_administrator_without_the_flag_is_promoted
stdout, stderr, status = reconcile(users: [account(1, "root")], keep: ["root"])
assert_predicate status, :success?, stderr
assert_equal "[CHANGED] root admin=true external=false\n", stdout
end
def test_an_external_member_is_marked_external
stdout, stderr, status = reconcile(
users: [account(1, "biber")],
externals: [member("biber")]
)
assert_predicate status, :success?, stderr
assert_equal "[CHANGED] biber admin=false external=true\n", stdout
end
def test_an_external_account_outside_the_role_loses_the_flag
stdout, stderr, status = reconcile(users: [account(1, "biber", external: true)])
assert_predicate status, :success?, stderr
assert_equal "[CHANGED] biber admin=false external=false\n", stdout
end
def test_the_administrator_role_outranks_the_external_role
stdout, stderr, status = reconcile(
users: [account(1, "biber", external: true)],
administrators: [member("biber")],
externals: [member("biber")]
)
assert_predicate status, :success?, stderr
assert_equal "[CHANGED] biber admin=true external=false\n", stdout
end
def test_bot_accounts_are_left_alone
stdout, stderr, status = reconcile(
users: [account(1, "project_bot", admin: true, user_type: "project_bot")]
)
assert_predicate status, :success?, stderr
assert_match(/\A\[UNCHANGED\]/, stdout)
end
def test_converged_flags_report_unchanged
stdout, stderr, status = reconcile(
users: [account(1, "biber", admin: true), account(2, "mapache", external: true), account(3, "guest")],
administrators: [member("biber")],
externals: [member("mapache")]
)
assert_predicate status, :success?, stderr
assert_equal "[UNCHANGED] every administrator and external flag matches the role groups\n", stdout
end
def test_a_rejected_save_fails_with_the_validation_errors
_stdout, stderr, status = reconcile(
users: [account(1, "biber", saves: false)],
administrators: [member("biber")]
)
refute_predicate status, :success?
assert_match(/\[FAIL\] could not update 'biber': Email is invalid/, stderr)
end
end