It's hard to understand the problem right no with this information. More detailed logs or debugging might be required. You're encountering a complex issue involving authorization failures, database connection problems, and potential caching issues within your application. Let's break down the problem and outline a systematic approach to debugging and resolving it.
PermissionRequirement: Project.Project.EditPermissionRequirement: Project.Project.ScheduleEditapi/abp/application-configuration which is normally available to all users is very strange.An error occurred using the connection to database 'sqldb-myapp' on server 'sql-myserver.database.windows.net'.System.Threading.Tasks.TaskCanceledException: A task was canceled.System.OperationCanceledException: The operation was canceled.at Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.GetAsync(String key, CancellationToken token)Code Example (Overriding GetAuthConfigAsync)
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations;
using Volo.Abp.DependencyInjection;
using Microsoft.AspNetCore.Http;
using System.Linq;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Authorization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Users;
using Volo.Abp.Settings;
using Volo.Abp.Features;
using Volo.Abp.Timing;
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending;
namespace YourProject.Controllers
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IAbpApplicationConfigurationAppService), typeof(AbpApplicationConfigurationAppService))]
public class CustomAbpApplicationConfigurationAppService : AbpApplicationConfigurationAppService
{
private readonly ILogger<CustomAbpApplicationConfigurationAppService> _logger;
private readonly IHttpContextAccessor _httpContextAccessor;
public CustomAbpApplicationConfigurationAppService(IOptions<AbpLocalizationOptions> localizationOptions,
IOptions<AbpMultiTenancyOptions> multiTenancyOptions,
IServiceProvider serviceProvider,
IAbpAuthorizationPolicyProvider abpAuthorizationPolicyProvider,
IPermissionDefinitionManager permissionDefinitionManager,
DefaultAuthorizationPolicyProvider defaultAuthorizationPolicyProvider,
IPermissionChecker permissionChecker,
IAuthorizationService authorizationService,
ICurrentUser currentUser,
ISettingProvider settingProvider,
ISettingDefinitionManager settingDefinitionManager,
IFeatureDefinitionManager featureDefinitionManager,
ILanguageProvider languageProvider,
ITimezoneProvider timezoneProvider,
IOptions<AbpClockOptions> abpClockOptions,
ICachedObjectExtensionsDtoService cachedObjectExtensionsDtoService,
IOptions<AbpApplicationConfigurationOptions> options,
ILogger<CustomAbpApplicationConfigurationAppService> logger,
IHttpContextAccessor httpContextAccessor) : base(localizationOptions, multiTenancyOptions, serviceProvider, abpAuthorizationPolicyProvider, permissionDefinitionManager, defaultAuthorizationPolicyProvider, permissionChecker, authorizationService, currentUser, settingProvider, settingDefinitionManager, featureDefinitionManager, languageProvider, timezoneProvider, abpClockOptions, cachedObjectExtensionsDtoService, options)
{
_logger = logger;
_httpContextAccessor = httpContextAccessor;
}
protected override async Task<ApplicationAuthConfigurationDto> GetAuthConfigAsync()
{
_logger.LogInformation("Custom GetAuthConfigAsync called.");
var httpContext = _httpContextAccessor.HttpContext;
if (httpContext?.User?.Claims != null)
{
_logger.LogInformation("User Claims:");
foreach (var claim in httpContext.User.Claims)
{
_logger.LogInformation($"Claim Type: {claim.Type}, Value: {claim.Value}");
}
}
if(httpContext != null){
_logger.LogInformation("User authenticated: " + httpContext.User.Identity.IsAuthenticated);
}
var authConfig = await base.GetAuthConfigAsync();
return authConfig;
}
}
}
Due to the inherent nature of the Inbox/Outbox pattern, all events are processed by a background job. When you separate your tenant's databases, that background job will not check the tenant's segregated database. To address this issue, there are two options available:
Extend/Customize the background worker to ensure it checks both databases and handles the events accordingly.
Operate two separate application instances, each working with a different database.
Hence, Point 1 (Defining a single database per tenant) is feasible with monolithic applications that do not utilize the Inbox/Outbox pattern in conjunction with BackgroundJobs.RabbitMQ.
However, Point 2 (Defining a separate database per tenant and microservice) is not achievable without intervention as outlined above. Whenever the Inbox/Outbox pattern with transaction is employed, it will not function properly with disparate databases.
See the following implementation for understanding better:
Also implementations of IInboxProcessor and IOutboxSender
Can you make sure if AbpAuthorizationService works on your gRPC request?
Hi,
ABP doesn't provide an authentication pipeline for gRPC by default, if you make the regular ASP.NET Core authentication mechanism, ABP policies can work together. In your case it seems ASP.NET Core can't execute its own properties.
Since gRPC requests does not have header like HTTP Requests by default, you may add and resolve them manually.
Hi,
I'll ask the LeptonX team and inform you about his issue soon
Can you try adding currentSchema parameter to your connection string?
https://jdbc.postgresql.org/documentation/use/#connection-parameters
I tried the same behaviour but unfortunately could not reproduce the problem. Are you sure the public schema has the tables?
Are they running on the same instance of application? Or you're using in a micro-service project?
how do we make it so that the default abp login does not appear?
You can't remove Microsoft.AspNetCore.Components.WebAssembly.Authentication package from your application because ABP modules are depending on it:
But you can remove configuration from Module class, you can find a method named ConfigureAuthentication. You can remove configuration from there and configure & register your own Oidc Client into service collection. Then you'll use your OidcClient in your own razor component/page
Hi,
Sorry for late-response, it seems you already found the problem.
Now, i need to send accessToken to the grpc endpoint because it's authorized.
ABP Framework does not implements it currently. gRPC requests are planned to be used for communication between micro-service that is not open to world and in an internal network.
But still it's an ASP.NET Core application, you can follow Microsoft's guide: https://learn.microsoft.com/en-us/aspnet/core/grpc/authn-and-authz?view=aspnetcore-9.0#authorize-users-to-access-services-and-service-methods
In the ABP Framework, Each PermissionName is a policy in the authorization logic of ASP.NET Core application, you can directly use your permissions in the [Authorize] attribute.