1
WebフォームアプリケーションをForms認証からOpenID Connect(OWINとIdentityServer3を使用)に移行しています。 このアプリケーションには、web.config内にさまざまな場所に対応する「認可」要素が多数あり、OWINに移行してから再利用したいと考えています。web.config認証要素を使用しているときにOWINチャレンジがトリガーされない
<authorization>
<deny users="?" />
</authorization>
<location path="Path/Page.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
...
問題は後に、私が代わりにログインページにリダイレクトされるのでOWINに切り替えて、私は401(無許可)を取得することです。
現時点ではログインページにユーザーをリダイレクトする唯一の方法は、手動でPage_Loadイベントに挑戦を作ることです。
public void ConfigureAuth(IAppBuilder app)
{
//reset the mapping dictionary to ensure the claims are not mapped to .NET standard claims
JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "ApplicationCookie",
AuthenticationMode = AuthenticationMode.Active
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
ClientId = "id",
Authority = IdentityConstants.BaseAddress,
RedirectUri = "uri",
ResponseType = "code id_token token",
SignInAsAuthenticationType = "ApplicationCookie",
Scope = "openid profile email roles offline_access",
...
}
...
:
if (!Request.IsAuthenticated)
{
HttpContext.Current.GetOwinContext().Authentication.Challenge();
}
これは私のStartup.Authがどのように見えるかです
web configの既存の認証要素を活用して、コードでこれらのチェックを再度行う必要はありませんか?これは、統合されたパイプラインで実行するようにOwinを指示します
app.UseStageMarker(PipelineStage.Authenticate);
: