Our MVC3 application is using Fluent NHibernate and requires implementation of user login, authentication and authorization.
I’ve seen articles using the [Authorize] method in the controller classes. However, I’m not sure how this all works in our situation given that Fluent NHibernate is in use.
Can anyone share some suggestions as to how to make this work?
You could write a custom role provider implementing the RoleProvider class. In your custom implementation you of the RoleProvider class you could use whatever database access technology you want – FluentNhibernate or whatever. Basically you are interested in implementing the IsUserInRole method.
Then decorate your controllers/actions with the Authorize attribute:
And here’s another
blog postthat covers writing a custom role provider in more details.