Skip to content

Commit

Permalink
Allow viewing vx workflows via link if organization matches (#6622)
Browse files Browse the repository at this point in the history
  • Loading branch information
fm3 authored Nov 14, 2022
1 parent 293b16f commit 46f8eee
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
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

0 comments on commit 46f8eee

Please sign in to comment.