30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
"use strict";
|
|
|
|
// Case-insensitive classification of the /api/nodes route namespace.
|
|
//
|
|
// Express matches routes case-insensitively by default (neither app enables
|
|
// "case sensitive routing"), so /API/NODES, /Api/Nodes and /api/nodes are
|
|
// dispatched to the same handlers. Any gate that classifies paths with a
|
|
// case-sensitive prefix match can therefore be bypassed by a case variant
|
|
// while the router still serves the real route. Both gate layers — the
|
|
// index.js pre-mount admin gate and the nodes.js in-app gate — must classify
|
|
// through these helpers.
|
|
//
|
|
// The OPEN-route allowlists (heartbeat, config.yml, node-bootstrap)
|
|
// deliberately keep their case-sensitive regexes: they grant
|
|
// pre-auth reachability, so a case variant that fails their match falls
|
|
// closed into the admin gate instead of widening the pre-auth surface.
|
|
|
|
const NODE_API_PREFIX = "/api/nodes";
|
|
const NODE_SERVER_API_PREFIX = "/api/nodes/server/";
|
|
|
|
function isNodeApiPath(p) {
|
|
return String(p || "").toLowerCase().startsWith(NODE_API_PREFIX);
|
|
}
|
|
|
|
function isNodeServerApiPath(p) {
|
|
return String(p || "").toLowerCase().startsWith(NODE_SERVER_API_PREFIX);
|
|
}
|
|
|
|
module.exports = { isNodeApiPath, isNodeServerApiPath };
|