最近、既存の Web アプリケーションでクレームベース認証を使い始めました。アプリケーションは jQuery と、特に AJAX 関数を使用するため、ハンドラーを変更してXmlHTTPRequests
.
FederatedAuthentication.WSFederationAuthenticationModule.AuthorizationFailed
イベント ハンドラは次のとおりです。
protected void WSFederationAuthenticationModule_AuthorizationFailed(object sender, AuthorizationFailedEventArgs e)
{
//WSFederationAuthenticationModule sam = (WSFederationAuthenticationModule)sender;
HttpContext context = HttpContext.Current;
HttpRequest req = context.Request;
HttpResponse resp = context.Response;
if (req == null || resp == null) return;
if ((resp.StatusCode == 302 || resp.StatusCode == 401) && req.Headers["X-Requested-With"] == "XMLHttpRequest")
{
resp.StatusCode = 403;
e.RedirectToIdentityProvider = false;
}
}
AJAX 呼び出しを実装して応答を処理する次のパターンがあります。
$.ajax({
cache: false,
data: $.param(o),
dataType: "xml",
url: "AJAXCall.ashx",
success: function (data)
{
// Success handler
},
error: function (XMLHttpRequest, textStatus, responseText)
{
if (XMLHttpRequest.status == 403)
{
var retVal = window.showModalDialog("Session.aspx", "", "dialogHeight: 250px; dialogWidth: 250px; edge: Raised; center: Yes; resizable: Yes; status: Yes;");
if (retVal)
{
// Succesful session renewal handler
}
else
{
// Session renewal failure handler
}
}
else
{
// Other errors handler
}
}
});
'Session.aspx' は基本的にモーダル ダイアログを閉じて、ID プロバイダーへのリダイレクトと戻りが成功した場合、戻り値は true になります。
しかし、私の問題は、次のエラーが発生することです。
「ID4223: SamlAssertion.NotOnOrAfter 条件が満たされていないため、SamlSecurityToken は拒否されました。」
これは、現在のアプリケーション ユーザーを偽装するサブシステムで呼び出され、明らかに前のセッションのトークンが引き続き保持されます。アプリケーションの web.config に次の設定があります。
<federatedAuthentication>
<wsFederation passiveRedirectEnabled="true" persistentCookiesOnPassiveRedirects="true" issuer="https://adfs.example.com/adfs/ls/" realm="https://www.example.com:449/" requireHttps="true" />
<cookieHandler requireSsl="true" />
このエラーを回避するにはどうすればよいですか? どんな助けでも大歓迎です。