Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AndrienkoAleksandr/74110b818d8f67786d42667baab6152b to your computer and use it in GitHub Desktop.
Save AndrienkoAleksandr/74110b818d8f67786d42667baab6152b to your computer and use it in GitHub Desktop.
@janus-idp/backstage-plugin-rbac-backend conditions
#!/bin/bash
# RBAC conditions determine which part of the resource content should be visible to the user.
curl -X POST "http://localhost:7007/api/permission/roles" -d '{ "memberReferences": [ "user:default/andrienkoaleksandr" ], "name": "role:default/test" }' -H "Content-Type: application/json" -H "Authorization: Bearer $token" -v
# Let's provide read catalog entity permission
curl -X POST "http://localhost:7007/api/permission/policies" -d '{"entityReference": "role:default/test", "permission": "catalog-entity", "policy": "read", "effect":"allow"}' -H "Content-Type: application/json" -H "Authorization: Bearer $token" -v
# Condition without criteria
{"result":"CONDITIONAL","pluginId":"catalog","resourceType":"catalog-entity","conditions":{"rule":"IS_ENTITY_OWNER","resourceType":"catalog-entity","params":{"claims":["user:default/andrienkoaleksandr","group:default/team-a"]}}}
curl -X POST "http://localhost:7007/api/permission/conditions" -d '{"result":"CONDITIONAL","pluginId":"catalog","resourceType":"catalog-entity","conditions":{"rule":"IS_ENTITY_OWNER","resourceType":"catalog-entity","params":{"claims":["user:default/andrienkoaleksandr","group:default/team-a"]}}}' -H "Content-Type: application/json" -H "Authorization: Bearer $token" -v
# Condition with criteria:
{"result":"CONDITIONAL","pluginId":"catalog","resourceType":"catalog-entity","conditions":{"anyOf":[{"rule":"IS_ENTITY_OWNER","resourceType":"catalog-entity","params":{"claims":["user:default/andrienkoaleksandr","group:default/team-a"]}},{"rule":"IS_ENTITY_KIND","resourceType":"catalog-entity","params":{"kinds":["Group"]}}]}}
curl -X PUT "http://localhost:7007/api/permission/conditions/1" -d '{"result":"CONDITIONAL","pluginId":"catalog","resourceType":"catalog-entity","conditions":{"anyOf":[{"rule":"IS_ENTITY_OWNER","resourceType":"catalog-entity","params":{"claims":["user:default/andrienkoaleksandr","group:default/team-a"]}},{"rule":"IS_ENTITY_KIND","resourceType":"catalog-entity","params":{"kinds":["Group"]}}]}}' -H "Content-Type: application/json" -H "Authorization: Bearer $token" -v
curl -X GET "http://localhost:7007/api/permission/conditions/1" -H "Content-Type: application/json" -H "Authorization: Bearer $token" -v
curl -X DELETE "http://localhost:7007/api/permission/conditions/1" -H "Content-Type: application/json" -H "Authorization: Bearer $token" -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment