Files
ocis/services/invitations
David WalterandClaude Opus 4.8 5a23c88296 feat(invitations): configurable Keycloak required actions and working ocis_full SMTP (#12467)
* feat(invitations): configurable Keycloak actions + working ocis_full SMTP

The invitations service already triggers Keycloak execute-actions-email after
provisioning a guest (service.Invite -> backend.SendMail ->
gocloak.ExecuteActionsEmail). Two things still limited it:

- The required actions were hardcoded to UPDATE_PASSWORD,VERIFY_EMAIL. They are
  now configurable via INVITATIONS_KEYCLOAK_EXECUTE_ACTIONS (comma-separated,
  same default). Unknown actions are logged and skipped, and the service falls
  back to the defaults if none remain valid so a guest always has a setup path.

- The Keycloak realm shipped with the ocis_full example had an empty smtpServer,
  so Keycloak silently dropped every mail it tried to send, including the guest
  invitation mail. The realm now points SMTP at the bundled mailpit
  (mailserver:1025).

Verified: execute-actions-email delivers to mailpit against the ocis_full realm;
go test ./services/invitations/... ./ocis-pkg/keycloak/... -race passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: David Walter <david.walter@kiteworks.com>

* fix(invitations): return the created user as invitedUser in the response

service.Invite echoed the request body unchanged, leaving the invitedUser
relation of the Graph invitation response empty, so a client could not learn
the identity of the guest that was just created. The keycloak backend now
records the created user (OWNCLOUD_ID, email, user type) on the invitation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: David Walter <david.walter@kiteworks.com>

* refactor(invitations): pass Keycloak actions through verbatim (no allowlist)

Address review (@kobergj): the configured execute-actions no longer need to
match a hardcoded enum. UserAction is now a string type passed to Keycloak
as-is, so operators can configure any required action their Keycloak supports
without oCIS keeping a list in sync. The convenience constants remain, the
default (UPDATE_PASSWORD, VERIFY_EMAIL) is unchanged, and validation is left to
Keycloak. Removes UserActionFromString and the two lookup maps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: David Walter <david.walter@kiteworks.com>

---------

Signed-off-by: David Walter <david.walter@kiteworks.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-31 15:54:23 +02:00
..
2023-04-12 18:40:41 +02:00

Invitations

The invitations service provides an Invitation Manager that can be used to invite external users, aka guests, to an organization.

  • Users invited via the Invitation Manager (via the libre graph API) will have the userType="Guest".
  • Users belonging to the organization have the userType="Member".

The corresponding CS3 API user types used to reperesent this are: USER_TYPE_GUEST and USER_TYPE_PRIMARY.

Provisioning Backends

When Infinite Scale is used via the IDM service for the user management, users are created using the /graph/v1.0/users endpoint via the libre graph API. For larger deployments, the Keycloak admin API can be used to provision users. In a future step, the endpoint, credentials and body might be made configurable using templates.

Keycloak

The default and currently only available backend used to handle invitations is Keycloak. Keycloak is an open source identity and access management (IAM) system which is also integrated by other Infinite Scale services as an authentication and authorization backend.

Keycloak Realm Configuration

See the example configuration json file of a Keycloak realm the backend will work with. This file includes the invitations client, which is relevant for this service.

To use the example json, set the INVITATIONS_KEYCLOAK_CLIENT_ID setting to invitations, though any other client ID can be configured.

Importing this example into Keycloak will give you a realm that federates with an LDAP server, has the right clients configured and all mappers correctly set. Be sure to set all the credentials after the import, as they will be disabled.

The most relevant bits are the mappers for the OWNCLOUD_ID and OWNCLOUD_USER_TYPE user properties.

Backend Configuration

After Keycloak has been configured, the invitation service needs to be configured with the following environment variables:

  • INVITATIONS_KEYCLOAK_BASE_PATH: The URL to access Keycloak.
  • INVITATIONS_KEYCLOAK_CLIENT_ID: The client ID of the client to use. In the above example, invitations is used.
  • INVITATIONS_KEYCLOAK_CLIENT_SECRET: The client secret used to authenticate. This can be found in the Keycloak UI.
  • INVITATIONS_KEYCLOAK_CLIENT_REALM: The realm where the client was added. In the example above, ocis is used.
  • INVITATIONS_KEYCLOAK_USER_REALM: The realm where to add the users. In the example above, ocis is used.
  • INVITATIONS_KEYCLOAK_INSECURE_SKIP_VERIFY: If set to true, the verification of the Keycloak HTTPS certificate is skipped. This is not recommended in production environments.

Bridging Provisioning Delay

Consider that when a guest account has to be provisioned in an external user management, there might be a delay between creating the user and the user being available in the local Infinite Scale system.