- ABP Framework version: v5.3.4
- UI type: Angular
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no
Hi,
For example, there is a Product microservice. I want to show the user who created a record in this Product table on the listing screen. AbpUser is located in another microservice.
Product Name Created By Product1----> Guven Product2---> Galip Product3----> Maliming . . .
3 Answer(s)
-
0
CreatorId
should be audited anyway so you can use the ExternalUserLookupService to get detailed info about the user.Although, you can also duplicate the data. You can add the CreatorName (or what else I need) to the
Product
entity. -
0
Hi, Is it possible to share sample code about it? Is there an example in abpframework github repos?
-
0
If you are going to use it for names only, data duplication makes more sense imho.
But if you want to keep users in your microservice to use for different scenarios as well, you can create a lookup user like
ProductUser
to keep in your microservice. Check the CmsUser for implementation details.Then you can create an
IProductUserLookupService
to handle user lookups. See ICmsUserLookupService and CmsUserLookupService for implementation details.This service checks if the local user exists, if it doesn't exist, it makes an external request to
IdentityService
and saves it as the local user and returns the user. You can also override the default behavior and configure it to check the external source all the time. See UserLookup implementation for more details.1. To make the
ExternalUserLookupServiceProvider
for the microservice, you need to configure your microservice as a client. In the IdentityServer/OpenIddict DataSeeder, add your microservice as a client (like the administration service). You can check the CmsService in eShopOnAbp registered to use IdentityService as a client with the required UserLookup permission. 2. Add<PackageReference Include="Volo.Abp.Identity.HttpApi.Client" Version="your-prefered-version" /> <PackageReference Include="Volo.Abp.Http.Client.IdentityModel.Web" Version="your-prefered-version" />
project references to the microservice that contains the UserLookUp service and don't forget to add
typeof(AbpIdentityHttpApiClientModule), typeof(AbpHttpClientIdentityModelWebModule)
to the microservice API host module. 3. Add configuration for server-to-server communication in the appsettings.json with the client_id you have set in the identityserver/openIddict data seeder as in the CmsService client credentials configuration sample.
Now you can inject
IProductUserLookupService
and search/find users.