More in this section

Forums / Developing with Sitefinity / Module Security

Module Security

2 posts, 0 answered
  1. Michael
    Michael avatar
    17 posts
    12 Oct 2008
    05 Dec 2008
    Link to this post
    I am about to implement my first Intra-Site module for sitefinity (first of any kind of module for Sitefinity).

    I have installed and carefully reviewed the Contacts module with LINQ and Security.  I am wondering how much of the security sections in that module transfer in a copy-and-paste fashion to a new module?

    For example, in the Security folder for the Contacts module there are two files: GlobalPermission.cs and GlobalPermissions.cs.  I have to say that it is not entirely clear to me what is going on with these files.  For my new module, can I just copy and paste them?  Is there anything going on inside of those two files that specific to a Contacts Module and would need tobe modified for my Foo module?  I am guessing the namespace is the key thing to change.  Is it really that simple?

    My question also pertains to the "security" region of the ContactsManager.cs file and the SecurityRoot, SecurityRoots overrides in the Module.cs file.  Again all of this seems to be generic.

    Finally, if these sections and files are truly generic, is there not a way to remove them from the module-specifc classes and abstract them out so they donot need to be copied and pasted for each module?

    I know these questions may sound nieve, but I am new to this.


  2. Pepi
    Pepi avatar
    981 posts
    31 Jan 2017
    15 Dec 2008
    Link to this post
    Hi Michael,

    Here are some instructions how to implement security for a module (in the brackets, I have provided references to the respective classes in the Contacts module):
    • Your module class should inherit from Telerik.Security.Permissions.SecuredModule base class (~/App_Code/Contacts/ContactsModule.cs). This class implements the ISecured interface.
    • In your manager class, implement a SecurityRoots dictionary (~/App_Code/Contacts/ContactsManager.cs)
    • The SecurityRoots property should persist an ID (GUID) for every secured object. When building modules this means one for each data provider. In order to do this, you need to implement two classes for your module and decide how to persist the ID of the secured object. These classes are GlobalPermission.cs and GlobalPermissions.cs. Take a look at their implementation in the Contacts module and do it similar in your own module (~/App_Code/Contacts/Security/).
    • When setting permissions through the UI, use the PermissionSet control, which uses these permission classes.
    • When checking for user permissions, do this through the manager by calling GetPermission(), which again uses the classes you have implemented in the third step.
    security implementation in the Contacts module is the same as in every other module. Just take a look at the classes I have mentioned and you'll have everything you need.

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
2 posts, 0 answered