see using a custom storage provider:
Blazor hosted WebAssembly - AddIdentityServer().AddApiAuthorization replacement.
I talked about standard template project Blazor WebAssembly hosted with Individual Account authentication type and NET5.0
Into server part there is a lines:
services.AddIdentityServer()
.AddApiAuthorization<ApplicationUser, ApplicationDbContext>…
Where is ApplicationDbContext makes me using of server local database with EF.
Is there a way to use service istead? Something like this:
services.AddIdentityServer()
.AddApiAuthorization<ApplicationUser>
.CustomDataStore()
Look like “AddApiAuthorization” is not splitable.
2 answers
Sort by: Most helpful
-
-
Brando Zhang-MSFT 2,956 Reputation points Microsoft Vendor
2021-09-14T07:34:22.833+00:00 Hi @Alex256 ,
According to the AddApiAuthorization source codes, you could find the AddApiAuthorization method will also call the AddOperationalStore method to set the dbcontext .
You said want to use service instead, I think this method not support service as the parameter now.The AddOperationalStore's parameter should be with any EF-supported database.
More details about how to use this AddOperationalStore method, you could refer to this article.
Notice: AddOperationalStore's first opinion should be ConfigureDbContext. ConfigureDbContext is the delegate of type Action<DbContextOptionsBuilder> used as a callback to configure the underlying ConfigurationDbContext. The delegate can configure the ConfigurationDbContext in the same way if EF were being used directly with AddDbContext, which allows any EF-supported database to be used.
If you still want to custom this method to use some custom store, I suggest you could write an new extension method and create the IIdentityServerBuilder based on your requirement with some custom store. Details about how to do it, I suggest you could try to refer to this article and this article.