noelbundick's CAS authentication for OwinをMVC 5アプリケーションに実装しようとしていますが、ひねりがあります。これを唯一のログインまたはログアウト方法にしたいので、認証なしでアプリケーションを開始し、すべての認証をセットアップするためにthis tutorialを使用しました。また、外部認証を組み込んだ別の新しいソリューション私がしていることを比較する。MVC 5 Owin CASログオフアクションがログオフしない
私はCASのものですべてのGoogleのものを切り替えました。何らかの理由を除いてすべて正常に機能しますが、ログアウトボタンは機能しません。具体的には、
// POST: /Account/LogOff
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
return RedirectToAction("Index", "Home");
}
ここでアクションがSignOut()
機能をスキップし、RedirectToAction()
にまっすぐに行くようです。助けてくれるコードをいくつか追加しますが、他に何が助けることができるのか本当に分かりません。最初の段落の参照には、私が使用したすべてのコードと、Visual Studioが外部認証を使用する基本的なMVCサイトで提供するすべてのデフォルトコードが含まれています。
認証マネージャ:
private IAuthenticationManager AuthenticationManager
{
get { return HttpContext.GetOwinContext().Authentication; }
}
Startup.Auth.cs
private void ConfigureAuth(IAppBuilder app)
{
var cookieOptions = new CookieAuthenticationOptions
{
LoginPath = new PathString("/Account/Login")
};
app.UseCookieAuthentication(cookieOptions);
app.SetDefaultSignInAsAuthenticationType(cookieOptions.AuthenticationType);
CasAuthenticationOptions casOptions = new CasAuthenticationOptions()
{
CasServerUrlBase = "https://cas.ourserver.com/cas"
};
app.UseCasAuthentication(casOptions);
}
Startup.cs
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
}
ChallengeResult:
private class ChallengeResult : HttpUnauthorizedResult
{
public ChallengeResult(string provider, string redirectUri)
{
LoginProvider = provider;
RedirectUri = redirectUri;
}
public string LoginProvider { get; set; }
public string RedirectUri { get; set; }
public override void ExecuteResult(ControllerContext context)
{
var properties = new AuthenticationProperties() { RedirectUri = RedirectUri };
context.HttpContext.GetOwinContext()
.Authentication.Challenge(properties, LoginProvider);
}
}
明らかに、CASサーバーからログオフする必要はありません。ウェブサイトだけです。 CASクッキーが残っていれば問題ありません。問題は、それでも "ようこそ、ユーザー!"と言うことです。上部に「ログオフ」が表示されます。
私が助けてくれるものがあれば教えてください。私はすべてを探せて、オンラインやStackOverflowで解決策を見つけることができませんでしたが、私は正しい言葉もGoogleには書いていない可能性があります。