From 67dcf10ebbd3204717a014b6cb25cd4949ec87e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Dubigny?= Date: Fri, 18 Oct 2024 18:32:02 +0200 Subject: [PATCH] feat: remove null value in authorize params + add doc link for customization function --- index.js | 6 ++++-- views/index.ejs | 11 ++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 5448b93..b45c2dc 100644 --- a/index.js +++ b/index.js @@ -22,6 +22,8 @@ app.use( ); app.use(morgan("combined")); +const removeNullValues = (obj) => Object.entries(obj).reduce((a,[k,v]) => (v ? (a[k]=v, a) : a), {}) + const getMcpClient = async () => { const mcpIssuer = await Issuer.discover(process.env.MCP_PROVIDER); @@ -79,12 +81,12 @@ const getAuthorizationControllerFactory = (extraParams) => { req.session.state = state; req.session.nonce = nonce; - const redirectUrl = client.authorizationUrl({ + const redirectUrl = client.authorizationUrl(removeNullValues({ nonce, state, ...AUTHORIZATION_DEFAULT_PARAMS, ...extraParams, - }); + })); res.redirect(redirectUrl); } catch (e) { diff --git a/views/index.ejs b/views/index.ejs index b5edf6c..8a21f86 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -96,7 +96,16 @@ cols="50" rows="12" ><%= locals.defaultParamsValue %> -
+

+ La liste des paramètres utilisables est disponible dans la + + librairie oidc-client + . +