@backstage-community/plugin-rbac-node 1.23.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  ## @backstage-community/plugin-rbac-node [1.4.0](https://github.com/janus-idp/backstage-plugins/compare/@backstage-community/plugin-rbac-node@1.3.1...@backstage-community/plugin-rbac-node@1.4.0) (2024-07-26)
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 05a0161: ### Conditional policies: eliminate HTTP metadata dependency and support broad matching
8
+
9
+ **Fixed:**
10
+
11
+ - **`.find()` arbitrary name selection:** `processConditionMapping()` used `.find()` to resolve `(resourceType, action)` to a permission name, picking the first match arbitrarily when a plugin registers multiple permissions with the same pair (named variants). The function has been removed entirely — users now control the format directly.
12
+ - **`checkConflictedConditions` for named variants:** Updated conflict detection to allow separate conditional policies for different permission names with the same action and resourceType. For example, `playlist.list.update` and `playlist.followers.update` can now have independent conditions for the same role.
13
+ - **Frontend sends `{name, action}`:** The frontend now sends the permission name the user selected in the UI instead of discarding it and sending only the action string.
14
+ - **Startup race condition (#9429):** Eliminated HTTP calls to plugin metadata endpoints during conditional policy reconciliation. The YAML file watcher no longer calls `processConditionMapping()` — conditions are stored directly without server-side name resolution. This removes the dependency on target plugins being ready at startup.
15
+
16
+ **Added:**
17
+
18
+ - **`permissionMapping` accepts two formats:**
19
+
20
+ - Action-only `['read']` — broad match, applies to all permissions with this action for the resourceType. Available in YAML conditional policies file and provider extension point (read-only in frontend UI).
21
+ - Named `[{name: 'catalog.entity.read', action: 'read'}]` — specific match, targets exactly the named permission. Available in all entry points including REST API and frontend UI.
22
+
23
+ - **New types** exported from `@backstage-community/plugin-rbac-common`:
24
+
25
+ - `PermissionMapping` — union type `PermissionAction | PermissionInfo`
26
+ - `isPermissionInfo()` — type guard
27
+ - `permissionMappingAction()` — extracts action from either format
28
+
29
+ - **REST API validation:** POST/PUT endpoints require `{name, action}` format for `permissionMapping` entries. Plain action strings are rejected with `InputError`. This ensures conditions created via REST API (editable in frontend UI) always have explicit permission names. Broad (action-only) format is supported in YAML and provider extension point where conditions are read-only in the UI.
30
+ - **Validation:** `{name, action}` entries are validated — empty permission names are rejected.
31
+
32
+ **Changed:**
33
+
34
+ - YAML conditional policies with action-only `permissionMapping` (e.g., `['read']`) are now stored as-is and match ALL permissions with that action for the given resourceType. Previously, the backend resolved the action to a single arbitrary permission name via HTTP. This affects only plugins with named variants — multiple permissions sharing the same `(resourceType, action)` pair (scaffolder, playlist). For most plugins where each action maps to one permission, behavior is unchanged. To target a specific permission, use the `{name, action}` format.
35
+ - Frontend and backend must be upgraded together — older frontend versions sending `['read']` to REST API will receive `InputError`.
36
+
37
+ **No DB migration required.** Existing `{name, action}` data in the database is already valid in the new `PermissionMapping` union type and continues to work unchanged.
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies [05a0161]
42
+ - @backstage-community/plugin-rbac-common@2.0.0
43
+
3
44
  ## 1.23.1
4
45
 
5
46
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
- import { RoleConditionalPolicyDecision, PermissionInfo } from '@backstage-community/plugin-rbac-common';
2
+ import { RoleConditionalPolicyDecision } from '@backstage-community/plugin-rbac-common';
3
3
 
4
4
  /**
5
5
  * Used to provide a list of pluginIDs on which a permission well-known endpoint is to be searched.
@@ -22,7 +22,7 @@ interface RBACProvider {
22
22
  interface RBACProviderConnection {
23
23
  applyRoles(roles: string[][]): Promise<void>;
24
24
  applyPermissions(permissions: string[][]): Promise<void>;
25
- applyConditionalPermissions(conditionalPermissions: RoleConditionalPolicyDecision<PermissionInfo>[]): Promise<void>;
25
+ applyConditionalPermissions(conditionalPermissions: RoleConditionalPolicyDecision[]): Promise<void>;
26
26
  }
27
27
 
28
28
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-rbac-node",
3
3
  "description": "Node.js library for the rbac plugin",
4
- "version": "1.23.1",
4
+ "version": "2.0.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -39,7 +39,7 @@
39
39
  "dist"
40
40
  ],
41
41
  "dependencies": {
42
- "@backstage-community/plugin-rbac-common": "^1.29.1",
42
+ "@backstage-community/plugin-rbac-common": "^2.0.0",
43
43
  "@backstage/backend-plugin-api": "^1.9.2"
44
44
  },
45
45
  "repository": {