Skip to content

Commit

Permalink
feat: add nonce and state by default
Browse files Browse the repository at this point in the history
  • Loading branch information
rdubigny committed Mar 22, 2024
1 parent 56b41b6 commit 10b7d87
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import "dotenv/config";
import express from "express";
import { generators, Issuer } from "openid-client";
import { Issuer } from "openid-client";
import cookieSession from "cookie-session";
import morgan from "morgan";
import * as crypto from "crypto";

const port = parseInt(process.env.PORT, 10) || 3000;
const origin = `${process.env.HOST}`;
Expand Down Expand Up @@ -56,12 +57,16 @@ app.get("/", async (req, res, next) => {
app.post("/login", async (req, res, next) => {
try {
const client = await getMcpClient();
const nonce = crypto.randomBytes(16).toString("hex");
const state = crypto.randomBytes(16).toString("hex");

const redirectUrl = client.authorizationUrl({
scope,
// claims: { id_token: { amr: { essential: true } } },
login_hint,
acr_values,
nonce,
state,
});

res.redirect(redirectUrl);
Expand Down

0 comments on commit 10b7d87

Please sign in to comment.