Skip to content

Commit f8d478c

Browse files
author
Olivier Gintrand
committed
feat: expose token_endpoint_auth_method in gateway admin UI
Add a dropdown to the gateway add and edit forms allowing admins to select between client_secret_post (default) and client_secret_basic for the OAuth2 token endpoint authentication method (RFC 6749 Section 2.3). Some OAuth providers (e.g. Freshworks/Freshservice) require client_secret_basic (HTTP Basic Auth header) rather than the default client_secret_post (credentials in POST body). Without this UI field, reconfiguring a gateway through the admin panel silently drops the token_endpoint_auth_method setting, causing token exchange failures. Changes: - admin.py: Read oauth_token_endpoint_auth_method from form data in both admin_add_gateway and admin_edit_gateway - admin.html: Add select dropdown in both add and edit gateway forms - admin.js: Populate the dropdown with existing value when editing Fixes #3991 Signed-off-by: Olivier Gintrand <olivier.gintrand@forterro.com>
1 parent 6c567f7 commit f8d478c

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

mcpgateway/admin.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11930,6 +11930,11 @@ async def admin_add_gateway(request: Request, db: Session = Depends(get_db), use
1193011930
if scopes:
1193111931
oauth_config["scopes"] = scopes
1193211932

11933+
# Token endpoint auth method (RFC 6749 Section 2.3)
11934+
oauth_token_endpoint_auth_method = str(form.get("oauth_token_endpoint_auth_method", ""))
11935+
if oauth_token_endpoint_auth_method:
11936+
oauth_config["token_endpoint_auth_method"] = oauth_token_endpoint_auth_method
11937+
1193311938
LOGGER.info(f"✅ Assembled OAuth config from UI form fields: grant_type={oauth_grant_type}, issuer={oauth_issuer}")
1193411939
LOGGER.info(f"DEBUG: Complete oauth_config = {oauth_config}")
1193511940

@@ -12202,6 +12207,11 @@ async def admin_edit_gateway(
1220212207
if scopes:
1220312208
oauth_config["scopes"] = scopes
1220412209

12210+
# Token endpoint auth method (RFC 6749 Section 2.3)
12211+
oauth_token_endpoint_auth_method = str(form.get("oauth_token_endpoint_auth_method", ""))
12212+
if oauth_token_endpoint_auth_method:
12213+
oauth_config["token_endpoint_auth_method"] = oauth_token_endpoint_auth_method
12214+
1220512215
LOGGER.info(f"✅ Assembled OAuth config from UI form fields (edit): grant_type={oauth_grant_type}, issuer={oauth_issuer}")
1220612216

1220712217
user_email = get_user_email(user)

mcpgateway/static/admin.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6306,6 +6306,9 @@ async function editGateway(gatewayId) {
63066306
);
63076307
const oauthIssuerField = safeGetElement("oauth-issuer-gw-edit");
63086308
const oauthScopesField = safeGetElement("oauth-scopes-gw-edit");
6309+
const oauthTokenEndpointAuthMethodField = safeGetElement(
6310+
"oauth-token-endpoint-auth-method-gw-edit",
6311+
);
63096312
const oauthAuthCodeFields = safeGetElement(
63106313
"oauth-auth-code-fields-gw-edit",
63116314
);
@@ -6436,6 +6439,13 @@ async function editGateway(gatewayId) {
64366439
? config.scopes.join(" ")
64376440
: "";
64386441
}
6442+
if (
6443+
oauthTokenEndpointAuthMethodField &&
6444+
config.token_endpoint_auth_method
6445+
) {
6446+
oauthTokenEndpointAuthMethodField.value =
6447+
config.token_endpoint_auth_method;
6448+
}
64396449
}
64406450
break;
64416451
case "query_param":

mcpgateway/templates/admin.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5983,6 +5983,25 @@ <h3 class="text-lg font-bold mb-4 dark:text-gray-200">
59835983
read:user")
59845984
</p>
59855985
</div>
5986+
5987+
<div>
5988+
<label
5989+
class="block text-sm font-medium text-gray-700 dark:text-gray-300"
5990+
>
5991+
Token Endpoint Auth Method
5992+
</label>
5993+
<select
5994+
name="oauth_token_endpoint_auth_method"
5995+
id="oauth-token-endpoint-auth-method-gw"
5996+
class="mt-1 px-1.5 block w-full rounded-md border border-gray-300 dark:border-gray-700 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 dark:text-gray-300"
5997+
>
5998+
<option value="client_secret_post">client_secret_post (credentials in POST body)</option>
5999+
<option value="client_secret_basic">client_secret_basic (HTTP Basic Auth header)</option>
6000+
</select>
6001+
<p class="mt-1 text-sm text-gray-500">
6002+
How client credentials are sent to the token endpoint (RFC 6749 Section 2.3)
6003+
</p>
6004+
</div>
59866005
</div>
59876006
</div>
59886007

@@ -10255,6 +10274,25 @@ <h3 class="text-lg font-medium text-gray-900 dark:text-gray-100">
1025510274
read:user")
1025610275
</p>
1025710276
</div>
10277+
10278+
<div>
10279+
<label
10280+
class="block text-sm font-medium text-gray-700 dark:text-gray-300"
10281+
>
10282+
Token Endpoint Auth Method
10283+
</label>
10284+
<select
10285+
name="oauth_token_endpoint_auth_method"
10286+
id="oauth-token-endpoint-auth-method-gw-edit"
10287+
class="mt-1 px-1.5 block w-full rounded-md border border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 dark:text-gray-300"
10288+
>
10289+
<option value="client_secret_post">client_secret_post (credentials in POST body)</option>
10290+
<option value="client_secret_basic">client_secret_basic (HTTP Basic Auth header)</option>
10291+
</select>
10292+
<p class="mt-1 text-sm text-gray-500">
10293+
How client credentials are sent to the token endpoint (RFC 6749 Section 2.3)
10294+
</p>
10295+
</div>
1025810296
</div>
1025910297
</div>
1026010298
</div>

0 commit comments

Comments
 (0)