Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 不同路径的Owin AuthenticationMode主动和被动_Asp.net_Owin - Fatal编程技术网

Asp.net 不同路径的Owin AuthenticationMode主动和被动

Asp.net 不同路径的Owin AuthenticationMode主动和被动,asp.net,owin,Asp.net,Owin,我正在使用Owin WsFederation身份验证。对于未经授权的用户,我希望一条路径重定向到STS,另一条路径返回401响应。是否可以为不同的路径设置不同的AuthenticationMode?我不知道-但是您可以在管道中添加多个中间件实例,使用不同的AuthenticationType,并在不同的路由上使用它们。您可以“分叉”OWIN管道,以便为不同路径配置不同的中间件 public void Configuration(IAppBuilder app) { app.UseErro

我正在使用Owin WsFederation身份验证。对于未经授权的用户,我希望一条路径重定向到STS,另一条路径返回401响应。是否可以为不同的路径设置不同的AuthenticationMode?

我不知道-但是您可以在管道中添加多个中间件实例,使用不同的AuthenticationType,并在不同的路由上使用它们。

您可以“分叉”OWIN管道,以便为不同路径配置不同的中间件

public void Configuration(IAppBuilder app)
{
    app.UseErrorPage(new ErrorPageOptions());

    app.Map("active", active => 
    {
        active.UseOpenIdConnectAuthentication(
            new OpenIdConnectAuthenticationOptions
            {
                AuthenticationMode = AuthenticationMode.Active
                //TODO: Add other options.
            });
    });

    app.Map("passive", passive =>
    {
        passive.UseOpenIdConnectAuthentication(
            new OpenIdConnectAuthenticationOptions
            {
                AuthenticationMode = AuthenticationMode.Passive,
                //TODO: Add other options.
            });
    });
}
此示例将“错误页面”中间件配置为在所有请求上运行,然后继续创建两个URL映射管道,一个用于启动
/active
的请求,另一个用于启动
/passive
的路径。每个映射管道分别使用主动和被动模式部分配置OIDC身份验证中间件

此机制旨在当请求通过特定路径传入时,让您运行不同的中间件集。将公共中间件放在映射中间件之前,使其在每个请求上运行