-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Working storage permission endpoint (refactoring / fixes needed) * use ADT rather than string hacking * remove unnecessary admin user * deal with errors better * rename method * move logic to a class * scalafmt
- Loading branch information
1 parent
b6faad4
commit eb9fde2
Showing
10 changed files
with
182 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...h/epfl/bluebrain/nexus/delta/plugins/storage/storages/StoragePermissionProviderImpl.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package ch.epfl.bluebrain.nexus.delta.plugins.storage.storages | ||
|
||
import ch.epfl.bluebrain.nexus.delta.sdk.model.IdSegmentRef | ||
import ch.epfl.bluebrain.nexus.delta.sdk.permissions.StoragePermissionProvider | ||
import ch.epfl.bluebrain.nexus.delta.sdk.permissions.StoragePermissionProvider.AccessType.{Read, Write} | ||
import ch.epfl.bluebrain.nexus.delta.sdk.permissions.model.Permission | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef | ||
import monix.bio.UIO | ||
|
||
class StoragePermissionProviderImpl(storages: Storages) extends StoragePermissionProvider { | ||
override def permissionFor( | ||
id: IdSegmentRef, | ||
project: ProjectRef, | ||
accessType: StoragePermissionProvider.AccessType | ||
): UIO[Permission] = { | ||
storages | ||
.fetch(id, project) | ||
.map(storage => storage.value.storageValue) | ||
.map(storage => | ||
accessType match { | ||
case Read => storage.readPermission | ||
case Write => storage.writePermission | ||
} | ||
) | ||
.hideErrors | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
.../main/scala/ch/epfl/bluebrain/nexus/delta/sdk/permissions/StoragePermissionProvider.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ch.epfl.bluebrain.nexus.delta.sdk.permissions | ||
|
||
import ch.epfl.bluebrain.nexus.delta.sdk.model.IdSegmentRef | ||
import ch.epfl.bluebrain.nexus.delta.sdk.permissions.StoragePermissionProvider.AccessType | ||
import ch.epfl.bluebrain.nexus.delta.sdk.permissions.model.Permission | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef | ||
import monix.bio.UIO | ||
|
||
trait StoragePermissionProvider { | ||
|
||
def permissionFor(id: IdSegmentRef, project: ProjectRef, accessType: AccessType): UIO[Permission] | ||
|
||
} | ||
|
||
object StoragePermissionProvider { | ||
sealed trait AccessType | ||
object AccessType { | ||
case object Read extends AccessType | ||
case object Write extends AccessType | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/src/test/resources/kg/storages/disk-perms-parameterised.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"@id": "{{id}}", | ||
"@type": "DiskStorage", | ||
"volume": "/default-volume", | ||
"default": false, | ||
"readPermission": "{{read-permission}}", | ||
"writePermission": "{{write-permission}}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters