How to persist user consent information in database Identity Server

心已入冬 提交于 2021-01-28 20:02:07

问题


I'm using IdentityServer4 and whenever the user login for the first time the application shows consent screen for the scopes of an application to the user which is expected. If the user clicks "yes" and click on remember option the application is not showing the consent screen when the user login for second time onwards which is also expected. Here the problem I'm facing is whenever I restart the IdentityServer (or when I do the deployment) the user consent information is not persisting and it is showing the consent screen again for the user. Can anyone help me to know Is there any way to store the user consent information into DataBase or how can we know where the information is being stored when the application is in running. I did some debugging but couldn't find it. Thanks in advance.


回答1:


Add reference IdentityServer4.EntityFramework.Storage nuget package to identity server 4 project, Then in startup.cs

service.AddIdentityServer((options) => {})
.AddPersistedGrantStore<PersistedGrantStore>()
// Add other services.

The PersistedGrantStore requires PersistedGrantDbContext uses EntityFramework and requires the DbContext to be configured (same way you configure other EntityFramework DbContext). For example to use SQL Server

services.AddDbContext<PersistedGrantDbContext>(options =>
  options.UseSqlServer(connectionString));

You can use dotnet-ef command tool to create and initialize the tables in the database.

You can also have your own implementation of IPersistedGrantStore service.



来源:https://stackoverflow.com/questions/63438175/how-to-persist-user-consent-information-in-database-identity-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!