Oauth 2.0 保护用asp.net 5/web API 2编写的API
所有示例都解释了如何保护用asp.net内核编写的APIOauth 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
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,
});