Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.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
Oauth 2.0 保护用asp.net 5/web API 2编写的API_Oauth 2.0_Asp.net Web Api2_Owin_Identityserver4 - Fatal编程技术网

Oauth 2.0 保护用asp.net 5/web API 2编写的API

Oauth 2.0 保护用asp.net 5/web API 2编写的API,oauth-2.0,asp.net-web-api2,owin,identityserver4,Oauth 2.0,Asp.net Web Api2,Owin,Identityserver4,所有示例都解释了如何保护用asp.net内核编写的API services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { options.Authority = "http://localhost:5000"; options.RequireHttpsMe

所有示例都解释了如何保护用asp.net内核编写的API

services.AddAuthentication("Bearer")
               .AddIdentityServerAuthentication(options =>
               {
                   options.Authority = "http://localhost:5000";
                   options.RequireHttpsMetadata = false;

                   options.ApiName = "api1";
               });
是否可以使用Identity Server 4使用完整的.net framework保护asp.net 5/web api2中编写的API。怎么做?

是的,这是可能的

使用程序集
Microsoft.Owin.Security.OpenIdConnect
中的
UseOpenIdConnectAuthentication
在启动配置代码中配置openid connect:

比如说

        app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions() {
                Authority = "http://localhost:5000",
                ClientId = "yourclientid",
                RedirectUri = "http://yourredirecturi",
                ResponseType = "id_token token",
                SignInAsAuthenticationType = "Cookies",
                RequireHttpsMetadata = false,
        });