From 5aab06775eae6ad0d5c843f9ae7895434fc2fb67 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Tue, 18 May 2010 16:43:55 +0100 Subject: [PATCH] SEC-1106: Added section on hierarchical roles to manual. --- .../src/docbook/authorization-common.xml | 117 +++++++----------- 1 file changed, 46 insertions(+), 71 deletions(-) diff --git a/docs/manual/src/docbook/authorization-common.xml b/docs/manual/src/docbook/authorization-common.xml index 60b327eebb..eecc4d0f52 100644 --- a/docs/manual/src/docbook/authorization-common.xml +++ b/docs/manual/src/docbook/authorization-common.xml @@ -294,75 +294,50 @@ boolean supports(Class clazz); AfterInvocationProviders. --> - +
+ Hierarchical Roles + + It is a common requirement that a particular role in an application should automatically + include other roles. For example, in an application which has the concept of + an admin and a user role, you may want an admin to be able to + do everything a normal user can. To achieve this, you can either make sure that all admin users + are also assigned the user role. Alternatively, you can modify every access constraint + which requires the user role to also include the admin role. + This can get quite complicated if you have a lot of different roles in your application. + + + The use of a role-hierarchy allows you to configure which roles (or authorities) should include others. + An extended version of Spring Security's RoleVoter, + RoleHierarchyVoter, is configured with a RoleHierarchy, + from which it obtains all the reachable authorities which the user is assigned. + A typical configuration might look like this: + + + + + + ROLE_ADMIN > ROLE_STAFF + ROLE_STAFF > ROLE_USER + ROLE_USER > ROLE_GUEST + +]]> + + Here we have four roles in a hierarchy ROLE_ADMIN => ROLE_STAFF => ROLE_USER => ROLE_GUEST. + A user who is authenticated with ROLE_ADMIN, will behave as if they have all four roles when + security contraints are evaluated against an AccessDecisionManager cconfigured + with the above RoleHierarchyVoter. The > symbol can be thought of + as meaning includes. + + + Role hierarchies offer a convenient means of simplifying the access-control configuration data for your + application and/or reducing the number of authorities which you need to assign to a user. For more + complex requirements you may wish to define a logical mapping between the specific access-rights your + application requires and the roles that are assigned to users, translating between the two when loading + the user information. + + +
+