Skip to content

Commit

Permalink
Detect when RLS has been a cause for error. Fixed calling the wrong a…
Browse files Browse the repository at this point in the history
…pis function when updating Run access. fixes #406 and #1145
  • Loading branch information
Jeremy Whiting committed Jan 23, 2024
1 parent 4d00d6c commit e123ee5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.quarkus.hibernate.orm.panache.PanacheQuery;
import io.quarkus.panache.common.Page;
import io.quarkus.panache.common.Sort;
import io.quarkus.security.UnauthorizedException;
import io.quarkus.security.identity.SecurityIdentity;

import jakarta.annotation.security.PermitAll;
Expand Down Expand Up @@ -437,8 +438,12 @@ public void updateAccess(int id,
query.setParameter(1, owner);
query.setParameter(2, access.ordinal());
query.setParameter(3, id);
if (query.executeUpdate() != 1) {
throw ServiceException.serverError("Access change failed (missing permissions?)");
try {
if (query.executeUpdate() != 1) {
throw ServiceException.serverError("Access change failed (missing permissions?)");
}
} catch ( UnauthorizedException ue) {
throw ServiceException.forbidden("Changing access of Test " + id + " is not permitted. You are not defined as a `tester` for the `"+ owner + "` team. Please update your permissions and try again.");
}
}

Expand Down
4 changes: 2 additions & 2 deletions horreum-web/src/domain/runs/Run.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import DatasetData from "./DatasetData"
import MetaData from "./MetaData"
import RunData from "./RunData"
import TransformationLogModal from "../tests/TransformationLogModal"
import {Access, fetchRunSummary, recalculateDatasets, RunExtended, updateAccess} from "../../api"
import {Access, fetchRunSummary, recalculateDatasets, RunExtended, updateAccess, updateRunAccess} from "../../api"
import {AppContext} from "../../context/appContext";
import { AppContextType} from "../../context/@types/appContextTypes";

Expand Down Expand Up @@ -58,7 +58,7 @@ export default function Run() {

const accessUpdate = (owner : string, access : Access) => {
if( run !== undefined) {
updateAccess(run.id, owner, access, alerting).then(() => getRunSummary())
updateRunAccess(run.id, run.testid, owner, access, alerting).then(() => getRunSummary())
}
}

Expand Down

0 comments on commit e123ee5

Please sign in to comment.