Platform Engineer Activity: Setup RBAC [Optional Module]
Role-Based Access Control (RBAC) in Red Hat Developer Hub
By setting up the Role-Based Access Control (RBAC) configuration, the Platform Engineer can manage access of the users. You can define specific with specific permissions and then assigning those roles to the users to meet the specific needs of your organization. RBAC can be enable via REST API or configuration files.
In this module you will
-
define policies in a declarative fashion using a simple CSV based format
-
upload them to OpenShift as a ConfigMap
-
configure Developer Hub to use this ConfigMap
Enable RBAC Plugin and setup the policies
-
The policies are managed as a ConfigMap within OpenShift, and this has been pre-deployed to make deployment of this workshop easier.
-
Click here to view the policies on OpenShift
backstage
namespace. The RBAC policies are defined following Casbin rules formatWhat is Casbin?
Casbin is a powerful and efficient open-source access control library that supports various access control models for enforcing authorization. For information about the Casbin rules format, see Basics of Casbin rules. -
Policies can contain Role permissions (which roles can do what), and assign the role to a group or a user.
-
Following role permission states that any user or group with role
role:default/platformengineer
can create Catalog Entitiesp, role:default/platformengineer, catalog.entity.create, create, allow
-
Next, assign this role to the group
group:default/platformengineers
g, group:default/platformengineers, role:default/platformengineer
-
The result is that users belonging to
platformengineers
group can create Catalog Entities
-
-
The RBAC plugins and other config are in the Developer Hub configuration file store in GitLab. Access the your rhdh/developer-hub-config configuration on GitLab. Select Edit > Edit single file. When prompted, login as (pe1/{common_password})
-
There are 3 sections in the Developer Hub configuration that need to be setup. All of them are under
-- RBAC --
blocks. You can useCMD + /
orCTRL + /
keys to uncomment the blocks.-
Look for the first
--- RBAC ---
block; This has thejanus-idp-backstage-plugin-rbac
dynamic plugin which allows you to assign permissions to users and groups; highlight this block and uncomment -
The second
--- RBAC ---
block sets the admin users and references to the ConfigMap we referred to in the prev section; highlight and uncomment. -
The final
-- RBAC --
sets up the volumes and mounts needed to enable the RBAC config. This section is a bit long and so the screenshot is edited for brevity; highlight the whole section and uncomment. -
Scroll down and enter a commit message:
feat: enable RBAC
and Click the Commit button.
-
-
Visit the
backstage
Application in OpenShift GitOps and click Refresh. Wait till it turnsHealthy
If needed, login using
admin
/{openshift_gitops_password}
.
Test the RBAC setup
-
Access Developer Hub.
As a Platform Engineer
-
If you are already logged in ensure you are logged in as a as a Platform Engineer
Click to see how
-
Navigate to Developer Hub' Settings menu and check the logged-in user’s name under the Profile section.
-
If you are not logged in as a Platform Engineer, Click on Sign Out.
-
-
If you are not already logged-in, login in as
pe1/{common_password}
. -
You will now be able to view the RBAC policies you setup in the Administration > RBAC left-hand menu.
Click for more info
-
The policies generated from a policy.csv or ConfigMap file cannot be edited or deleted using the Developer Hub Web UI.
-
You can download the list of users in CSV format using the Developer Hub web interface.
-
This downloaded file contains a list of active users and last logged in times as shown below
userEntityRef,displayName,email,lastAuthTime user:default/dev1,dev1 rhdh,dev1@rhdemo.com,"Tue, 10 Dec 2024 05:25:00 GMT" user:default/pe1,pe1 rhdh,pe1@rhdemo.com,"Tue, 10 Dec 2024 05:25:22 GMT"
-
-
Navigate to the Create menu, and you can still see the Register Existing Component button.
As a Developer
-
Logout from your pe1 user, and login back as a developer with
dev1/{common_password}
. -
You will not be able to see the
Administration > RBAC
menu, since developers are not assigned theadmin
role in the Developer Hub configuration -
Navigate to the Create menu.
-
Note that you cannot see the Register Existing Component button. But you can still use the templates already created.
-
This is because, as we saw earlier, the RBAC policy has been setup to allow
catalog.entity.create
only forgroup:default/platformengineers
Conclusion
In this workshop, we have assume that only Platform Engineers can create Catalog Entities. But, you can setup the policies as it suits your organization.
For details on other ways to setup RBAC polices refer to the Authorization guide