IIS7 .Net Authorization Rules & mojoRoleProvider

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
4/9/2010 7:29:48 PM
Gravatar
Total Posts 13

IIS7 .Net Authorization Rules & mojoRoleProvider

I asked a similar question in the Site Administration forum but maybe it's too programmery.

Anyone know how to use the mojoPortal Roles from within IIS7 to control folder/file based access restrictions?  I want custom roles that I've created to be allowed access to certain restricted custom directories in the mojoPortal site.

Thanks

4/10/2010 1:28:18 PM
Gravatar
Total Posts 18439

Re: IIS7 .Net Authorization Rules & mojoRoleProvider

Hi Jason,

I think for it to work from the IIS console the dll and all dependent dlls would have to be both signed with a strong name key and installed in the GAC. None of that is anything I want to get involved with supporting.

There is a way to do it from Web.config and I have a feeling that is all the IIS tool does is modify the Web.config.

First you need to add the attribute like this in the system.webserver modules section:

<modules runAllManagedModulesForAllRequests="true">

this makes .NET handle static files. I believe it only works with an Integrated app pool not with Classic.

Then below the main system.web section you can add location elements with their own system.web sections. For example this setting would block access to the /Data/Sites/1/media folder for anyone except users in the Admins role:

<location path ="Data/Sites/1/media">
    <system.web >
      <authorization>
        <allow roles="Admins" />
        <deny users ="*"/>
      </authorization>
    </system.web>
  </location>

On another note, the Shared Files feature was designed specifically to share files with role protection so that only users in allowed roles have access to the Shared Files instance. The way the Shared Files feature works is to store the files on disk with a .config extension which is protected by ,NET, and only if the user is in the allowed role the file is served and renamed back to its original name which is stored in the db.

Hope it helps,

Joe

4/11/2010 3:00:35 AM
Gravatar
Total Posts 13

Re: IIS7 .Net Authorization Rules & mojoRoleProvider

Yes, that config trick worked - although, and I didn't investigate this too hard, but it really did seem that "Administrators" as a role in the config was not honored, only two new custom roles that I made are honored.  This is regardless of the order I put them in the config file (two separate Allow rules, or one allow rule, comma delimited, order doesn't matter)  "Administrators, Custom Role"  Only Custom Role members are granted the access.  So I just added the admin to the Custom Role and it works for my purposes.

Regarding the Shared Files note:  I tried to use the Shared Files for this, but I couldn't get it to work.  I didn't want the actual downloads component to show up on the page, just the videos files that I was offering through the blog feature.  If I added the Shared Files as a component on an Admin-only page for easy uploading, even with permissions set, the permissions were denied for the non-admin role members on the other Blog page.  Maybe I could use some combination of hiding the page from showing in the menu or the site map, without actually denying access, but it was getting too complicated.

Thanks for the tips!

4/11/2010 7:47:44 AM
Gravatar
Total Posts 18439

Re: IIS7 .Net Authorization Rules & mojoRoleProvider

Hi Jason,

If you look in the mp_Roles table you will see that roles have a RoleName and a Display name which in most cases are the same. RoleName never changes but Display name can change. The actual role name for Administrators is Admins because this is what I named it way back in 2004, though later added Display Name as Administrators.

When checking against roles it always uses the Role Name not the Display name.

Hope it helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.