Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add instructions for OIDC with keycloak

Oliver Günther63325d483e33
diff --git a/docs/installation-and-operations/misc/custom-openid-connect-providers/README.md b/docs/installation-and-operations/misc/custom-openid-connect-providers/README.md
index 914c91d1d59..8ca6d53ca04 100644
--- a/docs/installation-and-operations/misc/custom-openid-connect-providers/README.md
+++ b/docs/installation-and-operations/misc/custom-openid-connect-providers/README.md
@@ -196,3 +196,90 @@ The option takes a space-separated list of ACR values. This is functionally the
more complicated `claims` option above but with `"essential": false`.
For all other claims there is no such shorthand.
+
+
+
+## Instructions for common OIDC providers
+
+The following section contains instructions for common OpenID Connect providers. Feel free to contribute your settings through the editing functionality at the bottom of this page.
+
+
+
+### Keycloak
+
+In Keycloak, use the following steps to set up a OIDC integration for OpenProject:
+
+- Select or create a realm you want to authenticate OpenProject with. Remember that realm identifier. For the remainder of this section, we're using REALM as the placeholder you'll need to replace.
+- Under "Clients" menu, click on "Create" or "Create client"
+- **Add client**: Enter the following details
+ - **Client type / protocol**: OpenID Connect
+ - **Client ID**: `https://<Your OpenProject hostname>`
+ - **Name**: Choose any name, used only within keycloak
+- For the **Capability config**, keep Standard flow checked. In our tested version of Keycloak, this was the default.
+- Click on Save
+
+
+
+You will be forwarded to the settings tab of the new client. Change these settings:
+
+- Set **Valid redirect URIs** to `https://<Your OpenProject hostname>/auth/keycloak/*`
+- Enable **Sign Documents**
+- If you want to enable [Backchannel logout](https://openid.net/specs/openid-connect-backchannel-1_0.html), set **Backchannel logout URL** to `https://<Your OpenProject hostname>/auth/keycloak/backchannel-logout`
+
+
+
+Next, you will need to create or note down the client secret for that client.
+
+- Go to the **Credentials** tab
+- Click on the copy to clipboard button next to **Client secret** to copy that value
+
+
+
+**OPTIONAL:** By default, OpenProject will map the user's email to the login attribute in OpenProject. If you want to change that, you can do it by providing an alternate claim value in Keycloak:
+
+- Go to **Client scopes**
+- Click on the `https://<Your OpenProject hostname>-dedicated` scope
+- Click on **Add mapper** and **By configuration**
+- Select **User property**
+- Assuming you want to provide the username as `preferred_username` to OpenProject, set these values. This will depend on what attribute you want to map:
+ - Set name and to `username`
+ - Set Token claim name to `preferred_username`
+- Click on **Save**
+
+
+
+#### Setting up OpenProject for Keycloak integration
+
+In OpenProject, these are the variables you will need to set. Please refer to the above documentation for the different ways you can configure these variables:
+
+```bash
+# The name of the login button in OpenProject, you can freely set this to anything you like
+OPENPROJECT_OPENID__CONNECT_KEYCLOAK_DISPLAY__NAME="Keycloak"
+OPENPROJECT_OPENID__CONNECT_KEYCLOAK_HOST="<Hostname of the keycloak server>"
+OPENPROJECT_OPENID__CONNECT_KEYCLOAK_IDENTIFIER="https://<Your OpenProject hostname>"
+OPENPROJECT_OPENID__CONNECT_KEYCLOAK_SECRET="<The client secret you copied from keycloak>"
+OPENPROJECT_OPENID__CONNECT_KEYCLOAK_AUTHORIZATION__ENDPOINT="/realms/REALM/protocol/openid-connect/auth"
+OPENPROJECT_OPENID__CONNECT_KEYCLOAK_TOKEN__ENDPOINT="/realms/REALM/protocol/openid-connect/token"
+OPENPROJECT_OPENID__CONNECT_KEYCLOAK_USERINFO__ENDPOINT="/realms/REALM/protocol/openid-connect/userinfo"
+# Optional, if you have created the client scope mapper as shown above
+# OPENPROJECT_OPENID__CONNECT_KEYCLOAK_ATTRIBUTE__MAP_LOGIN="preferred_username"
+```
+
+
+
+## Troubleshooting
+
+**Q: After clicking on a provider badge, I am redirected to a signup form that says a user already exists with that login.**
+
+A: This can happen if you previously created user accounts in OpenProject with the same email than what is stored in the identity provider. In this case, if you want to allow existing users to be automatically remapped to the OIDC provider, you should do the following:
+
+Spawn an interactive console in OpenProject. The following example shows the command for the packaged installation.
+See [our process control guide](../../../installation-and-operations/operation/control/) for information on other installation types.
+
+```bash
+sudo openproject run console
+> Setting.oauth_allow_remapping_of_existing_users = true
+> exit
+```
+
+Then, existing users should be able to log in using their OIDC identity. Note that this works only if the user is using password-based authentication, and is not linked to any other authentication source (e.g. LDAP) or identity provider.