I've been learning MVC and am looking at sessionless authentication (for reduced server strain/scaleability and also because AppFabric Cache is expensive on Azure Websites for hosting Session).
My user information is stored in SQL and each user has a Department, Rank, Roles and Permissions (and roles/Depts also have permissions). I was thinking that all I really need to store is their userId in a secure cookie and if it's not expired fetch the rest of their info with each request in the global.asax. I would secure it with a method such as http://eversystems.eu/Document/15/Sessionless_Authentication_with_Encrypted_Tokens
What I would like to end up with is the ability in my ViewModels to annotate them with custom fields
[Authorize(Roles="Admin")] [Authorize(Dept="IT")] [Authorize(Rank="Manager")]
or in the Html say
@if(User.IsInDept("IT")
or
@if(User.HasRank("Manager"))
I looked at extending the FormsAthenticationTicket
and Membership Provider / Roles
etc and IPricipal
and IIdentity
etc but it's difficult to understand exactly how i'd modify them all to achieve what i'm after. The examples i've seen have a lot of extra bloat that I don't want but the best example i've found is by @Ahmad Abu Raddad here ASP.NET MVC - Set custom IIdentity or IPrincipal
If someone could point out if i'm heading in the right direction or possibly suggest alternatives I would appreciate it.