My Requirements : 1) identity server clients and api-resource load from my database not from my static config file. 2) I need to add clients from my API and refresh clients automatically in my AUTH server.
What i did is ,
IEnumerable<Customers> clients = _accountservice.GetAllClients();
clients.ToList().ForEach((client) =>
{
authclients.Add(new Client
{
ClientId = client.ClientId,
ClientSecrets =
{
new Secret(client.ClientSecret.Sha256())
},
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
AllowedScopes = {client.AllowScopes },
AccessTokenType = AccessTokenType.Jwt,
AlwaysSendClientClaims = true,
Claims = new List<Claim>() {
new Claim("Client Id",client.ClientId , ClaimValueTypes.String)
}
});
});
In my startup.cs
services.AddIdentityServer().AddDeveloperSigningCredential()
.AddInMemoryApiResources(AuthConfiguration.GetApiResources())
.AddInMemoryClients(AuthConfiguration.GetClients()).AddProfileService<ProfileService>().AddResourceOwnerValidator<ResourceOwnerPasswordValidator>();
Every clients loading from database . First time i was add clients and host in IIS server. After i am adding client means i need to restart the server. But i don't want like that auto refresh option i need in my identity server.
I am using identity server 4.
答案 0 :(得分:2)
1)无法从我的数据库加载身份服务器客户端和api资源 从我的静态配置文件中。
幸运的是,Identity Server 4完全支持Entity Framework,并提供了许多开箱即用的可配置性选项。您可以参考Entity Framework support的文档页面,其中有快速入门和指南,展示了如何进行一切设置。
2)我需要从我的API添加客户端并自动刷新客户端 在我的AUTH服务器中。
没有开箱即用的API允许您POST
个新客户端。您的选择可能是使用前面提到的IdentityServer.EntityFramework
软件包,并在其之上构建一个API服务层以添加该功能。话虽如此,我已经在一些项目中实现了OAuth,但从未遇到过构建此类API的理由。相反,我们将创建一个UI层来管理(添加和编辑)OAuth客户端。如果您认为这是您感兴趣的内容,请查看Identity Server创建者的Identity Server Admin UI。这是一个出色的用户界面,但是,它是一种商业产品,因此您需要付费。