Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect when RLS has been a cause for error. #1147

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading