Skip to content

Commit

Permalink
Add module to dump headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Jermolene committed Dec 16, 2023
1 parent 01598ed commit f148f26
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions wiki/tiddlers/modules/dump-headers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*\
title: $:/core/modules/server/authenticators/dumpheaders.js
type: application/javascript
module-type: authenticator
Authenticator to dump headers
\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

if($tw.node) {
var util = require("util"),
fs = require("fs"),
url = require("url"),
path = require("path");
}

function DumpHeaders(server) {
this.server = server;
}

/*
Returns true if the authenticator is active, false if it is inactive, or a string if there is an error
*/
DumpHeaders.prototype.init = function() {
return true;
};

/*
Returns true if the request is authenticated and assigns the "authenticatedUsername" state variable.
Returns false if the request couldn't be authenticated having sent an appropriate response to the browser
*/
DumpHeaders.prototype.authenticateRequest = function(request,response,state) {
var headers = [];
for(const header of Object.keys(request.headers).sort()) {
headers.push(`${header} = ${request.headers[header]}`);
}
console.log(headers);
return true;
};

exports.AuthenticatorClass = DumpHeaders;

})();

0 comments on commit f148f26

Please sign in to comment.