OpenId Part Three: Authorization

Posted by: Clarity Blogs: ASP.NET, on 04 Sep 2009 | View original | Bookmarked: 0 time(s)

As promised in part two, Ill close the loop on OpenId by talking briefly about authorization. Weve already seen how to authenticate, so once youve got an authenticated OpenId identifier, the trick is what to do with it. This does not end up being all that exciting; in my case linked back to an identifier column in my user table and to get information about the newly logged in user. Based on characteristics of that user, I could then determine their authorization level or roles. Stick the roles into the FormsAuth cookie in pipe delimited list and you can then write code like this in your controller action:

[Authorize]
       public ActionResult Edit(long id)
       {
           if (!User.IsInRole(UserRoles.CRUD)) return View("AccessDenied");

So going from authentication to authorization is not that big of a jump. Where it gets a little trickier is what I glossed over before, going from the OpenId identifier to the user. In an open, public site where you want as many to create accounts as possible this association can be created as part of new account set up.

When the site is meant to mostly private or internal, you dont just want anyone creating accounts with privileges to modify or access your data. Our solution was to set up users in the database, but leave the OpenId identifier blank. We then had a special url where we could point the actual user to go and register their OpenId identifier with the unclaimed user account. This still doesnt feel quite right to me, but it is workable for small, internally addressed sites. It was nice to work with OpenId and the excellent DotNetOpenAuth library, but overall it seems that OpenId fits more naturally for a public-facing, community oriented site.

Category: ASP.NET | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1944 | Hits: 30

Similar Posts

  • Introducing SharePoint 2010 Training at U2U more
  • GiveCamps Get a new Sponsor more
  • Announcing the WebsiteSpark Program more
  • Scenarios for WS-Passive and OpenID more
  • More On The CodePlex Foundation more
  • OpenId Part One: A Friend of A Friend more
  • ASP.NET MVC and the templated partial view (death to ASCX) more
  • Win a Govie Award Submit an Innovative Gov 2.0 Application more
  • The web vs. the fallacies of distributed computing more
  • PART I: Building Applications Using the .NET Service Bus more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD