I am using OpenId in my ASP.NET MVC application. Works great :) After I have an OpenId user ID (as soon as they are authenticated and returned to my site), I upload user data (to get a display name, etc.).
From here I also know their roles.
I am not sure how to assign a role to the current Forms.Identity.
here is my code ...
// Load User... var user = GetUsers().ByOpenIdIdentifier("blahblahblahbl...."); // Here means we have a user AND all the roles, for that user. // Forms Authenticate and Redirect. FormsAuthentication.SetAuthCookie(user.DisplayName, true); return RedirectToAction("Index", "Home");
How can I change this code so that the authenticated user is assigned their roles?
Update
I came across this web post about creating a custom Authorize attribute. Notice how they check the role of registered users in the session? In addition, the roles are enumeration :) It's quite funny if you ask me :) It's nice and simple.
Thoughts (compared to the full RoleProvider class?)
authorization asp.net-mvc dotnetopenauth roles
Pure.Krome
source share