@spotify/backstage-plugin-rbac-common 0.5.2 → 0.5.3
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 +7 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +562 -172
- package/dist/index.esm.js +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @spotify/backstage-plugin-rbac-common
|
|
2
2
|
|
|
3
|
+
## 0.5.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Upgraded to Backstage `v1.15.0`
|
|
8
|
+
- Added a 'Save and Publish' option to the policy page menu to combine both the save and publish actions together, and added a default primary action that sits next to the menu button to either save, republish or duplicate policies depending on their state
|
|
9
|
+
|
|
3
10
|
## 0.5.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var c=require("@backstage/catalog-model"),P=require("uuid"),s=require("zod"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var c=require("@backstage/catalog-model"),P=require("uuid"),s=require("zod"),I=require("@backstage/plugin-permission-common");const f=(i,e)=>`${i} must be at least ${e} characters`,p=(i,e)=>`${i} must be less than ${e} characters`,y="Untitled policy",v=":backstageUser",h=s.z.object({rule:s.z.string(),params:s.z.record(s.z.any()).optional()}),n=s.z.lazy(()=>s.z.union([s.z.object({allOf:s.z.array(n).nonempty()}).strict(),s.z.object({anyOf:s.z.array(n).nonempty()}).strict(),s.z.object({not:n}).strict(),h])),g=s.z.object({pluginId:s.z.string().min(1).describe("Plugin ID that defines the permission and rules used."),resourceType:s.z.string().min(1).describe("Resource type associated with the conditions used."),conditions:n}),z=s.z.union([s.z.literal("allow"),s.z.literal("deny")]),b=s.z.union([z,g]),R=s.z.union([s.z.literal("*"),s.z.object({name:s.z.string().optional().describe("Name that must match the incoming permission request."),actions:s.z.array(s.z.string()).optional().describe("Actions that must be present on the incoming permission's attributes."),resourceType:s.z.string().min(1).optional().describe("Resource type that must match that of the incoming permission request.")})]),C=s.z.object({id:s.z.string().default(()=>P.v4().split("-")[0]).describe("ID of the permission."),match:R.describe("Values used to match against the incoming permission request."),decision:b.describe("Authorization result or conditions to send if this role permission applies.")}).refine(({decision:i,match:e})=>O(i)?e!=="*"&&(e==null?void 0:e.resourceType)!==void 0:!0,{path:["match","resourceType"],message:"match.resourceType is required for conditional decisions."}),D=s.z.array(C).superRefine((i,e)=>{const r=d(i,"id");r>=0&&e.addIssue({code:s.z.ZodIssueCode.custom,message:"Permission ids must be unique",path:[r,"id"]})}).describe("Permission decisions used to determine authorization responses."),T=s.z.string().refine(E,{message:"Invalid entity ref for member.",path:[]}).transform(i=>c.stringifyEntityRef(c.parseEntityRef(i,{defaultKind:"group",defaultNamespace:"default"}))),q=s.z.object({name:s.z.string().min(1,{message:f("Role name",1)}).max(1024,{message:p("Role name",1024)}).describe("Name of the role."),id:s.z.string().default(()=>P.v4().split("-")[0]).describe("ID of the role."),members:s.z.union([s.z.literal("*"),s.z.array(T).min(1)]).describe("Entity references used to map users to this role. These entities don't need to exist in the catalog."),permissions:D}),l=s.z.array(q).default([]).superRefine((i,e)=>{const r=d(i,"name");r>=0&&e.addIssue({code:s.z.ZodIssueCode.custom,message:"Role names must be unique",path:[r,"name"]});const t=d(i,"id");t>=0&&e.addIssue({code:s.z.ZodIssueCode.custom,message:"Role ids must be unique",path:[t,"id"]})}),u=s.z.string().min(1,{message:f("Policy name",1)}).max(1024,{message:p("Policy name",1024)}).default(y).describe("Name of the policy."),j=s.z.union([s.z.literal("first-match"),s.z.literal("any-allow")]),m=s.z.object({resolutionStrategy:j}).default({resolutionStrategy:"first-match"}),a=s.z.object({name:u,options:m,roles:l}),N=a.default({roles:[]});function E(i){try{return c.parseEntityRef(i,{defaultKind:"group",defaultNamespace:"default"}),!0}catch{return!1}}function d(i,e){let r=0;const t=new Set;for(;r<i.length;){const o=i[r][e];if(t.has(o))return r;t.add(o),r++}return-1}function O(i){return typeof i!="string"}function M(i){const e=Object.entries(i);return e.length===1&&e[0][0]==="allOf"&&Array.isArray(e[0][1])}function U(i){const e=Object.entries(i);return e.length===1&&e[0][0]==="anyOf"&&Array.isArray(e[0][1])}function k(i){const e=Object.entries(i);return e.length===1&&e[0][0]==="not"&&!Array.isArray(e[0][1])}const x=a,A=a.extend({name:u.optional(),options:m.optional(),roles:l.optional()}),S=s.z.object({description:s.z.string().optional(),update:A.optional()}),$=(i,e)=>e?e===i.name:!0,w=(i,e)=>e?I.isResourcePermission(i)&&e===i.resourceType:!0,V=(i,e)=>e?e.some(r=>r===i.attributes.action):!0,Z=(i,e)=>e==="*"?!0:$(i,e.name)&&w(i,e.resourceType)&&V(i,e.actions),B=(i,e)=>i.kind!==e.kind||i.namespace!==e.namespace?!1:e.name==="*"?!0:i.name===e.name;function K(i,e){const r={};if(i)for(const[t,o]of Object.entries(i))r[t]=e(o);return r}exports.BackstageUserPlaceholder=v,exports.ConditionalDecisionParser=g,exports.CreateDraftRequestParser=x,exports.DefaultingPolicyConfigParser=N,exports.LiteralDecisionParser=z,exports.PermissionConditionParser=h,exports.PermissionDecisionParser=b,exports.PermissionMatchParser=R,exports.PolicyConfigOptionsParser=m,exports.PolicyConfigParser=a,exports.PolicyDefaultName=y,exports.PolicyRoleResolutionStrategyParser=j,exports.PolicyTitleParser=u,exports.PublishVersionRequestParser=S,exports.RoleParser=q,exports.RolePermissionParser=C,exports.RolePermissionsParser=D,exports.RolesParser=l,exports.UpdateDraftRequestParser=A,exports.isAllOfPermissionCriteria=M,exports.isAnyOfPermissionCriteria=U,exports.isConditionalDecision=O,exports.isMatchingPermission=Z,exports.isNotPermissionCriteria=k,exports.mapParams=K,exports.matchesEntityRef=B;
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|