Skip to content

Commit 76e5fb2

Browse files
author
Olivier Gintrand
committed
feat: expose token_endpoint_auth_method in gateway admin UI
Add a dropdown selector for token_endpoint_auth_method (RFC 6749 Section 2.3) to both the gateway create and edit forms. Supports client_secret_post (default) and client_secret_basic methods. Changes: - admin.py: Parse token_endpoint_auth_method from form data in add/edit endpoints - admin.html: Add select dropdown to create and edit gateway modals - gateways.js: Populate field value when editing existing gateways
1 parent a2aa82a commit 76e5fb2

3 files changed

Lines changed: 58 additions & 0 deletions

File tree

mcpgateway/admin.py

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

12142+
# Token endpoint auth method (RFC 6749 Section 2.3)
12143+
oauth_token_endpoint_auth_method = str(form.get("oauth_token_endpoint_auth_method", ""))
12144+
if oauth_token_endpoint_auth_method:
12145+
oauth_config["token_endpoint_auth_method"] = oauth_token_endpoint_auth_method
12146+
1214212147
LOGGER.info(f"✅ Assembled OAuth config from UI form fields: grant_type={oauth_grant_type}, issuer={oauth_issuer}")
1214312148
LOGGER.info(f"DEBUG: Complete oauth_config = {oauth_config}")
1214412149

@@ -12411,6 +12416,11 @@ async def admin_edit_gateway(
1241112416
if scopes:
1241212417
oauth_config["scopes"] = scopes
1241312418

12419+
# Token endpoint auth method (RFC 6749 Section 2.3)
12420+
oauth_token_endpoint_auth_method = str(form.get("oauth_token_endpoint_auth_method", ""))
12421+
if oauth_token_endpoint_auth_method:
12422+
oauth_config["token_endpoint_auth_method"] = oauth_token_endpoint_auth_method
12423+
1241412424
LOGGER.info(f"✅ Assembled OAuth config from UI form fields (edit): grant_type={oauth_grant_type}, issuer={oauth_issuer}")
1241512425

1241612426
user_email = get_user_email(user)

mcpgateway/admin_ui/gateways.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ export const editGateway = async function (gatewayId) {
400400
const oauthRedirectUriField = safeGetElement("oauth-redirect-uri-gw-edit");
401401
const oauthIssuerField = safeGetElement("oauth-issuer-gw-edit");
402402
const oauthScopesField = safeGetElement("oauth-scopes-gw-edit");
403+
const oauthTokenEndpointAuthMethodField = safeGetElement(
404+
"oauth-token-endpoint-auth-method-gw-edit"
405+
);
403406
const oauthAuthCodeFields = safeGetElement(
404407
"oauth-auth-code-fields-gw-edit"
405408
);
@@ -526,6 +529,13 @@ export const editGateway = async function (gatewayId) {
526529
? config.scopes.join(" ")
527530
: "";
528531
}
532+
if (
533+
oauthTokenEndpointAuthMethodField &&
534+
config.token_endpoint_auth_method
535+
) {
536+
oauthTokenEndpointAuthMethodField.value =
537+
config.token_endpoint_auth_method;
538+
}
529539
}
530540
break;
531541
case "query_param":

mcpgateway/templates/admin.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5965,6 +5965,25 @@ <h3 class="text-lg font-bold mb-4 dark:text-gray-200">
59655965
read:user")
59665966
</p>
59675967
</div>
5968+
5969+
<div>
5970+
<label
5971+
class="block text-sm font-medium text-gray-700 dark:text-gray-300"
5972+
>
5973+
Token Endpoint Auth Method
5974+
</label>
5975+
<select
5976+
name="oauth_token_endpoint_auth_method"
5977+
id="oauth-token-endpoint-auth-method-gw"
5978+
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"
5979+
>
5980+
<option value="client_secret_post">client_secret_post (credentials in POST body)</option>
5981+
<option value="client_secret_basic">client_secret_basic (HTTP Basic Auth header)</option>
5982+
</select>
5983+
<p class="mt-1 text-sm text-gray-500">
5984+
How client credentials are sent to the token endpoint (RFC 6749 Section 2.3)
5985+
</p>
5986+
</div>
59685987
</div>
59695988
</div>
59705989

@@ -10274,6 +10293,25 @@ <h3 class="text-lg font-medium text-gray-900 dark:text-gray-100">
1027410293
read:user")
1027510294
</p>
1027610295
</div>
10296+
10297+
<div>
10298+
<label
10299+
class="block text-sm font-medium text-gray-700 dark:text-gray-300"
10300+
>
10301+
Token Endpoint Auth Method
10302+
</label>
10303+
<select
10304+
name="oauth_token_endpoint_auth_method"
10305+
id="oauth-token-endpoint-auth-method-gw-edit"
10306+
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"
10307+
>
10308+
<option value="client_secret_post">client_secret_post (credentials in POST body)</option>
10309+
<option value="client_secret_basic">client_secret_basic (HTTP Basic Auth header)</option>
10310+
</select>
10311+
<p class="mt-1 text-sm text-gray-500">
10312+
How client credentials are sent to the token endpoint (RFC 6749 Section 2.3)
10313+
</p>
10314+
</div>
1027710315
</div>
1027810316
</div>
1027910317
</div>

0 commit comments

Comments
 (0)