|
| 1 | +[id='defining-authorizations-in-external-files-by-using-helm'] |
| 2 | += Defining authorizations in external files by using Helm |
| 3 | + |
| 4 | +To automate {product} maintenance, you can define permissions and roles in external files, before starting {product-short}. |
| 5 | +You need to prepare your files, upload them to your {ocp-short} project, |
| 6 | +and configure {product-short} to use the external files. |
| 7 | + |
| 8 | +.Prerequisites |
| 9 | +* xref:enabling-and-giving-access-to-rbac[You enabled the RBAC feature]. |
| 10 | + |
| 11 | +.Procedure |
| 12 | +. Define your policies in a `rbac-policies.csv` CSV file by using the following format: |
| 13 | + |
| 14 | +.. Define role permissions: |
| 15 | ++ |
| 16 | +[source,csv,subs="+quotes"] |
| 17 | +---- |
| 18 | +p, _<role_entity_reference>_, _<permission>_, _<action>_, _<allow_or_deny>_ |
| 19 | +---- |
| 20 | + |
| 21 | +_<role_entity_reference>_:: |
| 22 | +Role entity reference, such as: `role:default/guest`. |
| 23 | + |
| 24 | +_<permission>_:: |
| 25 | +Permission, such as: `bulk.import`, `catalog.entity.read`, or `catalog.entity.refresh`, or permission resource type, such as: `bulk-import` or `catalog-entity`. |
| 26 | ++ |
| 27 | +See: xref:ref-rbac-permission-policies_{context}[Permission policies reference]. |
| 28 | +_<action>_:: |
| 29 | +Action type, such as: `use`, `read`, `create`, `update`, `delete`. |
| 30 | + |
| 31 | +_<allow_or_deny>_:: |
| 32 | +Access granted: `allow` or `deny`. |
| 33 | + |
| 34 | +.. Assign the role to a group or a user: |
| 35 | ++ |
| 36 | +[source,csv,subs="+quotes"] |
| 37 | +---- |
| 38 | +g, _<group_or_user>_, _<role_entity_reference>_ |
| 39 | +---- |
| 40 | + |
| 41 | +_<group_or_user>_:: |
| 42 | +Group, such as: `user:default/mygroup`, or user, such as: `user:default/myuser`. |
| 43 | ++ |
| 44 | +.Sample `rbac-policies.csv` |
| 45 | +[source,csv,subs="+quotes"] |
| 46 | +---- |
| 47 | +p, role:default/guests, catalog-entity, read, allow |
| 48 | +p, role:default/guests, catalog.entity.create, create, allow |
| 49 | +g, user:default/my-user, role:default/guests |
| 50 | +g, group:default/my-group, role:default/guests |
| 51 | +---- |
| 52 | + |
| 53 | +. Define your conditional policies in a `rbac-conditional-policies.yaml` YAML file by using the following format: |
| 54 | ++ |
| 55 | +[source,yaml,subs="+quotes"] |
| 56 | +---- |
| 57 | +result: CONDITIONAL |
| 58 | +roleEntityRef: _<role_entity_reference>_ |
| 59 | +pluginId: _<plugin_id>_ |
| 60 | +permissionMapping: |
| 61 | + - read |
| 62 | + - update |
| 63 | + - delete |
| 64 | +conditions: _<conditions>_ |
| 65 | +---- |
| 66 | ++ |
| 67 | +See: xref:ref-rbac-conditional-policy-definition_{context}[Conditional policies reference]. |
| 68 | + |
| 69 | +. Upload your `rbac-policies.csv` and `rbac-conditional-policies.yaml` files to a `rbac-policies` config map in your {ocp-short} project containing {product-short}. |
| 70 | ++ |
| 71 | +[source,terminal] |
| 72 | +---- |
| 73 | +$ oc create configmap rbac-policies \ |
| 74 | + --from-file=rbac-policies.csv \ |
| 75 | + --from-file=rbac-conditional-policies.yaml |
| 76 | +---- |
| 77 | + |
| 78 | +. Update your {product-short} `Backstage` Helm chart to mount in the {product-short} filesystem your files from the `rbac-policies` config map: |
| 79 | + |
| 80 | +.. In the {product-short} Helm Chart, go to *Root Schema -> Backstage chart schema -> Backstage parameters -> Backstage container additional volume mounts*. |
| 81 | + |
| 82 | +.. Select *Add Backstage container additional volume mounts* and add the following values: |
| 83 | + |
| 84 | +mountPath:: `/opt/app-root/src` |
| 85 | +Name:: `rbac-policies` |
| 86 | + |
| 87 | +.. Add the RBAC policy to the *Backstage container additional volumes* in the {product-short} Helm Chart: |
| 88 | + |
| 89 | +name:: `rbac-policies` |
| 90 | +configMap:: |
| 91 | +defaultMode::: `420` |
| 92 | +name::: `rbac-policies` |
| 93 | + |
| 94 | +. Update your {product-short} `app-config.yaml` configuration file to use the `rbac-policies.csv` and `rbac-conditional-policies.yaml` external files: |
| 95 | ++ |
| 96 | +.`app-config.yml` fragment |
| 97 | +[source,yaml] |
| 98 | +---- |
| 99 | +permission: |
| 100 | + enabled: true |
| 101 | + rbac: |
| 102 | + conditionalPoliciesFile: /opt/app-root/src/rbac-conditional-policies.yaml |
| 103 | + policies-csv-file: /opt/app-root/src/rbac-policies.csv |
| 104 | + policyFileReload: true |
| 105 | +---- |
0 commit comments