Deployment and Maintenance / OIDC Login
This document uses Keycloak as an example to describe how to configure OIDC login for DataFlux Func. Field names in the Keycloak interface may vary by version; please refer to the field meanings.
This article uses configuration item names from 8.1.11 onward; when upgrading, update the user configuration accordingly; for name changes, refer to ChangeLog / 8.1.11.
1. Quick Configuration
This section uses the default dataflux-func Client ID and role configuration to quickly enable basic OIDC login. First, prepare the DataFlux Func public access base URL and the Issuer address of the Keycloak Realm; after creating the Client, you also need to obtain the Client Secret generated by Keycloak.
1.1 Create Keycloak Client
In the target Realm, navigate to "Clients" and create and configure a Client:
| Configuration Item | Value |
|---|---|
| Client type | OpenID Connect |
| Client ID | dataflux-func |
| Client authentication | On |
| Standard flow | On |
| Valid redirect URIs | https://func.example.com/api/v1/auth/oidc/callback |
| Home URL | https://func.example.com/ |
Replace the example domain with the actual public access address of DataFlux Func. Navigate to "Clients / dataflux-func / Credentials", keep the Client ID and Secret authentication method, and copy the Client Secret.
1.2 Configure DataFlux Func
Configure the following in the user configuration file user-config.yaml, and replace the public access base URL, Issuer address, and Client Secret. For standard container deployment, the in-container path is /data/user-config.yaml, and the default host path is {installation-directory}/data/user-config.yaml; for details, see Deployment and Maintenance / Data Storage Location / DataFlux Func Configuration:
| YAML | |
|---|---|
1 2 3 4 | |
DataFlux Func automatically generates the OIDC callback URL and Web client URL based on WEB_SERVER_BASE_URL. When deploying with a virtual directory, the virtual directory should be included in that address.
After modifying the configuration, restart the entire DataFlux Func; do not restart only the Server. For specific operations, refer to Deployment and Maintenance / Upgrade and Restart.
Verify OIDC first, then disable the built-in login
During the initial configuration, keep DISABLE_BUILTIN_SIGN_IN: false and keep a logged-in administrator page open. After confirming that OIDC login and roles are working normally, change it to true as needed.
1.3 Verify Login
Open the DataFlux Func login page, confirm that the 'Use OpenID Connect to log in' button appears, and log in with a Keycloak user. Users without a valid Client Role get the "user" role by default; to grant the "admin" role to a user, continue reading "2.2.3 Configure Client Role".
2. Detailed Description
The following content details the example addresses, user Claims, role mapping and synchronization policies, as well as verification and troubleshooting methods.
2.1 Preparation Information
This document uses the following example information:
| Item | Example Value |
|---|---|
| DataFlux Func public access base URL | https://func.example.com |
| Keycloak public access URL | https://sso.example.com |
| Keycloak Realm | dataflux-func |
| Keycloak Client ID | dataflux-func |
| OIDC Issuer | https://sso.example.com/realms/dataflux-func |
| OIDC callback URL | https://func.example.com/api/v1/auth/oidc/callback |
| DataFlux Func Web client URL | https://func.example.com/client-app/ |
From the network where the DataFlux Func Server is located, access the following address to confirm that Keycloak is available:
| Bash | |
|---|---|
1 | |
The issuer in the returned content must match OIDC_ISSUER_URL.
DataFlux Func automatically generates the OIDC callback URL and Web client URL based on the public access base URL. When deploying with a virtual directory, the public access base URL should include that directory, for example https://func.example.com/virtual; the corresponding URLs will be generated as https://func.example.com/virtual/api/v1/auth/oidc/callback and https://func.example.com/virtual/client-app/ respectively.
2.2 Configure Keycloak
For related fields, refer to the Keycloak Server Administration Guide and Keycloak Protocol Mappers.
2.2.1 Create Client
In the target Realm, navigate to "Clients" and create a Client:
| Configuration Item | Value |
|---|---|
| Client type | OpenID Connect |
| Client ID | dataflux-func |
| Name | DataFlux Func |
After saving, configure:
| Configuration Item | Value |
|---|---|
| Client authentication | On |
| Authorization | Off |
| Standard flow | On |
| Direct access grants | Off |
| Implicit flow | Off |
| Service accounts roles | Off |
| Valid redirect URIs | https://func.example.com/api/v1/auth/oidc/callback |
| Home URL | https://func.example.com/ |
Navigate to "Clients / dataflux-func / Credentials", keep the Client ID and Secret authentication method, and copy the Client Secret.
Safeguard the Client Secret
Do not write the real Client Secret into public documents, logs, or code repositories, and do not use it on the browser side.
2.2.2 Configure User Claims
Confirm that the Client is associated with the profile, email, and phone Client Scopes. DataFlux Func uses the following Claims by default:
| User Field | Claim |
|---|---|
| Username | preferred_username |
| Name | name |
email |
|
| Phone Number | phone_number |
2.2.3 Configure Client Role
DataFlux Func reads Client Roles from resource_access.<OIDC_CLIENT_ID>.roles first. Received role values are mapped according to OIDC_ROLE_MAPPER, and then matched against local roles. Role names and mapping keys are case-sensitive. This document only describes the local "admin" and "user" roles.
When no valid local role is matched, the user gets the "user" role by default, so regular users do not need extra configuration. The default OIDC_ROLE_MAPPER maps "dataflux-func-admin" to the local "admin" role. Configure this Client Role for administrators:
- Navigate to "Clients / dataflux-func / Roles" and create a Role named
dataflux-func-admin. - Navigate to "Users / User / Role mapping" and click [Assign role].
- Filter by Client Role, select
dataflux-func-adminunder thedataflux-funcClient, and complete the assignment.
If you need to manage members by Group, you can assign the dataflux-func-admin Client Role to a Keycloak Group, and then add users to that Group.
On the Client Scope evaluation page, check the Access Token to confirm that it contains:
| JSON | |
|---|---|
1 2 3 4 5 6 7 | |
The default OIDC_ROLE_MAPPER already includes dataflux-func-admin: "admin", and OIDC_ROLE_CLAIM_SOURCES already includes "accessToken", so the example in this document does not require additional configuration of OIDC_ROLE_MAPPER or OIDC_ROLES_CLAIM.
Strictly control the administrator Client Role
The dataflux-func-admin Client Role is mapped to the "admin" role in DataFlux Func. Do not set it as the default Role, and strictly restrict Role management permissions and members.
2.3 Configure DataFlux Func
For standard container deployment, write the following configuration to /data/user-config.yaml in the container. The corresponding default location on the host is {installation-directory}/data/user-config.yaml. For the configuration file location, refer to Deployment and Maintenance / Data Storage Location.
Configure the following in the above user configuration file user-config.yaml, and replace the example URL, Realm, and Client Secret:
| YAML | |
|---|---|
1 2 3 4 | |
When configuring, note the following:
WEB_SERVER_BASE_URLis the public base URL for browser access to DataFlux Func; it must be configured when OIDC login is enabled; onlyhttporhttpsare supported, and it must not contain user info, query parameters, or anchors- DataFlux Func removes the trailing slash from
WEB_SERVER_BASE_URL, then appends/api/v1/auth/oidc/callbackand/client-app/respectively; the generated callback URL must exactly match the Valid redirect URIs in Keycloak - When deploying with a virtual directory, the virtual directory must be included in
WEB_SERVER_BASE_URL - For
OIDC_ISSUER_URL, fill in the Issuer URL and do not append/.well-known/openid-configuration OIDC_CLIENT_IDdefaults to"dataflux-func", which is consistent with the Keycloak Client created in this document
If you need to modify the display name, Claim, Scope, role source, role mapping, sync policy, or URLs, refer to the Appendix: Complete Configuration Items at the end of this document.
After modifying the configuration, restart the entire DataFlux Func; do not restart only the Server. For specific operations, refer to Deployment and Maintenance / Upgrade and Restart.
Verify OIDC first, then disable the built-in login
During the initial configuration, keep DISABLE_BUILTIN_SIGN_IN: false and keep a logged-in administrator page open. After confirming that OIDC login and roles are working normally, change it to true as needed.
2.3.1 Select the Role Sync Policy
OIDC_ROLE_SYNC_POLICY controls when OIDC roles are written to DataFlux Func:
| Configuration Value | Behavior |
|---|---|
"always" |
Default value. Syncs roles when creating the user and on every subsequent login; if there is no valid external role after mapping, syncs to OIDC_ROLE_DEFAULT |
"initial" |
Writes roles only when the local user is first created; subsequent logins retain the existing roles in DataFlux Func |
"never" |
Ignores Client Role, OIDC_ROLES_CLAIM, and OIDC_ROLE_MAPPER; uses OIDC_ROLE_DEFAULT when creating the user and on every subsequent login |
Manual roles may be overwritten
With the default "always" policy or with "never", roles are synchronized on every OIDC login. Do not rely on manual role adjustments made to OIDC users in DataFlux Func; if you need to preserve manual adjustments, configure OIDC_ROLE_SYNC_POLICY: "initial".
2.3.2 Configure Role Mapping
OIDC_ROLE_MAPPER uses the role values returned by the identity provider as keys and DataFlux Func local roles as values, and applies to both Client Role and OIDC_ROLES_CLAIM. DataFlux Func has the following default mappings configured in the configuration file config.yaml:
| YAML | |
|---|---|
1 2 3 | |
Therefore, when the identity provider returns "dff-admin" or "dataflux-func-admin", the user gets the local "admin" role. The Keycloak example in this document uses "dataflux-func-admin", so no additional configuration is required.
If the identity provider uses "func-administrators" and "func-users", you can configure them in the user configuration file user-config.yaml:
| YAML | |
|---|---|
1 2 3 4 5 | |
Customizing OIDC_ROLE_MAPPER replaces the entire default mapping rather than appending to it. The example above also retains the two default entries; you can omit them if the default mapping is no longer needed.
Role mapping follows these rules:
- Mapping keys are matched exactly by role value and are case-sensitive
- Role values without a configured mapping remain unchanged; if the value itself is a valid local role, such as
"admin"or"user", it is used directly - Mapping results must be existing local roles; unmapped original values that are not local roles and invalid mapping results are ignored, and duplicate local roles are deduplicated
OIDC_ROLE_DEFAULTshould be filled in directly with a local role and is not mapped throughOIDC_ROLE_MAPPER
2.3.3 Use Other Role Claims
Use the OIDC_ROLES_CLAIM configuration as a fallback Claim only when the identity provider cannot provide Client Role. For example, read roles from Realm Role:
| YAML | |
|---|---|
1 | |
The Claim can be a single value or an array. Each role value is first mapped through OIDC_ROLE_MAPPER and then matched against local roles, so it can return either a mapping key or a valid local role directly. In each Claim source, valid Client Role after mapping takes precedence over OIDC_ROLES_CLAIM.
Role claims are read in the following order by default, and reading stops once the first source containing a valid role is found:
| YAML | |
|---|---|
1 | |
"userInfo" is available only when OIDC_FETCH_USERINFO is enabled and the identity provider supports the UserInfo Endpoint; "accessToken" is available only when the Access Token is a JWT.
2.4 Verify Login
- Open the DataFlux Func login page and confirm that the OIDC login button appears; the default button text is 'Use OpenID Connect to log in'.
- Log in with a new user who has not been assigned a valid Client Role and confirm their role is
"user". - Log in with a new user who has been assigned the
dataflux-func-adminClient Role and confirm their local role is"admin". - With the default
"always"policy, remove the user'sdataflux-func-adminClient Role, log out and log in again, and confirm the role reverts to"user". - If you customized
OIDC_ROLE_MAPPER, assign the external role corresponding to the custom mapping key, log in again, and confirm that the local role matches the mapping result. - Verify the username, name, email, and phone number.
- Verify the actual operational permissions of both types of users.
- After logging out, confirm that the built-in administrator can still log in.
- After all checks pass, disable the built-in login as needed.
2.5 Notes
- The default
"always"policy syncs roles on every login. After a Keycloak Role changes, users need to log out and log in again; with the"initial"policy, existing user roles need to be manually adjusted in DataFlux Func. - Roles are read in the order of
OIDC_ROLE_CLAIM_SOURCESand are not merged across sources; in each source,resource_access.<OIDC_CLIENT_ID>.rolesis first mapped and filtered, and if there are no valid Client Roles,OIDC_ROLES_CLAIMis then mapped and filtered. - Both mapping keys and results in
OIDC_ROLE_MAPPERare case-sensitive; customizing this configuration in the user configuration fileuser-config.yamlreplaces the entire default mapping. OIDC_ROLES_CLAIMcan read a single value, an array, or a dot-separated nested path.- The OIDC username is not updated after creation; the name, email, and phone number are updated on subsequent logins. OIDC users should modify their profile in Keycloak.
- Logging out of DataFlux Func does not end the Keycloak SSO session. The default
{ prompt: "login" }requires Keycloak to re-authenticate; after changing it to{}, logging in again may directly reuse the Keycloak session. - After modifying
WEB_SERVER_BASE_URL, you need to update the callback URL registered with the identity provider; the virtual directory in this configuration is also used for the Web client URL after login completes. DISABLE_SIGN_IN: trueorOIDC_ENABLED: falsewill prevent existing OIDC users' local sessions from continuing to access.
Do not grant the administrator role by default
Do not configure OIDC_ROLE_DEFAULT: "admin", and do not map an external Group or Role with too broad a membership to "admin". When mapping a Claim to "admin", you must strictly restrict the members of the corresponding Keycloak Group or Role.
2.6 Troubleshooting
| Symptom | Check Item |
|---|---|
| No OIDC login button on the login page | Check OIDC_ENABLED: true, DISABLE_SIGN_IN: false, and confirm that the entire DataFlux Func has been restarted |
| Error after clicking login | Check WEB_SERVER_BASE_URL, the Keycloak address, TLS certificate, DNS, Client ID, Client Secret, and client authentication method |
| Keycloak reports invalid redirect URI | Compare Valid redirect URIs with the full address of WEB_SERVER_BASE_URL plus /api/v1/auth/oidc/callback, and check the protocol, domain, port, virtual directory, and trailing slash |
| Invalid state after callback | Complete the operation using the same browser that initiated login, and check the Cookie, shared Redis, SECRET of each Server node, and the 10-minute login timeout |
| Redirected to wrong client URL after login | Check whether WEB_SERVER_BASE_URL is the public base URL actually accessed by the browser, and whether the virtual directory in it is correct; the client URL is automatically generated as that base URL plus /client-app/ |
| User profile empty | Check OIDC_SCOPES, Client Scope, user profile, and the corresponding Claim |
| New user role incorrect | Check resource_access.<OIDC_CLIENT_ID>.roles, the case of the Role name, OIDC_ROLE_CLAIM_SOURCES, OIDC_ROLE_MAPPER, OIDC_ROLES_CLAIM, and OIDC_ROLE_DEFAULT |
| Role in Access Token not effective | Confirm the Access Token is a JWT and "accessToken" is in OIDC_ROLE_CLAIM_SOURCES; also check whether a higher-priority source already contains a valid role, whether the mapping key matches exactly, and whether the mapping result is a valid local role |
| Default admin role mapping not effective | Check whether OIDC_ROLE_MAPPER was customized in the user configuration file user-config.yaml and replaced the default mapping; if needed, add dff-admin or dataflux-func-admin back into the custom configuration |
| Existing user roles not synchronized | Check OIDC_ROLE_SYNC_POLICY; when set to "initial", manually adjust existing user roles in DataFlux Func |
| Logging in again after logout did not require authentication | Check whether OIDC_AUTHORIZATION_PARAMS has been overridden to {}, and how Keycloak handles prompt: "login" |
Appendix: Complete Configuration Items
The appendix lists the complete configuration items according to the OIDC configuration method adopted in this article.
| Configuration Item | Default Value | Example | Description |
|---|---|---|---|
WEB_SERVER_BASE_URL |
"" |
https://func.example.com |
The public base URL for browser access to DataFlux Func; required for OIDC login, the program automatically generates the callback URL and Web client URL based on this |
OIDC_ENABLED |
false |
true |
Set to true to enable OIDC login |
OIDC_ISSUER_URL |
"" |
https://sso.example.com/realms/dataflux-func |
The Issuer address of the identity provider, not including /.well-known/openid-configuration |
OIDC_CLIENT_SECRET |
"" |
— | Client Secret; required when using the default Token Endpoint authentication method |
| Configuration Item | Default Value | Description |
|---|---|---|
DISABLE_SIGN_IN |
false |
Whether to globally disable built-in, integrated, and OIDC login; must remain false when OIDC is enabled |
DISABLE_BUILTIN_SIGN_IN |
false |
Whether to disable built-in username/password login; configure to true only as needed after OIDC authentication is complete |
OIDC_DISPLAY_NAME |
"OpenID Connect" |
The identity provider name displayed on the OIDC login button; can be customized as needed |
OIDC_CLIENT_ID |
"dataflux-func" |
The Keycloak Client in this article uses the default value; configure to the corresponding value when the Client ID assigned by the identity provider differs |
OIDC_TOKEN_ENDPOINT_AUTH_METHOD |
"client_secret_basic" |
Token Endpoint authentication method; configure only when the identity provider requires "client_secret_post" or "none" |
OIDC_SCOPES |
[ "openid", "profile", "email", "phone" ] |
Requested scopes; "openid" is added automatically if not included |
OIDC_AUTHORIZATION_PARAMS |
{ prompt: "login" } |
Parameters appended to the authentication request; configure to {} only when you need to reuse an existing identity provider session |
OIDC_FETCH_USERINFO |
true |
Whether to request the UserInfo Endpoint to obtain user Claims |
OIDC_USERNAME_CLAIM |
"preferred_username" |
Username Claim path; fill in only when the identity provider uses a different Claim |
OIDC_NAME_CLAIM |
"name" |
Name Claim path; fill in only when the identity provider uses a different Claim |
OIDC_EMAIL_CLAIM |
"email" |
Email Claim path; fill in only when the identity provider uses a different Claim |
OIDC_MOBILE_CLAIM |
"phone_number" |
Phone number Claim path; fill in only when the identity provider uses a different Claim |
OIDC_ROLE_CLAIM_SOURCES |
[ "idToken", "userInfo", "accessToken" ] |
Sources and priority for reading role Claims; available values are "idToken", "userInfo", "accessToken" |
OIDC_ROLES_CLAIM |
"" |
Fallback Claim path used when no valid role remains after Client Role mapping; fill in only when the identity provider cannot provide Client Role |
OIDC_ROLE_MAPPER |
{ dff-admin: "admin", dataflux-func-admin: "admin" } |
Maps external role values from Client Role and the fallback Claim to local roles; custom configurations replace the default mapping entirely |
OIDC_ROLE_DEFAULT |
"user" |
Local role used when there is no valid external role after mapping; does not pass through OIDC_ROLE_MAPPER |
OIDC_ROLE_SYNC_POLICY |
"always" |
Role sync policy; can be changed to "initial" or "never" |