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

Allow viewing vx workflows via link if organization matches #6622

Merged
merged 2 commits into from
Nov 14, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Jobs can no longer be started on datastores without workers. [#6595](https://github.com/scalableminds/webknossos/pull/6595)
- When downloading volume annotations with volume data skipped, the nml volume tag is now included anyway (but has no location attribute in this case). [#6566](https://github.com/scalableminds/webknossos/pull/6566)
- Re-phrased some backend (error) messages to improve clarity and provide helping hints. [#6616](https://github.com/scalableminds/webknossos/pull/6616)
- Voxelytics workflows can now be viewed by anyone with the link who is in the right organization. [#6622](https://github.com/scalableminds/webknossos/pull/6622)

### Fixed
- Fixed importing a dataset from disk. [#6615](https://github.com/scalableminds/webknossos/pull/6615)
Expand Down
14 changes: 10 additions & 4 deletions app/controllers/VoxelyticsController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class VoxelyticsController @Inject()(
for {
_ <- bool2Fox(wkConf.Features.voxelyticsEnabled) ?~> "voxelytics.disabled"
// Auth is implemented in `voxelyticsDAO.findRuns`
runs <- voxelyticsDAO.findRuns(request.identity, None, workflowHash, conf.staleTimeout)
runs <- voxelyticsDAO.findRuns(request.identity, None, workflowHash, conf.staleTimeout, allowUnlisted = false)
result <- if (runs.nonEmpty) {
listWorkflowsWithRuns(request, runs)
} else {
Expand Down Expand Up @@ -113,9 +113,15 @@ class VoxelyticsController @Inject()(
// If all runs are fetched, a combined version of the workflow report
// will be returned that contains the information of the most recent task runs
runs <- runIdValidatedOpt
.map(runIdValidated =>
voxelyticsDAO.findRuns(request.identity, Some(List(runIdValidated)), Some(workflowHash), conf.staleTimeout))
.getOrElse(voxelyticsDAO.findRuns(request.identity, None, Some(workflowHash), conf.staleTimeout))
.map(
runIdValidated =>
voxelyticsDAO.findRuns(request.identity,
Some(List(runIdValidated)),
Some(workflowHash),
conf.staleTimeout,
allowUnlisted = true))
.getOrElse(
voxelyticsDAO.findRuns(request.identity, None, Some(workflowHash), conf.staleTimeout, allowUnlisted = true))
_ <- bool2Fox(runs.nonEmpty) ?~> "voxelytics.runNotFound" ~> NOT_FOUND
sortedRuns = runs.sortBy(_.beginTime).reverse
// All workflows have at least one run, because they are created at the same time
Expand Down
6 changes: 4 additions & 2 deletions app/models/voxelytics/VoxelyticsDAO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,11 @@ class VoxelyticsDAO @Inject()(sqlClient: SQLClient)(implicit ec: ExecutionContex
def findRuns(currentUser: User,
runIds: Option[List[ObjectId]],
workflowHash: Option[String],
staleTimeout: Duration): Fox[List[RunEntry]] = {
staleTimeout: Duration,
allowUnlisted: Boolean): Fox[List[RunEntry]] = {
val organizationId = currentUser._organization
val readAccessQ = if (currentUser.isAdmin) { "" } else { s" AND (r._user = ${escapeLiteral(currentUser._id.id)})" }
val readAccessQ =
if (currentUser.isAdmin || allowUnlisted) "" else { s" AND (r._user = ${escapeLiteral(currentUser._id.id)})" }
val runIdsQ = runIds.map(runIds => s" AND r._id IN ${writeEscapedTuple(runIds.map(_.id))}").getOrElse("")
val workflowHashQ =
workflowHash.map(workflowHash => s" AND r.workflow_hash = ${escapeLiteral(workflowHash)}").getOrElse("")
Expand Down