Skip to content
Merged
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
14 changes: 12 additions & 2 deletions hello/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@ const http = require("http");

http
.createServer(function (request, response) {

//
// If the app has been configured to check the CIS secret,
// make sure that the request header value 'x-cis-secret' matches the configured secret.
// If it doesn't match, assume that the request bypassed the CIS firewall and reject it.
if(process.env.CIS_SECRET && request.headers['x-cis-secret'] !== process.env.CIS_SECRET){
response.writeHead(403);
return response.end();
}

//
// debug endpoint, which prints all incoming headers and environment variables
// Debug endpoint, which prints all incoming headers and environment variables
if (request.url == "/debug") {
const respData = {
headers: request.headers,
Expand All @@ -17,7 +27,7 @@ http
}

//
// default http endpoint, which prints a simple hello world
// Default http endpoint, which prints a simple hello world
target = process.env.TARGET ? process.env.TARGET : "World";
msg = process.env.MSG ? process.env.MSG : "Hello " + target + "\n";
response.writeHead(200, { "Content-Type": "text/plain" });
Expand Down
Loading