Activities of "inavarro.cp"

Perfect, it's already working for me. Thanks

  • ABP Framework version:
  • UI Type: MVC
  • Database System: EF Core (PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): Tiered
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I am using ABP Studio version 0.9.22. I want to create a project with ABP version 8.4.3 but when I create it from ABP Studio it shows version 9.0.x. Is there a way to choose the ABP version from ABP Studio? I have also tried from the CLI with this command abp new Acme.BookStore -dbms PostgreSQL -m none --theme leptonx -csf --version 8.3.4, it also creates the project with ABP version 9.0.x.

Answer

I have already been able to solve it. Here I have the certificate.

In the environment variables I have added the thumbprint of my certificate

This is the new code I added

public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        var hostingEnvironment = context.Services.GetHostingEnvironment();
        var configuration = context.Services.GetConfiguration();

        PreConfigure<OpenIddictBuilder>(builder =>
        {
            builder.AddValidation(options =>
            {
                options.AddAudiences("WebApp");
                options.UseLocalServer();
                options.UseAspNetCore();
            });
        });

        if (!hostingEnvironment.IsDevelopment())
        {
            PreConfigure<AbpOpenIddictAspNetCoreOptions>(options =>
            {
                options.AddDevelopmentEncryptionAndSigningCertificate = false;
            });

            PreConfigure<OpenIddictServerBuilder>(serverBuilder =>
            {
                // Obtén el thumbprint del certificado desde la variable de entorno
                var certificateThumbprint = Environment.GetEnvironmentVariable("WEBSITE_LOAD_CERTIFICATES");

                if (!string.IsNullOrWhiteSpace(certificateThumbprint))
                {
                    // Obtén el certificado directamente desde Azure App Service
                    var certificate = GetCertificateFromAzure(certificateThumbprint);

                    if (certificate == null)
                    {
                        throw new InvalidOperationException($"No se pudo encontrar el certificado con thumbprint '{certificateThumbprint}' en Azure App Service.");
                    }

                    serverBuilder.AddEncryptionCertificate(certificate);
                    serverBuilder.AddSigningCertificate(certificate);
                }
                else
                {
                    throw new InvalidOperationException("La variable de entorno 'WEBSITE_LOAD_CERTIFICATES' no está configurada o está vacía.");
                }

                // Establece el issuer a partir de la configuración
                serverBuilder.SetIssuer(new Uri(configuration["AuthServer:Authority"]!));
            });
        }
    }

    private X509Certificate2? GetCertificateFromAzure(string thumbprint)
    {
        try
        {
            var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
            store.Open(OpenFlags.ReadOnly);

            var certificate = store.Certificates
                .Find(X509FindType.FindByThumbprint, thumbprint, validOnly: false)
                .OfType<X509Certificate2>()
                .FirstOrDefault();

            store.Close();

            return certificate;
        }
        catch (Exception ex)
        {
            throw new InvalidOperationException("Error al cargar el certificado desde Azure App Service.", ex);
        }
    }
Answer

In my environment variable WEBSITE_LOAD_CERTIFICATES I store the Thumbprint of the certificate.

Question
  • ABP Framework version: v6.0.1
  • UI Type: MVC
  • Database System: EF Core (PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): Tiered
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I already have a certificate in Azure and I would like to use it for OpenIddict. In my App Service in Azure where I have my application deployed, in Identity in the environment variables I already have WEBSITE_LOAD_CERTIFICATES configured. Now I would need to modify the code to be able to use that certificate. I am giving you the code that I currently have.

public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        var hostingEnvironment = context.Services.GetHostingEnvironment();
        var configuration = context.Services.GetConfiguration();

        PreConfigure<OpenIddictBuilder>(builder =>
        {
            builder.AddValidation(options =>
            {
                options.AddAudiences("WebApp");
                options.UseLocalServer();
                options.UseAspNetCore();
            });
        });
        /*
        * This configuration is used when the AuthServer is running on docker containers at localhost.
        * Configuring the redirectin URLs for internal network and the web
        */
        if (!hostingEnvironment.IsDevelopment())
        {
            PreConfigure<AbpOpenIddictAspNetCoreOptions>(options =>
            {
                options.AddDevelopmentEncryptionAndSigningCertificate = false;
            });
            
            PreConfigure<OpenIddictServerBuilder>(serverBuilder =>
            {
                serverBuilder.AddProductionEncryptionAndSigningCertificate("openiddict.pfx", "00000000-0000-0000-0000-000000000000");
                serverBuilder.SetIssuer(new Uri(configuration["AuthServer:Authority"]!));
            });
        }
    }
Answer

What we really want to do is ensure that a user cannot be deleted if they have created reports, since we would lose the traceability of who made said report. What do you propose to do?

Answer

If I need the CreatorId property to be mandatory, what would you recommend I do?

Question
  • ABP Framework version: v6.0.1
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Auth Server Separated (Angular): Tired
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

Hi, I have a class that inherits from the "FullAuditedAggregateRoot<Guid>" class. This inherited class already provides me with the "CreatorId" field, but it is of type Guid? I would like this field to be mandatory, how could I do it?

Question

I would like to know how to capture the exceptions I receive from the backend and display them on the frontend. I have a modal where in the OnGet() method I receive the data, in the case that there is a problem with the data from the backend I will have received a UserFriendlyException() exception.

For example:

This is my OnGet() method inside the modal

public async Task OnGet()
    {
        var data = await _feedOrderLinesAppService.GetListFeedOrderLinesFromDeliveryAsync(Id);
        if (data != null)
        {
            FeedOrderLineBasicInfoDtoViewModel = ObjectMapper.Map<List<FeedOrderLineBasicInfoDto>, List<FeedOrderLineBasicInfoDtoViewModel>>(data);
        }
    }

Let's review the method GetListFeedOrderLinesFromDeliveryAsync(Id)

public async Task<List<FeedOrderLineBasicInfoDto>> GetListFeedOrderLinesFromDeliveryAsync(string feedDeliveryId)
    {
        var feedOrderLines = await _feedOrderManager.GetListFeedOrderLinesFromDeliveryAsync(feedDeliveryId);
        return ObjectMapper.Map<List<FeedOrderLineWithNavigationProperties>, List<FeedOrderLineBasicInfoDto>>(feedOrderLines);
    }

Let's review the method GetListFeedOrderLinesFromDeliveryAsync(feedDeliveryId), This method must first obtain the header ID, and then obtain the lines, but in the case that the header does not exist, it throws an exception.

public async Task<List<FeedOrderLineWithNavigationProperties>> GetListFeedOrderLinesFromDeliveryAsync(string feedOrderHeaderErpId)
        {
            var feedOrderHeader = await _feedOrderHeaderRepository.FirstOrDefaultAsync(x => x.ErpId == feedOrderHeaderErpId);
    
            if (feedOrderHeader == null)
            {
                throw new UserFriendlyException("Feed order header not found");
            }
    
            return await _feedOrderLineRepository.GetListWithNavigationPropertiesAsync(feedOrderHeaderId: feedOrderHeader.Id);
        }
  • ABP Framework version: v6.0.1
  • UI Type: MVC
  • Database System: EF Core ( PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): Tiered
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

These are the logs generated by the Identity:

Volo.Abp.AbpInitializationException: An error occurred during ConfigureServicesAsync phase of the module Volo.Abp.OpenIddict.AbpOpenIddictAspNetCoreModule, Volo.Abp.OpenIddict.AspNetCore, Version=6.0.1.0, Culture=neutral, PublicKeyToken=null. See the inner exception for details.
 ---> System.IO.FileNotFoundException: Signing Certificate couldn't found: openiddict.pfx
   at Microsoft.Extensions.DependencyInjection.OpenIddictServerBuilderExtensions.AddProductionEncryptionAndSigningCertificate(OpenIddictServerBuilder builder, String fileName, String passPhrase) in /home/runner/work/Cincaporc.WebApp/Cincaporc.WebApp/src/Cincaporc.WebApp.AuthServer/OpenIddictServerBuilderExtensions.cs:line 13
   at Cincaporc.WebApp.WebAppAuthServerModule.<>c__DisplayClass0_0.<PreConfigureServices>b__2(OpenIddictServerBuilder serverBuilder) in /home/runner/work/Cincaporc.WebApp/Cincaporc.WebApp/src/Cincaporc.WebApp.AuthServer/WebAppAuthServerModule.cs:line 96
   at Volo.Abp.Options.PreConfigureActionList`1.Configure(TOptions options)
   at Microsoft.Extensions.DependencyInjection.ServiceCollectionPreConfigureExtensions.ExecutePreConfiguredActions[TOptions](IServiceCollection services, TOptions options)
   at Volo.Abp.OpenIddict.AbpOpenIddictAspNetCoreModule.&lt;&gt;c__DisplayClass1_0.&lt;AddOpenIddictServer&gt;b__0(OpenIddictServerBuilder builder)
   at Microsoft.Extensions.DependencyInjection.OpenIddictServerExtensions.AddServer(OpenIddictBuilder builder, Action`1 configuration)
   at Volo.Abp.OpenIddict.AbpOpenIddictAspNetCoreModule.AddOpenIddictServer(IServiceCollection services)
   at Volo.Abp.OpenIddict.AbpOpenIddictAspNetCoreModule.ConfigureServices(ServiceConfigurationContext context)
   at Volo.Abp.Modularity.AbpModule.ConfigureServicesAsync(ServiceConfigurationContext context)
   at Volo.Abp.AbpApplicationBase.ConfigureServicesAsync()

These are the logs generated by the GitHubActions:

Run dotnet dev-certs https -v -ep /home/runner/.dotnet/Cincaporc.WebApp.AuthServer/openiddict.pfx -p 00000000-0000-0000-0000-000000000000
  
[1] Listing certificates from CurrentUser\My
[2] Found certificates: 1 certificate
    1) 85401136598E5431084B7F11E2486FA96A65D658 - CN=localhost - Valid from 2024-08-09 10:24:49Z to 2025-08-09 10:24:49Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
[3] Checking certificates validity
[4] Valid certificates: 1 certificate
    1) 85401136598E5431084B7F11E2486FA96A65D658 - CN=localhost - Valid from 2024-08-09 10:24:49Z to 2025-08-09 10:24:49Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
[5] Invalid certificates: no certificates
[6] Finished listing certificates.
[1] Listing certificates from LocalMachine\My
[7] An error occurred while listing the certificates: System.Security.Cryptography.CryptographicException: Unix LocalMachine X509Store is limited to the Root and CertificateAuthority stores.
 ---> System.PlatformNotSupportedException: Unix LocalMachine X509Store is limited to the Root and CertificateAuthority stores.
   --- End of inner exception stack trace ---
   at Internal.Cryptography.Pal.StorePal.FromSystemStore(String storeName, StoreLocation storeLocation, OpenFlags openFlags)
   at System.Security.Cryptography.X509Certificates.X509Store.Open(OpenFlags flags)
   at Microsoft.AspNetCore.Certificates.Generation.CertificateManager.ListCertificates(StoreName storeName, StoreLocation location, Boolean isValid, Boolean requireExportable)
[8] Filtered certificates: 1 certificate
    1) 85401136598E5431084B7F11E2486FA96A65D658 - CN=localhost - Valid from 2024-08-09 10:24:49Z to 2025-08-09 10:24:49Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
[9] Excluded certificates: no certificates
[14] Valid certificates: 1 certificate
    1) 85401136598E5431084B7F11E2486FA96A65D658 - CN=localhost - Valid from 2024-08-09 10:24:49Z to 2025-08-09 10:24:49Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
[15] Selected certificate: 85401136598E5431084B7F11E2486FA96A65D658 - CN=localhost - Valid from 2024-08-09 10:24:49Z to 2025-08-09 10:24:49Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
[23] Saving certificate '85401136598E5431084B7F11E2486FA96A65D658 - CN=localhost - Valid from 2024-08-09 10:24:49Z to 2025-08-09 10:24:49Z - IsHttpsDevelopmentCertificate: true - IsExportable: true' to /home/runner/.dotnet/Cincaporc.WebApp.AuthServer/openiddict.pfx with private key.
[25] Creating directory /home/runner/.dotnet/Cincaporc.WebApp.AuthServer.
[27] Writing the certificate to: /home/runner/.dotnet/Cincaporc.WebApp.AuthServer/openiddict.pfx.
A valid HTTPS certificate is already present.
The certificate was exported to /home/runner/.dotnet/Cincaporc.WebApp.AuthServer/openiddict.pfx
Showing 1 to 10 of 22 entries
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on April 16, 2025, 12:13