私はちょうど2つのサーバー間で簡単なテストを作成しています。基本的に、ユーザーがすでに認証済みの場合、アプリケーション間でユーザーを渡すことができるようにしたいと考えています。私は3つの質問を持っている彼らにクロスドメインフォーム認証クッキーの適切な作成
を非表示にするには、キーを変更:
ドメインアプリケーション全体でクッキーを検証するための適切な方法は何ですか- 。たとえば、ユーザーが
successpage.aspx
になったとき、何を確認する必要がありますか? - 以下のコードは、クロスドメイン認証Cookieの作成に有効ですか?
web.config
は正しくセットアップされていますか?
マイコード:
if (authenticated == true)
{
//FormsAuthentication.SetAuthCookie(userName, false);
bool IsPersistent = true;
DateTime expirationDate = new DateTime();
if (IsPersistent)
expirationDate = DateTime.Now.AddYears(1);
else
expirationDate = DateTime.Now.AddMinutes(300);
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
userAuthName,
DateTime.Now,
expirationDate,
IsPersistent,
userAuthName,
FormsAuthentication.FormsCookiePath);
string eth = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, eth);
if (IsPersistent)
cookie.Expires = ticket.Expiration;
cookie.Domain = ".myDomain.com";
Response.SetCookie(cookie);
Response.Cookies.Add(cookie);
Response.Redirect("successpage.aspx");
}
マイ設定:
<authentication mode="Forms">
<forms loginUrl="~/Default.aspx" timeout="2880" name=".AUTHCOOKIE" domain="myDomain.com" cookieless="UseCookies" enableCrossAppRedirects="true"/>
</authentication>
<customErrors mode="Off" defaultRedirect="failure.aspx" />
<machineKey decryptionKey="@" validationKey="*" validation="SHA1" decryption="AES"/>
v4.5のWebサイトでVS 2013にフォーム認証を設定し、ドメインを「acme.com」に設定しました。 site1.acme.comにアクセスし、認証するとクッキーが設定されますが、Firebugではクッキーは私が思っていたようにacme.comではなくsite1.acme.comドメインに保存されます。 私が想定したことは、ブラウザがsite1.acme.comとsite2.acme.comの両方の要求に応じて認証クッキーを送信し、両方のマシンキー設定が同じであるためです確かに私の場合は起こっていない。私が間違っているアイデアは? – Jacques