asp.net-identity - 更改 IdentityServerAuthenticationOptions 客户端上的 ApiName 后仍然可以使用 Identity Server 4

标签 asp.net-identity .net-core identityserver4

我是 Identity Server 4 的新手,我正在关注官方 QuickStarts .

文档建议尝试一下选项,这样人们就可以了解这一切是如何工作的。但在我尝试了最后一个“进一步实验”点后,我遇到了麻烦。

当我更改 API Startup.cs 文件上的 ApiName 时,如下所示:

app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
    Authority = "http://localhost:5000",
    RequireHttpsMetadata = false,

    ApiName = "api2" //<-- this was api1
});

我仍在从客户端应用程序获取结果(执行 API 的 IdentityController 并返回用户声明的 json 数据)。

阅读文档(也可能根据常见逻辑)我相信,如果客户端应用程序获得与 API 所需的范围不同的范围(又名 ApiName),则它不应该能够访问 Controller 。

我对流程的理解错了还是什么?

最佳答案

我也不确定这一点,但我认为 ApiName 不是范围。如果添加

AllowedScopes = {"api2"} 添加到选项中,那么您将得到“Forbidden”结果。

Check this post

关于asp.net-identity - 更改 IdentityServerAuthenticationOptions 客户端上的 ApiName 后仍然可以使用 Identity Server 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41768949/

相关文章:

c# - ASP.NET Core 标识 userManager.AddToRoleAsync() - 通过 id 添加

c# - Identity Server 3 + AspNet Identity 中基于角色的声明

asp.net-mvc - 使用外部访问 token 或本地访问 token

javascript - 如何使用 AngularJS 和 MVC5 (ASP.NET Identity) 加载部分登录和注册 View

c# - Azure DevOps Pipeline 构建失败,因为它可以创建文件夹来写入 XML 文档文件

javascript - 如何在 MVC 应用程序中使用 JWT,其中使用 IdentityServer4 的某些 javascript 部分

nuget - 为什么我的 .NET Core 解决方案的包含文件夹中没有任何包文件夹?

c# - asp.net core 2.1 ConfigurationBuilder GetSection 函数返回null

reactjs - 使用 .net 核心 react 模板修改 oidc-client 的登录/登录 UI

c# - 身份服务器 4 无限循环