c# - How do you pass an authenticated session between app domains -
lets have websites www.xyz.com , www.abc.com.
lets user goes www.abc.com , authenticated through normal asp .net membership provider.
then, site, sent (redirection, linked, whatever works) site www.xyz.com, , intent of site www.abc.com pass user other site status of isauthenticated, site www.xyz.com not ask credentials of said user again.
what needed work? have constraints on though, user databases separate, not internal organization, in regards, passing stackoverflow.com google authenticated, separate in nature. link relevant article suffice.
try using formauthentication setting web.config authentication section so:
<authentication mode="forms"> <forms name=".aspxauth" requiressl="true" protection="all" enablecrossappredirects="true" /> </authentication>
generate machine key. example: easiest way generate machinekey – tips , tricks: asp.net, iis ...
when posting other application authentication ticket passed hidden field. while reading post first app, second app read encrypted ticket , authenticate user. here's example of page passes posts field:
.aspx:
<form id="form1" runat="server"> <div> <p><asp:button id="btntransfer" runat="server" text="go" postbackurl="http://otherapp/" /></p> <input id="hdnstreetcred" runat="server" type="hidden" /> </div> </form>
code-behind:
protected void page_load(object sender, eventargs e) { formsidentity cidentity = page.user.identity formsidentity; if (cidentity != null) { this.hdnstreetcred.id = formsauthentication.formscookiename; this.hdnstreetcred.value = formsauthentication.encrypt(((formsidentity)user.identity).ticket); } }
also see cross app form authentication section in chapter 5 of book wrox. recommends answers ones above in addition providing homebrew sso solution.
Comments
Post a Comment