私はIdentityServer 3で新しく、サンプルとチュートリアルではInMemoryユーザー、クライアント、スコープを使用していますが、これらはDBからのものである必要があります。 IdentityServer 3 - DBからのクライアントとスコープの使用
public void Configuration(IAppBuilder app)
{
// Allow all origins
app.UseCors(CorsOptions.AllowAll);
var factory = new IdentityServerServiceFactory();
var userService = new UserService();
var clientStore = new ClientStore();
var scopeStore = new ScopeStore();
var corsService = new CorsService();
factory.UserService = new Registration<IUserService>(resolver => userService);
factory.ClientStore = new Registration<IClientStore>(resolver => clientStore);
factory.ScopeStore = new Registration<IScopeStore>(resolver => scopeStore);
factory.CorsPolicyService = new Registration<ICorsPolicyService>(resolver => corsService);
var options = new IdentityServerOptions
{
SiteName = "Embedded IdentityServer",
SigningCertificate = LoadCertificate(),
Factory = factory
};
app.UseIdentityServer(options);
}
Startup.csしかしClientStoreとScopeStoreに私はIdentityServer3.Core.Modelsクライアント/スコープに私のクライアント/範囲DBモデルからのマッピングをする必要が:だから私はやりました。このように:
ClientStore.cs
public Task<Client> FindClientByIdAsync(string clientId)
{
var clientFromDb = _db.Clients.SingleOrDefault(x => x.ClientId == clientId);
var client = new Client
{
ClientName = clientFromDb.ClientName,
ClientId = clientFromDb.ClientId,
AccessTokenType = clientFromDb.AccessTokenType,
Enabled = clientFromDb.Enabled,
Flow = clientFromDb.Flow,
RedirectUris = clientFromDb.RedirectUris.Select(x => x.Uri).ToList(),
PostLogoutRedirectUris = clientFromDb.PostLogoutRedirectUris.Select(x => x.Uri).ToList(),
AllowedCorsOrigins = clientFromDb.AllowedCorsOrigins.Select(x => x.Origin).ToList(),
AllowedScopes = clientFromDb.AllowedScopes.Select(x => x.Scope).ToList(),
AllowAccessToAllScopes = clientFromDb.AllowAccessToAllScopes,
AccessTokenLifetime = clientFromDb.AccessTokenLifetime
};
return Task.FromResult(client);
}
私のDBモデルは、これらのIdentityServer3.Core.Modelsからちょうどコピーしていることを知って、これを行うには良い方法はありますか?
ハムを、いや..私は... – Stel
はあなたがかもしれない何かを示唆するように更新することを望んでいません欲しいです。 –