Skip to content
Open
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
4 changes: 4 additions & 0 deletions src/main/kotlin/com/cosmotech/api/rbac/RolesDefinition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const val PERMISSION_DELETE = "delete"
const val PERMISSION_LAUNCH = "launch"
const val PERMISSION_VALIDATE = "validate"

val NO_PERMISSIONS = emptyList<String>()

val COMMON_ROLE_READER_PERMISSIONS = listOf(PERMISSION_READ, PERMISSION_READ_SECURITY)
val COMMON_ROLE_USER_PERMISSIONS =
listOf(PERMISSION_READ, PERMISSION_READ_SECURITY, PERMISSION_CREATE_CHILDREN)
Expand Down Expand Up @@ -92,6 +94,7 @@ fun getCommonRolesDefinition(): RolesDefinition {
return RolesDefinition(
permissions =
mutableMapOf(
ROLE_NONE to NO_PERMISSIONS,
ROLE_VIEWER to COMMON_ROLE_READER_PERMISSIONS,
ROLE_USER to COMMON_ROLE_USER_PERMISSIONS,
ROLE_EDITOR to COMMON_ROLE_EDITOR_PERMISSIONS,
Expand All @@ -104,6 +107,7 @@ fun getScenarioRolesDefinition(): RolesDefinition {
return RolesDefinition(
permissions =
mutableMapOf(
ROLE_NONE to NO_PERMISSIONS,
ROLE_VIEWER to SCENARIO_ROLE_VIEWER_PERMISSIONS,
ROLE_EDITOR to SCENARIO_ROLE_EDITOR_PERMISSIONS,
ROLE_VALIDATOR to SCENARIO_ROLE_VALIDATOR_PERMISSIONS,
Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/com/cosmotech/api/rbac/CsmRbacTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ class CsmRbacTests {
fun `get default role definition permissions`() {
val expected: MutableMap<String, List<String>> =
mutableMapOf(
ROLE_NONE to NO_PERMISSIONS,
ROLE_VIEWER to COMMON_ROLE_READER_PERMISSIONS,
ROLE_USER to COMMON_ROLE_USER_PERMISSIONS,
ROLE_EDITOR to COMMON_ROLE_EDITOR_PERMISSIONS,
Expand All @@ -589,6 +590,7 @@ class CsmRbacTests {
definition.permissions.put(customRole, customRolePermissions)
val expected: MutableMap<String, List<String>> =
mutableMapOf(
ROLE_NONE to NO_PERMISSIONS,
ROLE_VIEWER to COMMON_ROLE_READER_PERMISSIONS,
ROLE_USER to COMMON_ROLE_USER_PERMISSIONS,
ROLE_EDITOR to COMMON_ROLE_EDITOR_PERMISSIONS,
Expand Down