Jos*_*osh 5 asp.net oauth-2.0 owin openid-connect identityserver4
我正在使用 IdentityServer4 并尝试连接一个 MVC 应用程序以进行身份验证。我目前通过使用隐式流来工作,但我遇到了访问令牌即将到期并且没有对隐式的刷新令牌支持的问题。我今天还读到,在浏览器变得良好之前,隐式是为 js 应用程序设计的,它不如授权代码流那么安全。
所以。我想让我的应用程序使用授权代码流。我无法使用 owin 找到任何一种简单的解决方案。我认为有一种很好且广泛自动化的方法可以让 owin 负责交换访问令牌的代码等等。在网上广泛研究后,我发现这段代码似乎在谈论我在做什么:
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
...
TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name",
RoleClaimType = "https://schemas.quickstarts.com/roles"
}
...
});
Run Code Online (Sandbox Code Playgroud)
有没有人有关于让 owin 做这一切的任何例子或其他信息?
相关信息:IdentityServer4 Client is .Net Framework 4.6
小智 1
在启动时添加此代码使用此客户端 GrantTypes
public static ICollection<string> CodeAndClientCredentials => new string[2] { "authorization_code", "client_credentials" };
services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme).AddOAuth2Introspection("token", (options) =>
{
var authorityUrl = Configuration["AUTHORITY_URL"];
options.IntrospectionEndpoint = authorityUrl + "/connect/introspect";
options.ClientId = string.IsNullOrEmpty(this.Configuration["AUTH_API_NAME"]) ? "identity_api" : this.Configuration["AUTH_API_NAME"];
options.ClientSecret = string.IsNullOrEmpty(this.Configuration["AUTH_API_SECRET"]) ? "secret" : this.Configuration["AUTH_API_SECRET"];
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
813 次 |
| 最近记录: |