Boj*_*jan 2 c# identityserver4
我想知道是否有人可以向我解释AddInMemoryIdentityResources在启动期间注册身份服务器时的用途。从他们展示的示例来看,它看起来像这样(注意注释之间的代码):
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryPersistedGrants()
//********************
.AddInMemoryIdentityResources(Config.GetIdentityResources())
//********************
.AddInMemoryApiResources(configurationManager.GetApiResources())
.AddInMemoryClients(configurationManager.GetClients())
.AddAspNetIdentity<User>();
Run Code Online (Sandbox Code Playgroud)
那么配置文件是这样的:
public static IEnumerable<IdentityResource> GetIdentityResources()
{
return new List<IdentityResource>
{
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
};
}
Run Code Online (Sandbox Code Playgroud)
现在,我认为当你声明一个客户端时,你定义了范围,基本上说你可以传递用户名、id 等...但是,那么这个语句的意义是什么,.AddInMemoryIdentityResources(Config.GetIdentityResources())因为它似乎做了同样的事情,但还没有它是全球性的,因为它不与任何客户联系?
AddInMemoryIdentityResources 基本上定义了可用身份范围的全局列表。即客户可以参考的主列表。