views:

24

answers:

2

Curious what recommendations anyone has.

I have an existing asp.net forms application that does a Forms Authentication and has identity impersonate turned on.

The application has a link to a questionnaire that I would like to develop separately in an asp.net MVC application, but I don't want the users to click on the link and be prompted for a username and password, I would like them to be able seamless start filling out the questionnaire.

Is there a way to somehow transfer authentication from one .net app to another? I would like to be able to pass stuff like UserRole.

What's the best way to do this?

+1  A: 

Using Windows Identity Foundation (WIF) you can achieve Single Sign-On.

In WIF, a service called a Security Token Service (STS), issues a token with claims, which can be anything you want to declare about the authenticated user, for instance his roles. In your apps you can use the Page.User, Controller.Page or Thread.Current.Principal properties to check the User claims (though if you'll only be using role claims you can use the IsInRole method for simplicity).

You can easily create a STS using the tools for VS included in WIF's SDK. The Forms authentication will be done in the STS instead of in the Web Forms site and both sites should have a trust relationship with the STS.

Anero
Thanks Anero, I'll check into STS.
Mark Kadlec
+1  A: 

If you use the same MachineKey in both applications and the MVC application is on the same server, I think that it will reuse the auth cookie and simply consider them logged in. See this MSDN article on configuring the MachineKey, especially the section on sharing authentication tickets across applications. Note this assumes that both applications are on the same server. If they are on different servers then you'll need to investigate some other mechanisms -- say generating a single-use ticket for the URL that can be used by the remote system via a web call back to the originating server who the user is. It might not need to be a full-up implementation of a central authentication system, but along those lines. Just be sure that you're using SSL to encrypt the relevant bits to help avoid man-in-the-middle attacks.

tvanfosson
Thanks tvanfosson, knowing this I can easily push for the MVC app to be on the same Server, that should not be a problem. I read the article you suggested, should work fine. A little bit of work, but should do the job once I generate the two keys.
Mark Kadlec

related questions