Skip to content

Commit 4a4cd2f

Browse files
committed
RHID-3976 Managing authorization by importing external files
Signed-off-by: Fabrice Flore-Thébault <[email protected]>
1 parent 0c9aec5 commit 4a4cd2f

13 files changed

+299
-480
lines changed

assemblies/assembly-configuring-authorization-in-rhdh.adoc

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ Role-Based Access Control (RBAC) is a security concept that controls access to r
1111
You define roles with specific permissions, and then assign the roles to users and groups.
1212

1313
RBAC on {product-short} is built on top of the Permissions framework, which defines RBAC policies in code.
14-
Rather than defining policies in code,
15-
the {product-short} RBAC feature allows you
16-
to define policies in a declarative fashion using a simple CSV based format.
17-
You can define the policies by using {product-short} web interface or REST API, rather than editing the CSV directly.
14+
Rather than defining policies in code, the {product-short} RBAC feature allows you to define policies in a declarative fashion using a simple CSV based format.
15+
16+
You can define the roles and policies:
17+
18+
* By using {product-short} web interface or REST API
19+
* By editing the policy CSV file.
20+
* By editing the `app-config.yaml` configuration file.
1821

1922
To apply RBAC in {product-short}:
2023

21-
. The {product-short} administrator sets up the RBAC feature:
22-
.. Enable the RBAC feature
23-
.. Configure Policy Administrators
24+
. The {product-short} administrator enables and gives access to the RBAC feature.
2425

2526
. The {product-short} policy administrator configures your RBAC policies:
2627
.. Define roles with specific permissions
@@ -33,17 +34,10 @@ include::modules/authorization/proc-enabling-the-rbac-plugin.adoc[leveloffset=+1
3334
include::assembly-managing-authorizations-by-using-the-rhdh-web-ui.adoc[leveloffset=+1]
3435

3536

36-
include::modules/authorization/ref-rbac-permission-policies.adoc[leveloffset=+1]
37-
38-
39-
include::modules/authorization/con-rbac-config-permission-policies.adoc[leveloffset=+2]
40-
37+
include::assembly-managing-authorizations-by-using-external-files.adoc[leveloffset=+1]
4138

42-
include::modules/authorization/con-rbac-config-permission-policies-external-file.adoc[leveloffset=+3]
4339

44-
include::modules/authorization/proc-mounting-the-policy-csv-file-using-the-operator.adoc[leveloffset=+4]
45-
46-
include::modules/authorization/proc-mounting-the-policy-csv-file-using-helm.adoc[leveloffset=+4]
40+
include::modules/authorization/ref-rbac-permission-policies.adoc[leveloffset=+1]
4741

4842

4943
include::modules/authorization/con-rbac-conditional-policies-rhdh.adoc[leveloffset=+1]
@@ -52,10 +46,6 @@ include::modules/authorization/con-rbac-conditional-policies-rhdh.adoc[leveloffs
5246
include::modules/authorization/ref-rbac-conditional-policy-definition.adoc[leveloffset=+2]
5347

5448

55-
include::modules/authorization/proc-rbac-config-conditional-policy-file.adoc[leveloffset=+2]
56-
57-
58-
5949
include::modules/authorization/con-user-stats-rhdh.adoc[leveloffset=+1]
6050

6151

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[id='managing-authorizations-by-using-external-files']
2+
= Managing authorizations by using external files
3+
4+
To automate {product} maintenance, you can configure permissions and roles in external files, before starting {product-short}.
5+
6+
7+
include::modules/authorization/proc-defining-authorizations-in-external-files-by-using-the-operator.adoc[leveloffset=+1]
8+
9+
include::modules/authorization/proc-defining-authorizations-in-external-files-by-using-helm.adoc[leveloffset=+1]
10+

assemblies/assembly-managing-authorizations-by-using-the-rhdh-web-ui.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[id='proc-rbac-ui-manage-roles_{context}']
1+
[id='managing-authorizations-by-using-the-web-ui']
22
= Managing role-based access controls (RBAC) using the {product} Web UI
33

44
Policy administrators can use the {product-short} web interface (Web UI) to allocate specific roles and permissions to individual users or groups. Allocating roles ensures that access to resources and functionalities is regulated across the {product-short}.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[id='con-permission-policy-and-role-source']
2+
= Understanding permission policy and role configuration source
3+
4+
You can configure {product} policy and roles by using different sources.
5+
To maintain data consistency, {product-short} associates each permission policy and role with one unique source.
6+
You can only use this source to change the resource.
7+
8+
You can manipulate permission policies and roles based on their source:
9+
10+
Configuration file::
11+
Configure roles and policies in the `app-config.yaml` configuration file, for instance to xref:enabling-and-giving-access-to-rbac[declare your policy administrators].
12+
13+
REST API::
14+
Configure roles and policies xref:managing-authorizations-by-using-the-seb-ui[by using the {product-short} Web UI] or xref:managing-authorizations-by-using-the-rest-api[by using the REST API].
15+
16+
CSV file::
17+
Configure roles and policies by using CSV files.
18+
19+
20+
Legacy::
21+
The legacy source applies to policies and roles defined before RBAC backend plugin version `2.1.3`, and is the least restrictive among the source location options.
22+
+
23+
IMPORTANT: Update the permissions and roles in legacy source to use either REST API or the CSV file sources.
24+
25+
Managing roles and permission policies originating from CSV files and REST API involves straightforward modification based on their initial source information.
26+
27+
The Configuration file pertains to the default `role:default/rbac_admin` role provided by the RBAC plugin.
28+
The default role has limited permissions to create, read, update, and delete permission policies or roles, and to read catalog entities.
29+
30+
[NOTE]
31+
====
32+
In case the default permissions are insufficient for your administrative requirements, you can create a custom admin role with required permission policies.
33+
====
34+
35+
You can use the `GET` requests to query roles and policies and determine the source information, if required.
36+

modules/authorization/con-rbac-config-permission-policies-external-file.adoc

Lines changed: 0 additions & 66 deletions
This file was deleted.

modules/authorization/con-rbac-config-permission-policies.adoc

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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.refresg`, 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 maps 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 config maps:
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 external files in {product-short}:
95+
+
96+
.`app-config.yml` fragment
97+
[source,yaml]
98+
----
99+
permission:
100+
enabled: true
101+
rbac:
102+
conditionalPoliciesFile: ./rbac-conditional-policies.yaml
103+
policies-csv-file: ./rbac-policies.csv
104+
policyFileReload: true
105+
----
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
[id='defining-authorizations-in-external-files-by-using-the-operator']
2+
= Defining authorizations in external files by using the operator
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.refresg`, 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 maps 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` custom resource to mount in the {product-short} filesystem your files from the config maps:
79+
+
80+
.`Backstage` Custom resource fragment
81+
[source,yaml]
82+
----
83+
apiVersion: rhdh.redhat.com/v1alpha1
84+
kind: Backstage
85+
spec:
86+
application:
87+
extraFiles:
88+
configMaps:
89+
- name: rbac-policies
90+
- name: rbac-conditional-policies
91+
----
92+
93+
. Update your {product-short} `app-config.yaml` configuration file to use the external files in {product-short}:
94+
+
95+
.`app-config.yml` fragment
96+
[source,yaml]
97+
----
98+
permission:
99+
enabled: true
100+
rbac:
101+
conditionalPoliciesFile: ./rbac-conditional-policies.yaml
102+
policies-csv-file: ./rbac-policies.csv
103+
policyFileReload: true
104+
----

0 commit comments

Comments
 (0)