Skip to content

Commit

Permalink
Support viewurl path (arkime#2704)
Browse files Browse the repository at this point in the history
* previous didn't support having a path in viewUrl fixes arkime#2696

previously when using a viewUrl if it has a path in it, it was ignored.
This allows a non standard method of accessing sensor viewers that
have a webBasePath now.

* lint
  • Loading branch information
awick authored Mar 11, 2024
1 parent 67759ca commit 3f7bcd7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 5 additions & 2 deletions common/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,11 @@ class Auth {
return done('Can not authenticate with role');
}

obj.path = obj.path.replace(Auth.#basePath, '/');
if (obj.path !== req.url) {
let objPath = obj.path;
if (Auth.#basePath.length > 1 && obj.path.startsWith(Auth.#basePath)) {
objPath = obj.path.substring(Auth.#basePath.length);
}
if (obj.path !== req.url && objPath !== req.url) {
console.log('ERROR - mismatch url', obj.path, ArkimeUtil.sanitizeStr(req.url));
return done('Unauthorized based on bad url');
}
Expand Down
10 changes: 8 additions & 2 deletions viewer/apiSessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1590,13 +1590,19 @@ class SessionAPIs {
return res.send(`Can't find view url for '${ArkimeUtil.safeStr(req.params.nodeName)}' check viewer logs on '${Config.hostName()}'`);
}

const url = new URL(req.url, viewUrl);
let url;
if (req.url.startsWith('/')) {
url = new URL(req.url.substring(1), viewUrl);
} else {
url = new URL(req.url, viewUrl);
}
const options = {
timeout: 20 * 60 * 1000,
agent: client === http ? internals.httpAgent : internals.httpsAgent
};

Auth.addS2SAuth(options, req.user, req.params.nodeName, req.url);
const urlPath = url.pathname + (url.search ?? '');
Auth.addS2SAuth(options, req.user, req.params.nodeName, urlPath);
ViewerUtils.addCaTrust(options, req.params.nodeName);

const preq = client.request(url, options, (pres) => {
Expand Down

0 comments on commit 3f7bcd7

Please sign in to comment.