RBAC stands for Role Based Access Control. It means that you manage authorizations to access applications by checking the role(s) of the user, and provide this role to the application.
As the definition of access rules is free in LemonLDAP::NG, you can implement an RBAC model if you need.
Imagine you've set your directory schema to store roles as values of an attribute of the user, for example “description”. This is simple because you can send the role to the application by creating a HTTP header (for example Auth-Role) with the concatenated values (';' is the concatenation string):
Auth-Roles => $description
If the user has these values inside its entry:
description: user description: admin
Then you got this value inside the Auth-Roles header:
user; admin
Now imagine the following DIT:
Roles are entries, below branches representing applications. We can use the standard LDAP objectClass organizationalRole
to maintain roles, for example:
dn: cn=admin,ou=aaa,ou=roles,dc=example,dc=com objectClass: organizationalRole objectClass: top cn: admin ou: aaa roleOccupant: uid=coudot,ou=users,dc=example,dc=com
A user is attached to a role if its DN is in roleOccupant
attribute. We add the attribute ou
to allow LL::NG to know which application is concerned by this role.
So imagine the user coudot is “user” on application “BBB” and “admin” on application “AAA”.
Use the LDAP group configuration to store roles as groups in the user session:
We configure LL::NG to authorize people on an application only if they have a role on it. For this, we use the $hGroups
variable.
default => groupMatch($hGroups, 'ou', 'aaa')
default => groupMatch($hGroups, 'ou', 'bbb')
It is done by creating the correct HTTP header:
Auth-Roles => ((grep{/aaa/} split(';',$groups))[0] =~ /([a-zA-Z]+?)/)[0]
Auth-Roles => ((grep{/bbb/} split(';',$groups))[0] =~ /([a-zA-Z]+?)/)[0]