Friday, October 09, 2009

VS2008 project template for OpenID and InfoCard relying parties

I finally built a project template to make it easier to write an OpenID relying party web site using C# and ASP.NET.  Up to this point all we had were the sample RPs that ship with DotNetOpenAuth, which were deliberately kept simple.  They didn’t use a real database, didn’t follow some best practices, and weren’t very real. 

Now you can start your next web site with OpenID and InfoCard logins already working!  Complete with role authorization, account management that allow for multiple OpenID/InfoCards per account, login and account creation.

And did I mention it’s free? (donations gratefully accepted)

Download it and copy the file (still zipped) into your %USERPROFILE%\Documents\Visual Studio 2008\Templates\ProjectTemplates folder and it will appear in your New Project wizard in Visual Studio 2008.

Yes, the site is still unbeautified, but that’s so you can brand it to look like yours.

Have fun.  And let me know what you think of it or can contribute.

3 comments:

mjwills.work said...

Lets say I have two Google accounts (G1 and G2).

I login to your sample website (running on my PC) as G1 and then logout again.

I now want to login as G2. SO I try and login again, but when I click Google on the sample website it logs me in automatically (without giving an opportunity to choose G2).

Is this an intrinsic limitation of OpenId (ala http://stackoverflow.com/questions/1385082/openid-how-do-you-logout )?

If so, how does rpxnow work? When you logout on rpxnow's website and then login again, it remembers your last login but has 'This isn't me' to allow you to switch to a different Google account. Are there any .Net OpenID samples showing how this could be achieved?

Andrew said...

Hi mjwills.work,

That's a very interesting scenario. It will work at any RP (RPXNow, DotNetOpenAuth, or other) until you click "Remember me" at Google while logging into a given RP. After which, Google will never intercept the login to the RP again, thereby not giving you the chance to choose to switch to G2.

At least from my testing just now that seems to be the case.

So if you really want to do this, it looks like the only way is to actually log out of your G1 account at Google first, and then try logging into the RP, which will then send you to Google where you can choose to log in as G1 or G2.

johnckirk said...

Firstly, thank you for all your hard work on this. I'm still trying to get my head around the OpenID thing, and hopefully this will make life easier.

Just as a suggestion, it might help to create a vsi file to distribute your template, as described here:
http://msdn.microsoft.com/en-us/library/ms185314.aspx

I stupidly unzipped it at first, then spent ages trying to figure out why it didn't like $safeprojectname$ - entirely my fault, but an installer file would make the process a bit more obvious to a doofus like me :)

Also, I'm using the Express version of Visual Studio at the moment. When I installed Visual Web Developer 2008, it complained about SQL 2005, so I had to upgrade that to SQL 2008. (I'm not sure whether this is a new requirement for SP1.) Unfortunately, that means that the SQL references in your project template don't work, since they're looking for v9 files, so I had to remove them and add the corresponding v10 references. Again, not a huge issue, but if most people have SQL 2008 installed then it might be worth updating the template.