waldur-site-agent-nextcloud
Nextcloud plugin for Waldur Site Agent.
Users purchase storage plans in Waldur and automatically receive access to a shared Nextcloud Group Folder. Login is via Keycloak OIDC.
At a glance
| Entry point | Group | Role |
|---|---|---|
nextcloud |
waldur_site_agent.backends |
order processing, membership sync, reporting |
Modes: order_process, membership_sync, report, event_process (recommended).
| Operation | Behaviour |
|---|---|
| Create resource | Nextcloud group and Group Folder with the ordered quota |
| Terminate resource | Deletes the Group Folder and the group |
| Update limits | Sets the Group Folder quota |
| Add / remove members | Adds / removes users in the Nextcloud group |
| Pause | Sets the folder quota to 0 |
| Downscale | Sets the folder quota to 1 GiB |
| Restore | No-op — returns False; the quota comes back with the next limit update |
| Usage reporting | Group Folder bytes used |
How it works
- Each Waldur resource → a Nextcloud Group + Group Folder (with quota from the plan)
- Users added to the resource → added to the Nextcloud group → can access the folder
- Usage is reported as Group Folder bytes used
Prerequisites
The setup guide walks through the whole integration — Keycloak client, Nextcloud, the Waldur offering and the agent — with screenshots.
Install and enable in Nextcloud admin:
- User OIDC app (
user_oidc) — configure to point at your Keycloak realm - Team folders app (
groupfolders, called Group Folders before Nextcloud 31)
In the OIDC provider settings, set the user ID attribute to preferred_username
(matches the Keycloak username that the site-agent uses when calling the OCS API),
and turn off "unique user id". With it on, user_oidc stores each user under a
hash of the provider id and subject, and the usernames the agent sends match no one.
The usernames the agent sends are the offering usernames, so the offering's username
generation policy must produce the Keycloak preferred_username (usually "Waldur username"),
and "Enable automatic creation of offering users" must be on.
When preprovision_users is enabled, the agent creates accounts through
user_oidc's provisioning API (POST /ocs/v2.php/apps/user_oidc/api/v1/user,
user_oidc 6.1.0 or newer), not core POST /cloud/users. The account belongs
to the OIDC provider: no password (login cannot bypass the identity provider and
its MFA), no welcome email, no password reset. The user's first OIDC login lands
in the same account, because user_oidc looks users up by provider and uid claim
value in both cases. Set oidc_provider_id to the provider's numeric id:
1 | |
user_oidc does not check that id: for an unknown provider, or with "unique user id"
on, it creates the account under a sha256 hash, which the agent could add to the group
but never remove again. The agent therefore reads the provider from user_oidc's admin
listing before pre-provisioning and pre-provisions nobody while the provider is missing
or has "unique user id" on (re-checked on every sync, so no restart is needed after the
fix). If an account still comes back under another uid, it is not added to the group and
the error names the stray account to delete. waldur_site_diagnostics runs the same check.
With "unique user id" off, a Keycloak user whose username equals a local Nextcloud account
logs in as that account. Turn off soft auto-provisioning, and with preprovision_users
consider letting only the agent create accounts:
1 2 | |
Until a user's first login, the display name and email of a pre-provisioned account are the ones Waldur holds; the login replaces them with the Keycloak claims mapped in the provider settings.
The admin account in admin_username must be a Nextcloud admin (the provisioning
endpoint and the provider listing are admin-only).
Configuration example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
Backend settings reference
| Key | Default | Description |
|---|---|---|
nextcloud_url |
(required) | Base URL of the Nextcloud instance |
admin_username |
(required) | Admin account for OCS API calls |
admin_password |
(required) | Admin password or app password |
group_prefix |
"waldur-" |
Prefix prepended to every auto-created group name |
default_storage_quota_gb |
25 |
Fallback quota (GiB) when the Waldur plan has no storage limit |
allow_resharing |
false |
If false, group members cannot reshare folder contents |
preprovision_users |
false |
Create accounts via user_oidc before the group add (purchase before first login) |
oidc_provider_id |
— | user_oidc provider id (occ user_oidc:provider); required with preprovision_users |
The agent does not expand ${VAR} references in its configuration file; write the values
in, or generate the file from a template at deploy time. The settings are validated by
waldur_site_agent_nextcloud.schemas.NextcloudBackendSettingsSchema; a misspelt or missing
required key is logged as a warning when the agent loads its configuration, and the backend
refuses to start without the required ones. The backend also requires a storage component
with accounting_type: limit.
STOMP settings reference
| Key | Default | Description |
|---|---|---|
stomp_enabled |
false |
Enable STOMP event-driven processing |
stomp_membership_sync_enabled |
null |
Inherits stomp_enabled. Set false to keep HTTP polling for membership. |
team_fetch_attempts (backend-level, non-configurable)
The Nextcloud backend sets team_fetch_attempts = 4 internally.
On order-processing paths (including STOMP create-order events) the event can
arrive before Waldur has committed the initial team membership row. The agent
retries the team-member fetch up to 4 times (with a 3 s delay between
attempts) if the list comes back empty. Other backends default to 1 (no
retry); this higher value is specific to Nextcloud's create-order path.
Note: the retry only helps when the team is entirely absent. A non-empty but stale team (new member not yet committed) breaks on the first attempt.
Tests
1 | |