Access control and page security
There is a fairly comprehensive security mechanism in place for Silverstripe CMS. If you want to add premium content to your site you have to figure this stuff out, and it's not entirely obvious.
Ways to restrict access
There are a number of ways to restrict access in Silverstripe CMS. In the security tab in the CMS you can create groups that have access to certain parts. The options can be found on the permissions documentation.
Once you have groups, you can set access for each page for a particular group. This can be:
- any person who is logged in;
- a specific group.
It is unclear how this works for data-objects that are not pages.
The security groups in Silverstripe CMS
In the security tab you can make groups for security. The way this was intended was as follows (this may be a counter intuitive):
- marketing executive
Thus, the further up the hierarchy you go the MORE privileges you can get. Similarly, you could have:
Where members have some privileges, coordinators slightly more and administrators the most; having each group inheriting privileges from its parent group.
Permission checking is at class level
Silverstripe CMS provides a security mechanism via the Permission::check method (see LeftAndMain for examples on how the admin screens work).
(next step -- go from Permission::checkMember...)
Nuts and bolts -- figuring it out
Here are my notes trying to figure this stuff out. Not really useful unless you're VERY interested in how exactly SS works.
Loading the admin page: looking at security
Security::permissionFailure() is the next utility function you can use to redirect to the login form.
Customizing access checks in CMS classes