Skip to content

Commit

Permalink
Better path checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Bryant (mandatory) committed Sep 17, 2021
1 parent 2f35dd9 commit 56bb44e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion api.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,17 @@ async function set_up_api_server(app) {
constants.API_BASE_PATH + 'settings',
];

// Check if the path being accessed required authentication
var requires_authentication = false;
AUTHENTICATION_REQUIRED_ROUTES.map(authenticated_route => {
if(req.path.toLowerCase().startsWith(authenticated_route)) {
requires_authentication = true;
}
});

// If the route is not one of the authentication required routes
// then we can allow it through.
if(!AUTHENTICATION_REQUIRED_ROUTES.includes(req.path)) {
if(!requires_authentication) {
next();
return;
}
Expand Down

0 comments on commit 56bb44e

Please sign in to comment.