gowri a
03/26/2026, 8:30 AMjdbc:mysql://<fe_host>:9030/<db_name>
In this case:
The username provided in the JDBC connection is not being passed to Keycloak.
• During authentication, even after entering valid credentials, I receive a "user not found" error.
• The same user exists in both Keycloak and StarRocks.
I have tried multiple approaches, but the issue persists.
Could you please help me understand:
• Why the JDBC connection is not passing the username to Keycloak?
• Whether this is a known limitation or if any specific configuration is required?
Any guidance or documentation would be greatly appreciated.
Thanks in advance!
+ @RockyRocky
03/26/2026, 8:30 AMsub field in the JWT. In Keycloak, the sub field is usually a UUID (e.g., 550e8400-e29b...), while your StarRocks user is likely named something like alice.
* The Fix: You need to ensure the principal_field in your StarRocks configuration matches the field in Keycloak that contains the actual username (usually preferred_username).
Check your User or Security Integration configuration:
sql
-- If using Security Integration (Recommended)
CREATE SECURITY INTEGRATION keycloak_integration
PROPERTIES (
"type" = "authentication_oauth2",
"principal_field" = "preferred_username", -- Keycloak usually stores the login name here
...
);
-- Or if configuring on the specific user
ALTER USER 'your_username' IDENTIFIED WITH authentication_oauth2 AS '{
"principal_field": "preferred_username",
...
}';
Note: If it works in the MySQL client, verify that the MySQL client is actually using the same user and authentication method.
2. Username Passing and JDBC Plugin
You mentioned the username isn't being passed to Keycloak. In the OIDC Authorization Code flow, the StarRocks FE redirects your browser to Keycloak.
* Username Hint: StarRocks does not currently pass the JDBC user property as a login_hint to Keycloak's login page. This is standard OIDC behavior—the user is expected to identify themselves directly to the Identity Provider (Keycloak).
* The Handshake: Standard JDBC drivers (like mysql-connector-java) do not natively handle the interactive "Redirect URL" flow. While you can copy the URL manually, it is recommended to use the StarRocks JDBC OAuth2 Plugin.
This plugin automates the browser opening and token exchange process. You can find the implementation details in the StarRocks GitHub repository.
3. Verify FE Logs for Identity Mapping
To see exactly what username StarRocks is trying (and failing) to find, check the fe.log on your Leader FE node. Look for entries around the time of the failed login. You will likely see a log message similar to:
User [some_value] not found in StarRocks
If [some_value] is a UUID or an email address instead of your StarRocks username, it confirms that your principal_field mapping is incorrect.
4. Connection String Parameters
Ensure your JDBC connection string is not forcing a specific authentication plugin that might conflict with the OAuth2 switch:
jdbc:mysql://<fe_host>:9030/<db_name>?useSSL=false&allowPublicKeyRetrieval=true
Summary of Recommendations:
1. Check `fe.log`: Identify the exact "principal" string StarRocks is extracting from the Keycloak token.
2. Adjust `principal_field`: Set it to preferred_username (or whichever claim contains the human-readable username) in your StarRocks OAuth2 settings.
3. Check Case Sensitivity: StarRocks usernames are case-sensitive. If Keycloak returns Alice but your user is alice, it will fail.
4. Try the Plugin: If this is for an application or BI tool, use the starrocks-jdbc-oauth2-plugin to handle the flow seamlessly.
Since you are using 4.0.0-rc1, ensure your FE configuration files (fe.conf) have the global oauth2_principal_field set if you aren't defining it per-user.Rocky
03/26/2026, 8:30 AMgowri a
03/30/2026, 10:40 AMRocky
03/30/2026, 10:40 AM