Skip to content

Commit

Permalink
feat: remove null value in authorize params + add doc link for custom…
Browse files Browse the repository at this point in the history
…ization function
  • Loading branch information
rdubigny committed Oct 18, 2024
1 parent bf97b8e commit 67dcf10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 10 additions & 1 deletion views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,16 @@
cols="50"
rows="12"
><%= locals.defaultParamsValue %></textarea>
<br>
<p>
La liste des paramètres utilisables est disponible dans la
<a
href="https://github.com/panva/openid-client/blob/v5.x/docs/README.md#clientauthorizationurlparameters"
target="_blank"
rel="noopener noreferrer"
>
librairie oidc-client
</a>.
</p>
<button id="custom-connection">Connexion personnalisée</button>
</form>
</details>
Expand Down

0 comments on commit 67dcf10

Please sign in to comment.