OpenID Connect (OIDC) Keycloak example
This short tutorial shows how to set up Studo Flow's OIDC login provider with Keycloak. Users from the Keycloak's realm then should be able to log in into Studo Flow.
You can follow this tutorial to configure your Keycloak, or use it as a reference point to configure a different OIDC compatible identity provider.
Prerequisites
This tutorial assumes the following setup:
- A Keycloak server instance
- A provisioned Flow server with a valid licence and reachable web interface
- A working networking setup where the Flow server and Keycloak can communicate
Configuration
Create a Keycloak client
First we will configure Keycloak by creating a client in the Keycloak web UI for Flow.
- Select the desired Keycloak realm, click on Clients then click on Create.
- Set a Client ID (for this tutorial we will use "studo-flow").
- As Client Protocol use "openid-connect".
- As Root URL use the following pattern "https://<FLOW_DOMAIN>" (for this tutorial we will use https://demo.studoflow.com/).
- Click Save.
- Set name and description to e.g. "Studo Flow" (these values don't impact functionality).
- Make sure Enabled is true.
- Set Access Type to "confidential".
- Set Standard Flow Enabled and Direct Access Grants Enabled to true.
- Set Front Channel Logout to false.
- Set Valid Redirect URIs to "/*".
- Set Backchannel Logout Session Required to true.
- Click Save.
- Click on the Client Scopes tab, and make sure that Assigned Default Client Scopes has the scope "email".
- Click on the Credentials tab and make sure that Client Authenticator is set to "Client Id and Secret".
Setup Flow to use the newly created Keycloak client
Go to your Flow server's web UI, and log in as an admin user.
- Go to System Configuration and click Configure login providers in the toolbar.
- Scroll down to OidcLoginProvider, set enable to "true" and click Save configuration.
- Set clientId to your newly created client's id (we will use "studo-flow").
- Set clientSecret to your client's secret (You can find this on the Credentials tab from step 15).
- Set openIdConfigUrl to your Keycloak's OpenID Endpoint Configuration URL. (In Keycloak you can find this on the General tab of the realm's configuration page. For this tutorial we will use Studo's Keyloak instance: https://keycloak-dev.functionaldude.com/auth/realms/flow-test/.well-known/openid-configuration).
Getting the userId's right
Flow gets all it's users from its importers. The userId of these users must either match
- the subject ("sub" field in the userinfo response) of the Keycloak user
- the username ("preferred_username" field in the userinfo response) of the Keycloak user
Configure the userIdField according to your needs.