Skip to content
This repository was 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
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');
@@ -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;
@@ -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) {
@@ -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",
734 changes: 571 additions & 163 deletions build/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/package.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.19.0",
"axios": "^0.27.2",
"node-rsa": "^0.4.2",
"prompt": "^1.0.0",
"ramda": "^0.25.0",
557 changes: 453 additions & 104 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -11,13 +11,11 @@
"repository": "github:widen/cloudfront-auth",
"license": "ISC",
"dependencies": {
"axios": "^0.18.1",
"axios": "^0.27.2",
"cookie": "^0.3.1",
"crypto": "^1.0.1",
"jsonwebtoken": "^8.1.0",
"jwk-to-pem": "^1.2.6",
"nonce": "^1.0.4",
"querystring": "^0.2.0",
"url": "^0.11.0"
}
}