Debian Codegraph @

doc/sources/admin/rbac.rst

raw
1 RBAC model
2 ==========
3
4 Presentation
5 ------------
6
7 `RBAC <http://en.wikipedia.org/wiki/Role-based_access_control>`__ stands
8 for Role Based Access Control. It means that you manage authorizations
9 to access applications by checking the role(s) of the user, and provide
10 this role to the application.
11
12 As the definition of access rules is free in LemonLDAP::NG, you can
13 implement an RBAC model if you need.
14
15 Configuration
16 -------------
17
18 Roles as simple values of a user attribute
19 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20
21 Imagine you've set your directory schema to store roles as values of an
22 attribute of the user, for example "description". This is simple because
23 you can send the role to the application by creating a HTTP header (for
24 example Auth-Role) with the concatenated values (';' is the
25 concatenation string):
26
27 ::
28
29 Auth-Roles => $description
30
31 If the user has these values inside its entry:
32
33 ::
34
35 description: user
36 description: admin
37
38 Then you got this value inside the Auth-Roles header:
39
40 ::
41
42 user; admin
43
44 Roles as entries in the directory
45 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46
47 Now imagine the following DIT:
48
49 - dc=example,dc=com
50
51 - ou=users
52
53 - uid=coudot
54
55 - ou=roles
56
57 - ou=aaa
58
59 - cn=admin
60 - cn=user
61
62 - ou=bbb
63
64 - cn=admin
65 - cn=user
66
67 Roles are entries, below branches representing applications. We can use
68 the standard LDAP objectClass ``organizationalRole`` to maintain roles,
69 for example:
70
71 .. code::
72
73 dn: cn=admin,ou=aaa,ou=roles,dc=example,dc=com
74 objectClass: organizationalRole
75 objectClass: top
76 cn: admin
77 ou: aaa
78 roleOccupant: uid=coudot,ou=users,dc=example,dc=com
79
80 A user is attached to a role if its DN is in ``roleOccupant`` attribute.
81 We add the attribute ``ou`` to allow LL::NG to know which application is
82 concerned by this role.
83
84 So imagine the user coudot is "user" on application "BBB" and "admin" on
85 application "AAA".
86
87 Gather roles in session
88 ^^^^^^^^^^^^^^^^^^^^^^^
89
90 Use the :ref:`LDAP group<authldap-groups>` configuration to store roles
91 as groups in the user session:
92
93 - Base: ou=roles,dc=example,dc=com
94 - Object class: organizationalRole
95 - Target attribute: roleOccupant
96 - Searched attributes: cn ou
97
98 Restrict access to application
99 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
100
101 We configure LL::NG to authorize people on an application only if they
102 have a role on it. For this, we use the ``$hGroups`` variable.
103
104 - For application AAA:
105
106 ::
107
108 default => groupMatch($hGroups, 'ou', 'aaa')
109
110 - For application BBB:
111
112 ::
113
114 default => groupMatch($hGroups, 'ou', 'bbb')
115
116 Send role to application
117 ^^^^^^^^^^^^^^^^^^^^^^^^
118
119 It is done by creating the correct HTTP header:
120
121 - For application AAA:
122
123 ::
124
125 Auth-Roles => ((grep{/aaa/} split(';',$groups))[0] =~ /([a-zA-Z]+?)/)[0]
126
127 - For application BBB:
128
129 ::
130
131 Auth-Roles => ((grep{/bbb/} split(';',$groups))[0] =~ /([a-zA-Z]+?)/)[0]
132