I am new to IdentityServer and am having a little trouble setting this up.
For reasons I won't go into here I can't use ASP.NET Identity or EntityFramework. I have a custom database for users that I need to authenticate against so I took the samples and tried to switch out the InMemoryUsers for a custom persistence store.
Here is my ConfigureServices method:
public void ConfigureServices(IServiceCollection services)
{
services.AddIdentityServer(options =>
{
options.AuthenticationOptions = new IdentityServer4.Configuration.AuthenticationOptions
{
};
})
.AddInMemoryClients(Clients.Get())
.AddInMemoryScopes(Scopes.Get())
.SetTemporarySigningCredential();
services.AddMvc();
services.AddTransient<ISignInService, SignInService>();
services.AddTransient<IUserRepository, UserRepository>();
services.AddTransient<IUserService, UserService>();
services.AddTransient<IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
services.AddTransient<IProfileService, ProfileService>();
}
I know this method is imperfect as I am still testing some things, but when I run the application I get this error:
System.InvalidOperationException No storage mechanism for grants specified. Use the 'AddInMemoryStores' extension method to register a development version.
Obviously I don't want to use in memory stores for a production implementation, but I am not sure what I need to do to fix this.
AddInMemoryStores does not have the best name. It actually adds the store for all the transient data that relates to issued materials/tokens.
We use it in production sometimes because a lot of the time we don't really need to persist this data to disk, and we don't use long lived tokens.
Take a look at what the extension method does here and look at what the IPersistedGrantStore
contract looks like to get a better idea.