From daf57957dfe71c41a000cd31470f92893092958f Mon Sep 17 00:00:00 2001 From: Manan Bhatt Date: Tue, 5 May 2026 17:15:39 +0000 Subject: [PATCH] fix: skip token exchange when no credentials configured (OSS Conductor) When no KeyId/KeySecret are provided in OrkesAuthenticationSettings, calling GetToken() would proceed to POST /api/token which returns 404/405 on OSS Conductor, causing an unhandled exception. Fix: return null early in both GetToken() and RefreshToken() when credentials are null or empty, so unauthenticated OSS deployments work without throwing. --- .../Client/Authentication/TokenHandler.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Conductor/Client/Authentication/TokenHandler.cs b/Conductor/Client/Authentication/TokenHandler.cs index e743e29a..a1fb8fd2 100644 --- a/Conductor/Client/Authentication/TokenHandler.cs +++ b/Conductor/Client/Authentication/TokenHandler.cs @@ -33,6 +33,14 @@ public TokenHandler() public string GetToken(OrkesAuthenticationSettings authenticationSettings, TokenResourceApi tokenClient) { + // OSS Conductor: if no credentials are configured, skip token exchange entirely. + if (authenticationSettings == null || + string.IsNullOrEmpty(authenticationSettings.KeyId) || + string.IsNullOrEmpty(authenticationSettings.KeySecret)) + { + return null; + } + string token = (string)_memoryCache.Get(authenticationSettings); if (token != null) { @@ -43,6 +51,14 @@ public string GetToken(OrkesAuthenticationSettings authenticationSettings, Token public string RefreshToken(OrkesAuthenticationSettings authenticationSettings, TokenResourceApi tokenClient) { + // OSS Conductor: if no credentials are configured, skip token exchange entirely. + if (authenticationSettings == null || + string.IsNullOrEmpty(authenticationSettings.KeyId) || + string.IsNullOrEmpty(authenticationSettings.KeySecret)) + { + return null; + } + lock (_lockObject) { string token = GetTokenFromServer(authenticationSettings, tokenClient); @@ -80,4 +96,4 @@ private string GetTokenFromServer(OrkesAuthenticationSettings authenticationSett throw new Exception("Failed to refresh authentication token"); } } -} \ No newline at end of file +}