我正在使用Identity Server 4,ASP.NET Core並嘗試在生產環境中替換IdentityServer開發人員。但得到以下錯誤:IdentityServer 4:沒有指定授予的存儲機制 - 使用AddInMemoryStores
No storage mechanism for grants specified. Use the 'AddInMemoryStores' extension method to register a development version.
所以,我試圖實現服務如本answer提到:
- IProfileService
- IResourceOwnerPasswordValidator
這是我ConfigureServices方法啓動班:
services.AddMvc();
var identityBuilder = services.AddIdentityServer();
identityBuilder.AddInMemoryScopes(identitySrvConfig.GetScopes());
identityBuilder.AddInMemoryClients(identitySrvConfig.GetClients());
identityBuilder.AddProfileService<ProfileService>();
identityBuilder.Services.AddTransient<IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
考慮到我的情況下,接口簽名是不同的:
public class ResourceOwnerPasswordValidator : IdentityServer4.Validation.IResourceOwnerPasswordValidator
{
public Task ValidateAsync(ResourceOwnerPasswordValidationContext context)
{
throw new NotImplementedException();
}
}
但我仍然得到同樣的錯誤,這是什麼問題?
我是有身份的服務器更新到RC3,以及所使用的'AddInMemoryPersistedGrants'。然而,它說:「您正在使用持久授權存儲的內存版本,這會將同意決定,授權碼,刷新和參考標記存儲在內存中。如果 正在使用生產中的任何產品,則需要切換到不同的商店實現。我使用隱式流而不是刷新和引用標記。那麼,在投入生產時會如何影響我的服務器呢? – Coding
如果您沒有持久授予某種形式的數據存儲(SQL/Mongo),那麼它們將在部署之間丟失。因此,如果您計劃在生產中使用此功能,請使用支持查詢的數據存儲庫實施'IPersistedGrantStore'。 – Lutando