Hello, I am using ABP 8.1.5 version so I can't use integration service.
I’m facing a permission/authorization issue while calling an AppService of one microservice from another in an ABP-based microservice architecture.
Scenario MS1Service contains ProductsAppService Permission required: MS1Service.Products
MS2Service calls ProductsAppService of MS1Service using client credentials flow
I created an Application Client with the following details:
ClientId: DAS Client Type: Confidential Grant Type: Client Credentials Allowed Scope: MS1Service Granted Permission: MS1Service.Products
**MS2Service **appsettings.json
"RemoteServices": {
"MS1Service": {
"BaseUrl": "https://localhost:44388/",
"UseCurrentAccessToken": "false"
}
},
"IdentityClients": {
"Default": {
"GrantType": "client_credentials",
"ClientId": "DAS",
"ClientSecret": "1q2w3e*",
"Authority": "https://localhost:44322",
"Scope": "MS1Service"
}
}
When **MS2Service **calls the AppService of MS1Service, I receive the following authorization error:
[INF] Authorization failed. These requirements were not met:
PermissionRequirement: MS1Service.Products
[WRN] ---------- RemoteServiceErrorInfo ----------
{
"code": "Volo.Authorization:010001",
"message": "Authorization failed! Given policy has not granted."
}
Is granting permission to the Application Client (DAS) sufficient for client-to-service calls? Is any additional configuration required in UseCurrentAccessToken or AbpAuthorizationOptions.
I’m trying to understand the correct and recommended way to authorize service-to-service AppService calls in ABP using client credentials.
Any pointers, examples, or documentation references would be greatly appreciated.
Thanks in advance!
imran@spacestem.com
I sent it by wetransfer.
I am getting following error now.
System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Church.Api.Services.IShipmentAppService Lifetime: Transient ImplementationType: Church.Api.Services.ShipmentAppService': Unable to resolve service for type 'AutoMapper.IMapper' while attempting to activate 'Church.Api.Services.ShipmentAppService'.)
I have added dependency of auto mapper.
[DependsOn(typeof(NxPBlobStoringAwsModule), typeof(AbpAutoMapperModule))]
public class ChurchAipModule : AbpModule
{
I have one .net core web api project which is not abp solution but I want to use the blob storing module with this project. I have created one module in the project as below.
[DependsOn(typeof(NxPBlobStoringAwsModule))]
public class NxPAipModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
//context.Services.AddAutoMapperObjectMapper<>();
base.PreConfigureServices(context);
Configure<AbpBlobStoringOptions>(options =>
{
options.Containers.Configure<DocumentBlobContainer>(container =>
{
container.UseAws(Aws =>
{
Aws.Region = "eu-west-2";
Aws.CreateContainerIfNotExists = true;
Aws.UseClientSideEncryption = false;
Aws.AccessKeyId = "";
Aws.SecretAccessKey= "";
Aws.ContainerName = "nxp-staging-1";
});
});
});
}
}
and create the intance of NxPApiModule in program.cs file as below.
using (var application = AbpApplicationFactory.Create<ChurchAipModule>(options =>
{
options.UseAutofac();
}))
This is my NxPBlobStoringAwsModule
[DependsOn(typeof(AbpBlobStoringModule),
typeof(AbpCachingModule),
typeof(AbpAutofacModule))]
public class NxPBlobStoringAwsModule : AbpModule
{
}
When I run the project, I am getting below exception on application build.
1[Church.Api.DocumentBlobContainer]': Unable to resolve service for type 'Volo.Abp.BlobStoring.IBlobContainerFactory' while attempting to activate 'Volo.Abp.BlobStoring.BlobContainer1[Church.Api.DocumentBlobContainer]'.) (Error while validating the service descriptor 'ServiceType: Church.Api.Services.IShipmentAppService Lifetime: Transient ImplementationType: Church.Api.Services.ShipmentAppService':Its still not working. I have checked in host project as well as in application project.
I have created the class but do I need to register this class in configuration? How it will overwrite the existing class? I am using abp azure module nuget package so Do I need to use the source code instead of package.
I am using the azure blob storage module and when I upload image on blob, it creates the host name folder on the blob container. I don't want to create the host folder and want to use my path without the host folder. I set multi tenancy false but still it is pointing to host folder.
Here is my configuration in module
var configuration = context.Services.GetConfiguration();
Configure<AbpBlobStoringOptions>(options =>
{
options.Containers.Configure<CategoryBlobContainer>(container =>
{
container.IsMultiTenant = false;
container.UseAzure(azure =>
{
azure.ConnectionString = configuration["BlobStoring:Containers:AzureContainer:Configuration:ConnectionString"];
azure.ContainerName = configuration["BlobStoring:Containers:AzureContainer:Configuration:ContainerName"];
azure.CreateContainerIfNotExists = true;
});
});
});