Zurab Kiknavelidze
06/01/2026, 8:40 AMRocky
06/01/2026, 8:40 AMAuthenticationOAuth2Client.java code you compiled) does not implement local caching, it will trigger the full OAuth handshake for every new connection.
To resolve this and persist the token/session, you can apply the following solutions:
1. IDE Configuration: Enable Connection Sharing
The most effective way to avoid re-authentication is to force the IDE to reuse a single connection for the entire session.
* In DBeaver:
1. Right-click your StarRocks connection and select Edit Connection.
2. Navigate to Connection settings > Shell commands or Initialization.
3. Look for "Open separate connection for each editor" and set it to NEVER.
4. Also, ensure "Keep-alive" (heartbeat) is enabled to prevent the session from timing out.
* In DataGrip:
1. Open Data Sources and Drivers (Ctrl+Alt+Shift+S).
2. Select your StarRocks data source.
3. Go to the Options tab.
4. Check the box "Single connection mode". This ensures that all SQL scripts and refreshes share the same authenticated connection.
2. Modify the Plugin Code (Token Caching)
Since you are compiling the JAR from the starrocks-jdbc-oauth2-plugin example code, you can modify the Java code to implement a local cache. The example provided in the StarRocks repository is a basic implementation of the AuthenticationPlugin interface and usually does not include persistent storage.
You can modify the AuthenticationOAuth2Client class to:
* Store the Access Token in a static variable within the class. Since JDBC drivers are typically loaded once by the IDE's classloader, a static variable will persist as long as the IDE (or the driver instance) stays open.
* Check if the cached token exists and is not expired before initiating the browser redirect/flow.
* Optional: Save the token to a temporary file (e.g., ~/.starrocks/token_cache.json) to persist it even after restarting the IDE.
3. StarRocks FE Configuration
If the token is expiring too quickly even within a single connection, you can check your StarRocks FE settings. While the identity provider (Azure AD) controls the initial token lifetime, StarRocks manages the session.
Ensure the following variables are tuned in your `fe.conf`:
* `wait_timeout`: The number of seconds the server waits for activity on a connection before closing it.
* `interactive_timeout`: Similar to wait_timeout but for interactive sessions.
Summary of Recommended Workflow
1. Switch to "Single Connection Mode" in your IDE first; this solves 90% of re-authentication issues.
2. If you still need multiple connections, modify the AuthenticationOAuth2Client.java code to use a static Map to cache tokens keyed by user/host, and re-compile your JAR.
References
• administration/user_privs/authentication/oauth2_authentication.md
• integrations/authenticate_to_azure_storage.mdZurab Kiknavelidze
06/01/2026, 11:31 AMRocky
06/01/2026, 11:32 AMAuthenticationOAuth2Client plugin acts as the bridge. When the FE asks the new connection to authenticate via OAuth, the plugin triggers the flow. If the plugin doesn't have a local cache of the token, it starts the browser/redirect process from scratch.
How to achieve "Persistent" authentication
Since the FE cannot automatically link two different TCP connections without a fresh credential, you must handle the persistence at the client level.
1. Modify the Plugin Code (Recommended)
The code in the starrocks-jdbc-oauth2-plugin repository is a reference implementation and is intentionally simple—it does not include logic to save tokens to disk or memory.
To fix this, you can modify the Java code you are using to build the JAR:
* Static Memory Cache: Store the accessToken in a static variable within the plugin class. Because the IDE loads the JDBC driver (and your plugin JAR) into its memory once, a static variable will persist as long as the IDE is open. Before the plugin starts a new OAuth flow, it should check if this static variable holds a valid, non-expired token.
* Disk Cache: For persistence across IDE restarts, have the plugin write the token to a local file (e.g., ~/.starrocks/oauth_token.json).
2. IDE "Single Connection" Mode
If you don't want to modify code, you can force your IDE to stop opening new connections for every task:
* DataGrip: Go to Data Source Properties > Options and enable "Single connection mode". This forces all tabs and refreshes to use the same authenticated TCP connection.
* DBeaver: Go to Connection Settings > Initialization and set "Open separate connection for each editor" to Never.
3. Token Expiration
Check if your Azure AD tokens have a very short TTL (Time to Live). If the token expires quickly, even the FE-side session will be invalidated, forcing a re-auth even within the same connection. You can increase the token lifetime in your Azure AD app registration settings if necessary.
Summary
The FE node does save the token for the duration of a single connection session, but it cannot share that state with a new connection. To avoid repeated logins, the JDBC plugin must be the one to "remember" the token and present it to the FE during the handshake of any subsequent connections.
For more details on the JDBC plugin's interaction, you can review the StarRocks OAuth 2.0 Documentation.
References
• administration/management/FE_configuration.md
• administration/user_privs/authentication/oauth2_authentication.mdZurab Kiknavelidze
06/01/2026, 3:11 PMRocky
06/01/2026, 3:12 PMstatic variables in your AuthenticationOAuth2Client class will persist as long as the IDE remains open.
* The Flow: New Tab Opened → New TCP Connection → FE sends Auth Challenge → JDBC Driver calls your Plugin → Plugin checks its internal static cache → If token exists, plugin sends it immediately (no browser popup).
* The Problem: The current reference code in the StarRocks repository is a simple "Getting Started" example. It does not implement any caching, so it initiates a full browser flow every single time it is called.
2. How to "Fix" the Plugin Code
To stop the re-authentication, you should modify the Java code you compiled. You can add a simple in-memory cache like this:
java
public class AuthenticationOAuth2Client implements AuthenticationPlugin {
// This static variable stays in memory for all connections in the IDE
private static String cachedToken = null;
private static long expiryTime = 0;
@Override
public void setAuthenticationParameters(String user, String password) { ... }
@Override
public byte[] nextAuthenticationStep(byte[] data) {
// 1. Check if we have a valid token in memory
if (cachedToken != null && System.currentTimeMillis() < expiryTime) {
return cachedToken.getBytes();
}
// 2. If not, perform the browser flow (existing logic)
String newToken = performOAuthFlow();
// 3. Save to static cache for the NEXT tab/connection
cachedToken = newToken;
expiryTime = System.currentTimeMillis() + (3600 * 1000); // e.g., 1 hour
return cachedToken.getBytes();
}
}
3. Why the FE cannot "save" this for you
From the perspective of the StarRocks FE node, a new TCP connection is a "blank slate." Because the MySQL protocol (which StarRocks uses) is connection-oriented but doesn't use "session cookies" like a web browser, the FE has no way of knowing that the person connecting on Port 54321 (Tab A) is the same person now connecting on Port 54322 (Tab B) until they present a credential.
Alternative: The "No-Code" Fix
If you don't want to re-compile the JAR with caching logic, you must tell the IDE to stop opening new TCP connections:
* DataGrip: Right-click Data Source → Properties → Options → Check "Single connection mode".
* DBeaver: Connection Properties → General → Connection Type (or Initialization) → Set "Open separate connection for each editor" to Never.
Summary: The FE requires authentication for every new TCP connection. To avoid the browser popup, your JDBC plugin must be "smart" enough to remember the token from the last time it was called and reuse it for that same IDE session persistence.
References
• administration/user_privs/authentication/oauth2_authentication.md
• administration/user_privs/authentication/security_integration.md
References
• administration/user_privs/authentication/oauth2_authentication.md
• administration/user_privs/authorization/ranger_plugin.mdZurab Kiknavelidze
06/01/2026, 3:16 PMRocky
06/01/2026, 3:17 PMauthentication_oauth2 flow in StarRocks.
In the OAuth 2.0 (Authorization Code) flow used by StarRocks, the JDBC plugin is essentially a "browser launcher." You are right that the token is fetched by the FE, not the plugin. Here is why this prevents the plugin from caching anything:
1. The Handshake: When you open a new tab, the IDE opens a new TCP connection. The FE tells the plugin: "Go to this Azure AD URL."
2. The Exchange: You authenticate in the browser, and Azure AD redirects back to the FE's HTTP port (usually 8030). The FE exchanges the code for the token.
3. The Result: The FE validates the token and tells the waiting MySQL connection (on port 9030) that it is now logged in. The JDBC plugin never actually sees or touches the Access Token.
Because the plugin has no token, it has nothing to cache. Every new connection is a "blank slate" to the FE.
How to achieve persistence
To stop the re-authentication prompts, you have two options:
Option 1: Use "Single Connection Mode" (Recommended)
This is the standard solution for IDEs like DataGrip and DBeaver. Instead of fixing the protocol, you prevent the IDE from opening new connections.
* DataGrip: Right-click your Data Source -> Properties -> Options -> Check "Single connection mode".
* DBeaver: Connection Properties -> General -> Connection Type (or Initialization) -> Set "Open separate connection for each editor" to Never.
* Result: All your SQL windows and table refreshes will travel over the one connection that has already been authenticated.
Option 2: Switch to JWT Authentication (The "Cacheable" Way)
If you want the JDBC plugin to truly "persist" a token and avoid the browser entirely after the first login, you should switch your StarRocks user to use authentication_jwt instead of authentication_oauth2.
* How it works: In the JWT flow, the client (plugin) is responsible for providing the token.
* Modification: You would modify your Java plugin to use the MSAL (Microsoft Authentication Library). The plugin would:
1. Check a local file (e.g., ~/.starrocks/token_cache.json) for a valid token.
2. If it exists, send it to StarRocks as the "password."
3. If not, perform a device code flow or interactive login, get the token, save it locally, and then send it.
* StarRocks Setup: You would change the user's authentication method:
sql
ALTER USER 'your_user' IDENTIFIED WITH authentication_jwt AS '{"jwks_url": "...", "issuer": "..."}';
Summary
The authentication_oauth2 method is designed for a browser-based "handshake" where the server (FE) holds the credentials. Because the plugin is bypassed during the token exchange, it cannot help with persistence. Enabling "Single Connection Mode" in your IDE is the most immediate and effective fix for your workflow.
References
• administration/user_privs/authentication/oauth2_authentication.md
• administration/user_privs/authentication/jwt_authentication.md
References
• administration/user_privs/authentication/oauth2_authentication.md
• administration/management/FE_configuration.mdZurab Kiknavelidze
06/01/2026, 3:18 PMRocky
06/01/2026, 3:18 PM