Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Update axios and remove querystring and crypto #103

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions authn/openid.index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const qs = require('querystring');
const fs = require('fs');
const jwt = require('jsonwebtoken');
const cookie = require('cookie');
Expand Down Expand Up @@ -57,7 +56,9 @@ function mainProcess(event, context, callback) {
// Get request, request headers, and querystring dictionary
const request = event.Records[0].cf.request;
const headers = request.headers;
const queryDict = qs.parse(request.querystring);
const queryParams = new URLSearchParams(request.querystring);
const queryDict = Object.fromEntries(queryParams);

if (event.Records[0].cf.config.hasOwnProperty('test')) {
config.AUTH_REQUEST.redirect_uri = event.Records[0].cf.config.test + config.CALLBACK_PATH;
config.TOKEN_REQUEST.redirect_uri = event.Records[0].cf.config.test + config.CALLBACK_PATH;
Expand Down Expand Up @@ -111,7 +112,7 @@ function mainProcess(event, context, callback) {
config.TOKEN_REQUEST.code = queryDict.code;

// Exchange code for authorization token
const postData = qs.stringify(config.TOKEN_REQUEST);
const postData = new URLSearchParams(config.TOKEN_REQUEST).toString();
console.log("Requesting access token.");
axios.post(discoveryDocument.token_endpoint, postData)
.then(function(response) {
Expand Down Expand Up @@ -245,7 +246,7 @@ function redirect(request, headers, callback) {
config.AUTH_REQUEST.state = request.uri;

// Redirect to Authorization Server
var querystring = qs.stringify(config.AUTH_REQUEST);
var querystring = new URLSearchParams(config.AUTH_REQUEST).toString();

const response = {
"status": "302",
Expand Down
Loading