Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Minor bugfixes (#16)
Browse files Browse the repository at this point in the history
* Add a missing null check in `principal_get`.
* Disable caching in the editor so we always see the latest information.
  • Loading branch information
amrc-benmorrow authored Jan 11, 2024
2 parents eab27be + 69a4834 commit fa7a953
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function get_token (service, renew) {
return promise;
}

async function fetch_json (service, path, method="GET", body=null) {
async function fetch_json (service, path, method="GET", body=null, cache=false) {
if (!(service in Services)) return;
const url = new URL(path, Services[service]);

Expand All @@ -60,6 +60,7 @@ async function fetch_json (service, path, method="GET", body=null) {
const opts = {
method,
headers: { "Authorization": `Bearer ${token}` },
cache: cache ? "default" : "no-cache",
};
if (body != null) {
opts.body = JSON.stringify(body);
Expand All @@ -85,7 +86,9 @@ async function fetch_json (service, path, method="GET", body=null) {
}

async function _get_name (obj) {
const gi = await fetch_json("configdb", `v1/app/${Uuid.General_Info}/object/${obj}`);
const gi = await fetch_json("configdb",
`v1/app/${Uuid.General_Info}/object/${obj}`,
"GET", null, true);
return gi
? gi.deleted
? html`<s>${gi.name}</s>`
Expand All @@ -94,7 +97,9 @@ async function _get_name (obj) {
}

async function get_name (obj) {
const reg = await fetch_json("configdb", `v1/app/${Uuid.Registration}/object/${obj}`);
const reg = await fetch_json("configdb",
`v1/app/${Uuid.Registration}/object/${obj}`,
"GET", null, true);
const name = await _get_name(obj);
const klass = reg ? await _get_name(reg.class) : html`<i>NO CLASS</i>`;
return html`${name} <small>(${klass})</small>`;
Expand Down
2 changes: 1 addition & 1 deletion lib/authz.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default class AuthZ {

/* We can return 403 here as long as we don't return 404 until
* we've checked the permissions. */
const ok = req.auth == ids.kerberos
const ok = req.auth == ids?.kerberos
|| await this.model.check_acl(req.auth, Perm.Read_Krb, uuid, true);
if (!ok) return res.status(403).end();

Expand Down

0 comments on commit fa7a953

Please sign in to comment.