From 55c832c536d495deb693fa582ccfdb37551a1f24 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Mon, 6 Jan 2025 08:19:15 +0530 Subject: [PATCH] feat: do partial client method validation --- app/utils/oidc.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/utils/oidc.ts b/app/utils/oidc.ts index f90f08e..ebb6d26 100644 --- a/app/utils/oidc.ts +++ b/app/utils/oidc.ts @@ -2,7 +2,8 @@ import { redirect } from 'react-router'; import { authorizationCodeGrantRequest, calculatePKCECodeChallenge, - type Client, + Client, + ClientAuthenticationMethod, discoveryRequest, generateRandomCodeVerifier, generateRandomNonce, @@ -34,10 +35,12 @@ export async function startOidc(oidc: OidcConfig, req: Request) { }); } + // TODO: Properly validate the method is a valid type + const method = oidc.method as ClientAuthenticationMethod; const issuerUrl = new URL(oidc.issuer); const oidcClient = { client_id: oidc.client, - token_endpoint_auth_method: oidc.method, + token_endpoint_auth_method: method } satisfies Client; const response = await discoveryRequest(issuerUrl); @@ -88,11 +91,13 @@ export async function finishOidc(oidc: OidcConfig, req: Request) { }); } + // TODO: Properly validate the method is a valid type + const method = oidc.method as ClientAuthenticationMethod; const issuerUrl = new URL(oidc.issuer); const oidcClient = { client_id: oidc.client, client_secret: oidc.secret, - token_endpoint_auth_method: oidc.method, + token_endpoint_auth_method: method, } satisfies Client; const response = await discoveryRequest(issuerUrl);