Я искал все о том, как зарегистрировать UserService
с IdentityServer4 в ядре asp.net, но я не могу найти правильный способ сделать это.
Это код для регистрации InMemoryUsers, найденного здесь, однако я хотел бы получить доступ к пользователям из моей базы данных MSSQL, а не статическим пользователям, определенным в образец.
var builder = services.AddIdentityServer(options =>
{
options.SigningCertificate = cert;
});
builder.AddInMemoryClients(Clients.Get());
builder.AddInMemoryScopes(Scopes.Get());
builder.AddInMemoryUsers(Users.Get());
Итак, я посмотрел на этот, который для IdentityServer3.
var factory = new IdentityServerServiceFactory()
.UseInMemoryClients(Clients.Get())
.UseInMemoryScopes(Scopes.Get());
var userService = new UserService();
factory.UserService = new Registration<IUserService>(resolver => userService);
Из чтения онлайн кажется, что мне нужно использовать систему DI для регистрации UserService, но я не уверен, как она привязывается к IdentityServer, например.
services.AddScoped<IUserService, UserService>();
Итак, мой вопрос:
Как связать мой UserService
с разработчиком (IdentityServer4 Users)? И как мне обратиться к моей базе данных для доступа и аутентификации моих существующих пользователей db в UserService
(я использую репозитории для подключения к db)?
Учитывая это, нужно работать с ядром asp.net.
Спасибо!