現在、フォーム認証を使用してサブドメイン間で認証を行っています。したがって、次のサーバーがあります。
site1.domain.com
site2.domain.com
Forms Auth Cookie を共有できます。これが可能になる方法へのリンクは次のとおりです 。 http://msdn.microsoft.com/en-us/library/eb0zx8fc(v=VS.100).aspx
しかし今、アプリケーションにクレームを追加しています。この行を呼び出すと、次のようになります。
var sessionToken = new SessionSecurityToken(principal);
FederatedAuthentication.SessionAuthenticationModule.CookieHandler.Domain = "domain.com";
FederatedAuthentication.SessionAuthenticationModule.WriteSessionTokenToCookie(sessionToken);
シリアル化および暗号化されたクレームを含む "FedAuth=" Cookie が書き込まれていること。
しかし、現在、1 つのサブドメイン (site1) に FedAuth Cookie を設定して、他のサブドメイン (site2) に読み取らせることができません。次のエラーが表示されます。
Key not valid for use in specified state.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Security.Cryptography.CryptographicException: Key not valid for use in specified state.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[CryptographicException: Key not valid for use in specified state.]
System.Security.Cryptography.ProtectedData.Unprotect(Byte[] encryptedData, Byte[] optionalEntropy, DataProtectionScope scope) +397
System.IdentityModel.ProtectedDataCookieTransform.Decode(Byte[] encoded) +90
[InvalidOperationException: ID1073: A CryptographicException occurred when attempting to decrypt the cookie using the ProtectedData API (see inner exception for details). If you are using IIS 7.5, this could be due to the loadUserProfile setting on the Application Pool being set to false.]
System.IdentityModel.ProtectedDataCookieTransform.Decode(Byte[] encoded) +1158198
System.IdentityModel.Tokens.SessionSecurityTokenHandler.ApplyTransforms(Byte[] cookie, Boolean outbound) +173
System.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver) +756
System.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(Byte[] token, SecurityTokenResolver tokenResolver) +100
System.IdentityModel.Services.SessionAuthenticationModule.ReadSessionTokenFromCookie(Byte[sessionCookie) +668
System.IdentityModel.Services.SessionAuthenticationModule.TryReadSessionTokenFromCookie(SessionSecurityToken& sessionToken) +164
System.IdentityModel.Services.SessionAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs eventArgs) +173
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
Forms Auth を使用する前は、これは問題ではなく、機能していました。
すべてが同じドメインを使用するサブドメイン間でこれらの FedAuth Cookie を共有するには、何をする必要がありますか?
はい、両方のサイトの web.config ファイルに同じ machineKey があります。また、各サイトのアプリケーション プールの loadProfile 設定は false に設定されています。
STSを使わずにこれを実行できるようにしたい. STS はオーバーヘッドと複雑さをもたらします。FedAuth Cookie サブドメイン フレンドリーにラップされたクレームを使用できない理由がわかりません。
ありがとう、マイク