feat(roles): simplify roles to only Viewer, Editor, Admin
┌────────┬──────┬─────────┬────────┬────────┬───────┬────────┐ │ Role │ read │ comment │ create │ update │ share │ delete │ ├────────┼──────┼─────────┼────────┼────────┼───────┼────────┤ │ viewer │ ✓ │ │ │ │ │ │ ├────────┼──────┼─────────┼────────┼────────┼───────┼────────┤ │ editor │ ✓ │ ✓ │ ✓ │ ✓ │ │ │ ├────────┼──────┼─────────┼────────┼────────┼───────┼────────┤ │ admin │ ✓ │ ✓ │ ✓ │ ✓ │ ✓ │ ✓ │ └────────┴──────┴─────────┴────────┴────────┴───────┴────────┘
This commit is contained in:
@@ -133,9 +133,9 @@ impl From<Permission> for PermissionDto {
|
|||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum Role {
|
pub enum Role {
|
||||||
Viewer,
|
Viewer,
|
||||||
Commenter,
|
//Commenter,
|
||||||
Editor,
|
Editor,
|
||||||
Manager,
|
//Manager,
|
||||||
Admin,
|
Admin,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,13 +146,16 @@ impl Role {
|
|||||||
pub fn expand(self) -> &'static [Permission] {
|
pub fn expand(self) -> &'static [Permission] {
|
||||||
match self {
|
match self {
|
||||||
Role::Viewer => &[Permission::Read],
|
Role::Viewer => &[Permission::Read],
|
||||||
|
/* reserved for future
|
||||||
Role::Commenter => &[Permission::Read, Permission::Comment],
|
Role::Commenter => &[Permission::Read, Permission::Comment],
|
||||||
|
*/
|
||||||
Role::Editor => &[
|
Role::Editor => &[
|
||||||
Permission::Read,
|
Permission::Read,
|
||||||
Permission::Comment,
|
Permission::Comment,
|
||||||
Permission::Create,
|
Permission::Create,
|
||||||
Permission::Update,
|
Permission::Update,
|
||||||
],
|
],
|
||||||
|
/* reserved for future
|
||||||
Role::Manager => &[
|
Role::Manager => &[
|
||||||
Permission::Read,
|
Permission::Read,
|
||||||
Permission::Comment,
|
Permission::Comment,
|
||||||
@@ -160,6 +163,7 @@ impl Role {
|
|||||||
Permission::Update,
|
Permission::Update,
|
||||||
Permission::Share,
|
Permission::Share,
|
||||||
],
|
],
|
||||||
|
*/
|
||||||
Role::Admin => &[
|
Role::Admin => &[
|
||||||
Permission::Read,
|
Permission::Read,
|
||||||
Permission::Comment,
|
Permission::Comment,
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ jsonpath "$[?(@.resource.id=='{{shared_folder_id}}')].permission" == "read"
|
|||||||
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────
|
||||||
# Step 9 — Promote Bob to Manager (adds comment, create, update, share).
|
# Step 9 — Promote Bob to Admin (adds comment, create, update, share, delete).
|
||||||
# PUT /api/grants/role reconciles the row set in one call.
|
# PUT /api/grants/role reconciles the row set in one call.
|
||||||
# ─────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────
|
||||||
PUT {{base_url}}/api/grants/role
|
PUT {{base_url}}/api/grants/role
|
||||||
@@ -159,12 +159,12 @@ Content-Type: application/json
|
|||||||
{
|
{
|
||||||
"subject": { "type": "user", "id": "{{dave_user_id}}" },
|
"subject": { "type": "user", "id": "{{dave_user_id}}" },
|
||||||
"resource": { "type": "folder", "id": "{{shared_folder_id}}" },
|
"resource": { "type": "folder", "id": "{{shared_folder_id}}" },
|
||||||
"role": "manager"
|
"role": "admin"
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTP 200
|
HTTP 200
|
||||||
[Asserts]
|
[Asserts]
|
||||||
jsonpath "$" count == 5
|
jsonpath "$" count == 6
|
||||||
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────
|
||||||
@@ -173,7 +173,7 @@ jsonpath "$" count == 5
|
|||||||
PUT {{base_url}}/api/folders/{{shared_folder_id}}/rename
|
PUT {{base_url}}/api/folders/{{shared_folder_id}}/rename
|
||||||
Authorization: Bearer {{dave_token}}
|
Authorization: Bearer {{dave_token}}
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
{ "name": "renamed-by-bob-as-manager" }
|
{ "name": "renamed-by-bob-as-admin" }
|
||||||
|
|
||||||
HTTP 200
|
HTTP 200
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ HTTP 200
|
|||||||
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────
|
||||||
# Step 12 — Bob re-shares to Carol (he has Share via Manager).
|
# Step 12 — Bob re-shares to Carol (he has Share via Admin).
|
||||||
# ─────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────
|
||||||
POST {{base_url}}/api/grants
|
POST {{base_url}}/api/grants
|
||||||
Authorization: Bearer {{dave_token}}
|
Authorization: Bearer {{dave_token}}
|
||||||
|
|||||||
Reference in New Issue
Block a user