Skip to content

Commit

Permalink
fix: add allow http protocol (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitSerrano authored Nov 20, 2024
1 parent 9d8e5d7 commit da3c33f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,22 @@ const objToUrlParams = (obj) =>
const getCurrentUrl = (req) =>
new URL(`${req.protocol}://${req.get("host")}${req.originalUrl}`);

const configOptions = process.env.IS_HTTP_PROTOCOL_FORBIDDEN === "True" ? undefined : {execute: [client.allowInsecureRequests]}

const getProviderConfig = async () => {
return await client.discovery(
const config = await client.discovery(
new URL(process.env.PC_PROVIDER),
process.env.PC_CLIENT_ID,
{
client_secret: process.env.PC_CLIENT_SECRET,
id_token_signed_response_alg: process.env.PC_ID_TOKEN_SIGNED_RESPONSE_ALG,
userinfo_signed_response_alg:
process.env.PC_USERINFO_SIGNED_RESPONSE_ALG || null,

},
client.ClientSecretPost(process.env.PC_CLIENT_SECRET),
configOptions
);
return config
};

const AUTHORIZATION_DEFAULT_PARAMS = {
Expand Down Expand Up @@ -161,7 +166,7 @@ app.get(process.env.CALLBACK_URL, async (req, res, next) => {
const tokens = await client.authorizationCodeGrant(config, currentUrl, {
expectedNonce: req.session.nonce,
expectedState: req.session.state,
});
}, configOptions);

req.session.nonce = null;
req.session.state = null;
Expand All @@ -170,6 +175,7 @@ app.get(process.env.CALLBACK_URL, async (req, res, next) => {
config,
tokens.access_token,
claims.sub,
configOptions
);
req.session.idtoken = claims;
req.session.id_token_hint = tokens.id_token;
Expand Down

0 comments on commit da3c33f

Please sign in to comment.