Skip to content

Nextcloud Storage Setup Guide

This guide sets up a Waldur offering that sells shared Nextcloud storage. Each order becomes a Nextcloud Team folder (Group Folders app) with the ordered quota, the project team gets access to it, and users log in to Nextcloud through the same Keycloak realm as Waldur.

With preprovision_users on, the site agent creates each member's Nextcloud account as soon as they get access in Waldur, so a user who orders storage before ever opening Nextcloud finds the folder waiting at their first login.

The screenshots were taken on a local stack: Nextcloud 31.0.14 with user_oidc 8.13.0 and Team folders (groupfolders), Keycloak 26.0.7, and Waldur develop (December 2026).

How it works

1
2
3
4
5
6
7
8
9
Waldur order / team change
        │
        ▼
waldur-site-agent (nextcloud backend) ── OCS API as a Nextcloud admin ──▶ Nextcloud
        │                                                                 ├─ group  waldur-<resource uuid>
        │                                                                 ├─ Team folder, quota from the order
        │                                                                 └─ accounts, created through user_oidc
        ▼
first login: Nextcloud ──OIDC──▶ Keycloak ──▶ back into the account the agent created
Waldur Nextcloud
Resource Group waldur-<resource uuid> and a Team folder <project>/<resource>-<uuid prefix>
Storage limit (GiB) Team folder quota
Offering user (username) Account with that uid, created through user_oidc
Project member added / removed Account added to / removed from the group

The account is created through user_oidc's provisioning API, so it belongs to the identity provider: it has no password, no welcome email is sent, and the user's first Keycloak login lands in it because user_oidc finds the account by provider and uid claim.

Prerequisites

  • Nextcloud 29 or newer, served over HTTPS, with an admin account (or app password) for the agent.
  • The OpenID Connect user backend app (user_oidc) 6.1.0 or newer, and Team folders (groupfolders; called Group Folders before Nextcloud 31).
  • A Keycloak realm that Waldur users sign in with, so a Waldur username and the Keycloak preferred_username are the same string.
  • A Waldur organization registered as a service provider, and the site agent installed with the waldur-site-agent-nextcloud plugin.

Step 1: Create the Keycloak client

In the realm your users sign in with, create an OpenID Connect client for Nextcloud:

Field Value
Client ID nextcloud
Client authentication On (confidential client)
Authentication flow Standard flow only
Valid redirect URIs https://<nextcloud>/apps/user_oidc/code (plus /index.php/… without pretty URLs)
Web origins https://<nextcloud>

Copy the client secret from the Credentials tab.

Keycloak client for Nextcloud

Step 2: Configure Nextcloud

2.1 Install the apps

1
2
occ app:install user_oidc
occ app:install groupfolders

2.2 Register Keycloak as an OpenID Connect provider

1
2
3
4
5
6
7
8
occ user_oidc:provider keycloak \
  --clientid=nextcloud \
  --clientsecret='<client secret>' \
  --discoveryuri=https://<keycloak>/realms/<realm>/.well-known/openid-configuration \
  --mapping-uid=preferred_username \
  --mapping-email=email \
  --mapping-display-name=name \
  --unique-uid=0

Two settings matter for the agent:

  • User ID mapping must be preferred_username: the account's uid is then the Keycloak username, which is the name Waldur sends.
  • Use unique user ID must be off. With it on, user_oidc stores every account under a hash of provider and user id, and the agent refuses to pre-provision (see Troubleshooting).

The same settings in Administration settings → OpenID Connect:

Registered OpenID Connect provider

User ID mapping and unique user ID

Note the provider's numeric id, which goes into the agent configuration as oidc_provider_id:

1
2
3
4
5
6
$ occ user_oidc:provider
+----+------------+---------------------------------------------------------------+-----------+
| ID | Identifier | Discovery endpoint                                            | Client ID |
+----+------------+---------------------------------------------------------------+-----------+
| 1  | keycloak   | https://<keycloak>/realms/<realm>/.well-known/openid-configuration | nextcloud |
+----+------------+---------------------------------------------------------------+-----------+

2.3 Harden account matching

With "unique user ID" off, a Keycloak user whose username equals an existing local Nextcloud account logs in as that account — on a default install, a Keycloak user called admin becomes the Nextcloud admin. Turn off soft auto-provisioning, which is what links the two, and let only the agent create accounts:

1
2
occ config:system:set user_oidc soft_auto_provision --value=false --type=boolean
occ config:system:set user_oidc disable_account_creation --value=true --type=boolean
Setting Effect
soft_auto_provision=false A login whose uid matches a local account is refused ("user conflict"), not merged
disable_account_creation=true A Keycloak user Waldur has not provisioned cannot create an account by logging in

Both were checked on the stack above: the provisioning API and the accounts it created keep working. Leave disable_account_creation off if people outside Waldur also use this Nextcloud.

Step 3: Create the offering in Waldur

3.1 New offering

In the service provider's organization open Service provider → Service catalog → Offerings and click Add:

Field Value
Name Nextcloud Storage
Category Storage
Type Waldur site agent

New offering dialog

The offering UUID in the editor's URL is the agent's waldur_offering_uuid.

3.2 Offering users

Under Edit → Integration → User management:

  • Offering users → Enable automatic creation of offering users: on. Without it a project member gets no offering user and is never synced.
  • Accounts → Username generation policy: a policy that yields the Keycloak preferred_username. When Waldur users sign in through the same realm, that is Waldur username.

Automatic creation of offering users

Username generation policy

The agent provisions Nextcloud accounts under the offering username, never the Waldur username, and only for offering users in state OK.

3.3 Storage component and plan

Under Accounting → Components, add one component:

Field Value
Name / type Storage / storage
Billing type Limit-based
Unit GiB

Storage component

Add a plan under Accounting → Plans with a price per GiB, then Activate the offering.

Plan with a price per GiB

Step 4: Configure the site agent

 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
offerings:
  - name: "Nextcloud Storage"
    waldur_api_url: "https://waldur.example.com/api/"
    waldur_api_token: "<site agent token>"
    waldur_offering_uuid: "<offering uuid>"
    backend_type: "nextcloud"
    order_processing_backend: "nextcloud"
    membership_sync_backend: "nextcloud"
    reporting_backend: "nextcloud"
    stomp_enabled: true
    backend_settings:
      nextcloud_url: "https://nextcloud.example.com"
      admin_username: "waldur-agent"
      admin_password: "<app password>"
      group_prefix: "waldur-"
      default_storage_quota_gb: 25
      allow_resharing: false
      preprovision_users: true
      oidc_provider_id: 1
    backend_components:
      storage:
        measured_unit: "GiB"
        accounting_type: "limit"
        label: "Storage"
        unit_factor: 1

admin_username must be a Nextcloud admin: the provisioning API and the provider listing are admin-only. Prefer an app password (Personal settings → Security → Devices & sessions) to the account password.

Check the configuration before starting the agent:

1
2
3
4
5
6
$ waldur_site_diagnostics -c waldur-site-agent-config.yaml
...
=== Nextcloud Backend Diagnostics ===
Pre-provision users: True
user_oidc provider keycloak (id 1) maps uid to 'preferred_username'; pre-provisioning enabled
user_oidc provider 1 usable: True

Diagnostics fail if oidc_provider_id names no provider or the provider has "unique user ID" on.

Step 5: Order storage

A project member orders the offering from the service catalog and sets the storage limit:

Order form

Depending on the organization's settings the order waits for consumer and provider approval. Once approved, the agent creates the group and the Team folder, pre-provisions the project team and adds them to the group. The resource turns OK; its backend id is the Team folder id.

Resource in Waldur

The agent log for the order:

1
2
3
4
5
6
7
Created Nextcloud folder 1 ('Demo Project/team-share-8458ef69') for resource 8458ef69-… with 10 GiB quota
Team members at resource creation: count=2, usernames=['manager', 'member']
user_oidc provider keycloak (id 1) maps uid to 'preferred_username'; pre-provisioning enabled
Pre-provisioned Nextcloud user manager (uid manager)
Added user manager to group waldur-8458ef69-b00b-4ca4-8b91-894e6f9ff483
Pre-provisioned Nextcloud user member (uid member)
Added user member to group waldur-8458ef69-b00b-4ca4-8b91-894e6f9ff483

In Nextcloud the accounts exist before anyone has logged in, and the folder carries the ordered quota:

Pre-provisioned accounts

Team folder with quota

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
$ occ user:info manager --output=json_pretty
{
    "user_id": "manager",
    "display_name": "Project Manager",
    "email": "manager@demo.waldur.com",
    ...
    "groups": [
        "waldur-8458ef69-b00b-4ca4-8b91-894e6f9ff483"
    ],
    ...
    "first_seen": "never",
    "last_seen": "never",
    ...
    "backend": "user_oidc"
}

backend: user_oidc and first_seen: never are what pre-provisioning produces: an account of the identity provider that has not been used yet.

Step 6: First login

The user picks Login with keycloak (the button shows the provider's identifier) and signs in:

Nextcloud login page

Keycloak sign-in

They land in the pre-provisioned account — same uid, same group — and find the folder under Team folders:

The team folder after the first login

Team changes

Membership sync (or STOMP events) keeps the group in line with the project team. Adding owner to the project and removing member:

1
2
3
4
Resource stale usernames (1): member
Pre-provisioned Nextcloud user owner (uid owner)
Added user owner to group waldur-8458ef69-b00b-4ca4-8b91-894e6f9ff483
Removed user member from group waldur-8458ef69-b00b-4ca4-8b91-894e6f9ff483

Removal takes the user out of the group, so the folder disappears from their files; the account itself stays, since the user may own other files. Terminating the resource deletes the Team folder and the group.

Troubleshooting

oidc_provider_id=… matches no user_oidc provider

user_oidc does not check the provider id it is given: for an unknown id it would create the account under a hash. The agent therefore reads the provider list first and pre-provisions nobody until the id matches. Fix oidc_provider_id (occ user_oidc:provider); no restart is needed.

… has 'unique user id' on … not pre-provisioning users

Turn the setting off: occ user_oidc:provider keycloak --unique-uid=0. Accounts created while it was on are named by hashes and are not linked to the usernames Waldur sends.

user_oidc created the account for alice as '5f2b9c…', not as the username

The account was created under a hash, typically on a user_oidc release without the provider listing, so the up-front check could not run. The agent does not add it to the group: access granted to a hash could never be removed again. Fix the provider, then delete the stray account with the command from the log line (occ user:delete <uid>).

"You must access Nextcloud with HTTPS to use OpenID Connect"

user_oidc refuses OIDC logins over plain HTTP. Serve Nextcloud over HTTPS, or set overwriteprotocol to https behind a TLS-terminating proxy. For a throwaway local test only: occ config:app:set user_oidc allow_insecure_http --value=1 --type=boolean --lazy.

Login refused with "user conflict"

With soft_auto_provision=false, a Keycloak user whose username matches a local (non-OIDC) Nextcloud account cannot log in. That is the protection from step 2.3. Rename the local account or the Keycloak user.

The folder is missing for a user

  • Is the user's offering user in state OK, and is its username their Keycloak preferred_username? The agent provisions and adds the offering username only.
  • A WebDAV client that opens a path inside the folder directly, without ever listing the root, can get a 404 right after being added to the group; Nextcloud refreshes a user's mounts on a root listing, which the web UI and desktop clients do.

Reproducing this setup locally

The screenshots come from this stack; HTTPS is replaced by allow_insecure_http, which is for local testing only. Keycloak is reached as host.docker.internal:18180 from both the browser and the Nextcloud container (map that name to 127.0.0.1 on the host).

1
2
3
4
5
6
7
docker network create nc
docker run -d --name kc --network nc -p 18180:8080 \
  -e KC_BOOTSTRAP_ADMIN_USERNAME=admin -e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
  -e KC_HOSTNAME=http://host.docker.internal:18180 quay.io/keycloak/keycloak:26.0.7 start-dev
docker run -d --name nc --network nc -p 18181:80 --add-host host.docker.internal:host-gateway \
  -e SQLITE_DATABASE=nc -e NEXTCLOUD_ADMIN_USER=admin -e NEXTCLOUD_ADMIN_PASSWORD=adminpass123 \
  -e NEXTCLOUD_TRUSTED_DOMAINS=localhost nextcloud:31-apache

Then follow steps 1–6 with http://localhost:18181 as the Nextcloud URL (docker exec -u www-data nc php occ … for the occ commands), and create Keycloak users with the same usernames as the Waldur users. After installing user_oidc in step 2.1, allow plain HTTP:

1
docker exec -u www-data nc php occ config:app:set user_oidc allow_insecure_http --value=1 --type=boolean --lazy