开发者

MVC RelyingParty and Provider as single code base

开发者 https://www.devze.com 2023-03-15 09:38 出处:网络
I have been converting the projects: OpenIdRelyingPartyMvc and OpenIdProviderMvc to be the same code base. I wish to have a website which can provide both of those functions.

I have been converting the projects: OpenIdRelyingPartyMvc and OpenIdProviderMvc to be the same code base. I wish to have a website which can provide both of those functions.

The integration parts left on my list are as follows.

Case 1

OpenIdProviderMvc requires the following routes as specified in the global.asax. However, having these routes breaks OpenIdRelyingPartyMvc from displaying the OpenID textbox and login button. Instead it says "This is login's OpenID identity page".

//-- OpenIdProviderMvc requires these, however, it breaks OpenIdRelyingPartyMvc 
routes.MapRoute(
    "User identities",
    "user/{id}/{action}",
    new {controller = "User", action = "Identity", id = string.Empty, anon = false});
routes.MapRoute(
    "PPID identifiers",
    "anon",
    new {controller = "User", action = "Identity", id = string.Empty, anon = true});

Case 2

The second difference is the forms authentication in the web.config.

//-- OpenIdRelyingPartyMvc
<forms defaultUrl="~/Home" loginUrl="~/User/Login" name="OpenIdRelyingPartyMvcSession"/>

//-- OpenIdProviderMvc
<forms loginUrl="~/Account/LogOn" timeout="2880" name="ProviderMvcSession"/>

How can I complete the integration gi开发者_开发知识库ven these two remaining case?

Thank you


Note: Currently my requirement is a single user per site.

The solution I found is:

  1. All terms and action of "Logon" change to "Login", "Logoff" to "Logout".

  2. Have a single link on the home page to /Account/Login

  3. The Account/Login is to have both user login and openid login on the same page. The also involves moving identity to account controller and removing the UserController/actions as this was basically just an authenticated members area.

  4. The forms authentication to be /Account/Login version too (web.config) as changed by (1)

  5. All XRDS xml documents to be named XRDS-Party or XRDS-Provider respectivly and also need to be returned from views as xml without their surrounding layout. I was only able to do this by instead of returning View(), to return Content() with the help of another method RenderPartialViewToString() from http://learningdds.com/public/ControllerExtension.cs

  6. Log4net is your friend, especially when "No endpoint could be found" error. It also helped me find that the returned xml document was surrounded by xml.

Lastly, the above steps are not a complete guide to converting the solution to be a single code base. Hopefully it will help you and feel free to ask Qs.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号