Activités de "ed_developer3"

ok i have checked mapping its correct.

Also how to avoid this error by abp api "The data you have submitted has already changed by another user/client. Please discard the changes you've done and try from the beginning" Thanks

ya it worked thanks

hi Swagger response and controller code Actually on frontend 403 is being taken as forbidden access message and code we are using is causing 400 in response text and not response code its still 403. Where to inject DefaultHttpExceptionStatusCodeFinder inherited class to override the response code.

when we say Busnessexception or friendly exception it results into status code 403 which is wrong code as user has permissions but contact cannot be added due to validation so we wanted to show a message with different status code than 403

Its 403 which comes when user does not have permission

Répondre

Thanks for the links, we will try and implement please keep this open for next 3-4 days then if you don't hear from us you can close this ticket.

Any update on this we are awaiting this since long its hampering our development.

Error is gone as of now, we used last code copy which was deployed on UAT and modified APi.HostModule in API host project. but not sure what went wrong and how error is gone.

you can uncomment the commented code for background jobs to reproduce.

using System; using System.Collections.Generic; using System.IO; using System.Linq; using Microsoft.AspNetCore.Authentication.Google; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; using Microsoft.AspNetCore.Authentication.Twitter; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Cors; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.AspNetCore.Extensions.DependencyInjection; using OpenIddict.Validation.AspNetCore; using OpenIddict.Server.AspNetCore; using Wbi.EntityFrameworkCore; using Wbi.MultiTenancy; using Microsoft.OpenApi.Models; using Volo.Abp; using Volo.Abp.Account.Web; using Volo.Abp.Account.Public.Web; using Volo.Abp.Account.Public.Web.Impersonation; using Volo.Abp.AspNetCore.MultiTenancy; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Autofac; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.UI.Navigation.Urls; using Volo.Abp.VirtualFileSystem; using Volo.Abp.Account; using Volo.Abp.Account.Public.Web.ExternalProviders; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Microsoft.AspNetCore.Hosting; using Wbi.HealthChecks; using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonX; using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonX.Bundling; using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Identity; using Volo.Abp.LeptonX.Shared; using Volo.Abp.Swashbuckle; using Volo.Saas.Host; using Volo.Abp.OpenIddict; using Microsoft.IdentityModel.Tokens; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Http; using Volo.Abp.BlobStoring; using Volo.Abp.BlobStoring.FileSystem; using Serilog; using Volo.Abp.Auditing; using Volo.Abp.BlobStoring.Database; using Volo.FileManagement; using ProjectModule; using Volo.Abp.BackgroundJobs; using Microsoft.EntityFrameworkCore; using MasterModule.LookUps; using MasterModule.Provinces; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.BackgroundWorkers; using Wbi.Services.BackGroundJobs;

namespace Wbi;

[DependsOn( typeof(WbiHttpApiModule), typeof(AbpAutofacModule), typeof(AbpAspNetCoreMultiTenancyModule), typeof(WbiApplicationModule), typeof(WbiEntityFrameworkCoreModule), typeof(AbpAspNetCoreMvcUiLeptonXThemeModule), typeof(AbpAccountPublicWebImpersonationModule), typeof(AbpAccountPublicWebOpenIddictModule), typeof(AbpSwashbuckleModule), typeof(AbpAspNetCoreSerilogModule), typeof(AbpBlobStoringFileSystemModule) )] public class WbiHttpApiHostModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) {

#if RELEASE //test commit. //these are new changes made to deploy this app to IIS, to get rid of development certificates. PreConfigure<AbpOpenIddictAspNetCoreOptions>(options => { options.AddDevelopmentEncryptionAndSigningCertificate = false; });

    //if we need to run this app on azure or load balancer, the signing keys wil not work, we may have to use x509 certificate
    PreConfigure&lt;OpenIddictServerBuilder&gt;(builder =>
    {
        // builder.AddEncryptionKey(new SymmetricSecurityKey
        //        (Convert.FromBase64String("DRjd/GnduI3Efzen9V9BvbNUfc/VKgXltV7Kbk9sMkY=")));
        //Set options here...		
        builder.AddEphemeralEncryptionKey()
          .AddEphemeralSigningKey();
    });

#endif
PreConfigure<OpenIddictBuilder>(builder => { builder.AddValidation(options => {

            options.AddAudiences("Wbi");
            options.UseLocalServer();
            options.UseAspNetCore();
        });
    });

    PreConfigure&lt;OpenIddictServerBuilder&gt;(builder =>
    {
        builder
            .SetAccessTokenLifetime(TimeSpan.FromHours(1))
            .SetIdentityTokenLifetime(TimeSpan.FromHours(1));
    });
}

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

    Configure&lt;AbpBlobStoringOptions&gt;(options =>
    {
        options.Containers.Configure&lt;DocumentContainer&gt;(container =>
        {
            container.UseFileSystem(fileSystem =>
            {
                fileSystem.BasePath = configuration["DocumentPaths:UploadDocuments"];
                //fileSystem.BasePath = "C:\\Blobdocs";
            });
        });
    });

    //Configure&lt;AbpBackgroundJobWorkerOptions&gt;(options =>
    //{
    //    options.DefaultTimeout = 864000; //10 days (as seconds)
    //});
    Configure&lt;AbpBackgroundJobOptions&gt;(options =>
    {
        options.IsJobExecutionEnabled = true; //Disables job execution
    });


    //Configure&lt;AbpBlobStoringOptions&gt;(options =>
    //    {
    //        options.Containers.Configure("account-profile-pictures", container =>
    //        {
    //            container.UseFileSystem(fileSystem =>
    //                    {
    //                        fileSystem.BasePath = configuration["DocumentPaths:UploadDocuments"];
    //                        //fileSystem.BasePath = "C:\\Blobdocs";
    //                    });
    //        });
    //    });

    //Configure&lt;AbpBlobStoringOptions&gt;(options =>
    //{
    //    options.Containers.Configure("documents", container =>
    //    {
    //        container.UseFileSystem(fileSystem =>
    //                {
    //                    fileSystem.BasePath = configuration["DocumentPaths:UploadDocuments"];
    //                    //fileSystem.BasePath = "C:\\Blobdocs";
    //                });
    //    });
    //});

    context.Services.ConfigureApplicationCookie(options =>
    {
        options.ExpireTimeSpan = TimeSpan.FromHours(1); // Set the expiration time to 5 minutes
        options.SlidingExpiration = false;
    });

    Configure&lt;AbpAuditingOptions&gt;(options =>
    {
        options.EntityHistorySelectors.AddAllEntities();
    });
    if (!Convert.ToBoolean(configuration["App:DisablePII"]))
    {
        Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
    }

    if (!Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]))
    {
        Configure&lt;OpenIddictServerAspNetCoreOptions&gt;(options =>
        {
            options.DisableTransportSecurityRequirement = true;
        });
    }

    if (!Convert.ToBoolean(configuration["App:DisablePII"]))
    {
        Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
    }

    if (!Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]))
    {
        Configure&lt;OpenIddictServerAspNetCoreOptions&gt;(options =>
        {
            options.DisableTransportSecurityRequirement = true;
        });
    }

    ConfigureAuthentication(context);
    ConfigureUrls(configuration);
    ConfigureBundles();
    ConfigureConventionalControllers();
    ConfigureImpersonation(context, configuration);
    ConfigureSwagger(context, configuration);
    ConfigureVirtualFileSystem(context);
    ConfigureCors(context, configuration);
    ConfigureExternalProviders(context);
    ConfigureHealthChecks(context);
    ConfigureTheme();

}

private void ConfigureTheme()
{
    Configure&lt;LeptonXThemeOptions&gt;(options =>
    {
        options.DefaultStyle = LeptonXStyleNames.System;
    });
}

private void ConfigureAuthentication(ServiceConfigurationContext context)
{
    context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
}

private void ConfigureHealthChecks(ServiceConfigurationContext context)
{
    context.Services.AddWbiHealthChecks();
}

private void ConfigureUrls(IConfiguration configuration)
{
    Configure&lt;AppUrlOptions&gt;(options =>
    {
        options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
        options.Applications["Angular"].RootUrl = configuration["App:AngularUrl"];
        options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password";
        options.Applications["Angular"].Urls[AccountUrlNames.EmailConfirmation] = "account/email-confirmation";
        options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(','));
    });
}

private void ConfigureBundles()
{
    Configure&lt;AbpBundlingOptions&gt;(options =>
    {
        options.StyleBundles.Configure(
            LeptonXThemeBundles.Styles.Global,
            bundle =>
            {
                bundle.AddFiles("/global-styles.css");
            }
        );
    });
}


private void ConfigureVirtualFileSystem(ServiceConfigurationContext context)
{
    var hostingEnvironment = context.Services.GetHostingEnvironment();

    if (hostingEnvironment.IsDevelopment())
    {
        Configure&lt;AbpVirtualFileSystemOptions&gt;(options =>
        {
            options.FileSets.ReplaceEmbeddedByPhysical&lt;WbiDomainSharedModule&gt;(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}Wbi.Domain.Shared"));
            options.FileSets.ReplaceEmbeddedByPhysical&lt;WbiDomainModule&gt;(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}Wbi.Domain"));
            options.FileSets.ReplaceEmbeddedByPhysical&lt;WbiApplicationContractsModule&gt;(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}Wbi.Application.Contracts"));
            options.FileSets.ReplaceEmbeddedByPhysical&lt;WbiApplicationModule&gt;(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}Wbi.Application"));
        });
    }
}

private void ConfigureConventionalControllers()
{
    Configure&lt;AbpAspNetCoreMvcOptions&gt;(options =>
    {
        options.ConventionalControllers.Create(typeof(WbiApplicationModule).Assembly);
    });
}

private static void ConfigureSwagger(ServiceConfigurationContext context, IConfiguration configuration)
{
    context.Services.AddAbpSwaggerGenWithOAuth(
        configuration["AuthServer:Authority"],
        new Dictionary&lt;string, string&gt;
        {
                {"Wbi", "Wbi API"}
        },
        options =>
        {
            options.SwaggerDoc("v1", new OpenApiInfo { Title = "Wbi API", Version = "v1" });
            options.DocInclusionPredicate((docName, description) => true);
            options.CustomSchemaIds(type => type.FullName);
        });
}

private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
{
    context.Services.AddCors(options =>
    {
        options.AddDefaultPolicy(builder =>
        {
            builder
                .WithOrigins(
                    configuration["App:CorsOrigins"]
                        .Split(",", StringSplitOptions.RemoveEmptyEntries)
                        .Select(o => o.Trim().RemovePostFix("/"))
                        .ToArray()
                )
                .WithAbpExposedHeaders()
                .SetIsOriginAllowedToAllowWildcardSubdomains()
                .AllowAnyHeader()
                .AllowAnyMethod()
                .AllowCredentials();
        });
    });
}

private void ConfigureExternalProviders(ServiceConfigurationContext context)
{
    context.Services.AddAuthentication()
        .AddGoogle(GoogleDefaults.AuthenticationScheme, _ => { })
        .WithDynamicOptions&lt;GoogleOptions, GoogleHandler&gt;(
            GoogleDefaults.AuthenticationScheme,
            options =>
            {
                options.WithProperty(x => x.ClientId);
                options.WithProperty(x => x.ClientSecret, isSecret: true);
            }
        ).AddCookie(options =>
        {
            // add an instance of the patched manager to the options:
            options.CookieManager = new ChunkingCookieManager();
            options.Cookie.HttpOnly = true;
            options.Cookie.SameSite = SameSiteMode.None;
            options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
        })
        .AddMicrosoftAccount(MicrosoftAccountDefaults.AuthenticationScheme, options =>
        {
            //Personal Microsoft accounts as an example.
            options.AuthorizationEndpoint = "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize";
            options.TokenEndpoint = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token";
        })
        .WithDynamicOptions&lt;MicrosoftAccountOptions, MicrosoftAccountHandler&gt;(
            MicrosoftAccountDefaults.AuthenticationScheme,
            options =>
            {
                options.WithProperty(x => x.ClientId);
                options.WithProperty(x => x.ClientSecret, isSecret: true);
            }
        )
        .AddTwitter(TwitterDefaults.AuthenticationScheme, options => options.RetrieveUserDetails = true)
        .WithDynamicOptions&lt;TwitterOptions, TwitterHandler&gt;(
            TwitterDefaults.AuthenticationScheme,
            options =>
            {
                options.WithProperty(x => x.ConsumerKey);
                options.WithProperty(x => x.ConsumerSecret, isSecret: true);
            }
        );
}

private void ConfigureImpersonation(ServiceConfigurationContext context, IConfiguration configuration)
{
    context.Services.Configure&lt;AbpAccountOptions&gt;(options =>
    {
        options.TenantAdminUserName = "admin";
        options.ImpersonationTenantPermission = SaasHostPermissions.Tenants.Impersonation;
        options.ImpersonationUserPermission = IdentityPermissions.Users.Impersonation;
    });
}

public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
    var app = context.GetApplicationBuilder();
    var env = context.GetEnvironment();
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    //below cofigures auto trigger to background job
    //context.ServiceProvider
    //.GetRequiredService&lt;IBackgroundWorkerManager&gt;()
    //.AddAsync(
    // context
    //     .ServiceProvider
    //     .GetRequiredService&lt;SecurityRequirement_Job&gt;()
    //);
    // end of job
    app.UseAbpRequestLocalization();

    if (!env.IsDevelopment())
    {
        app.UseErrorPage();
    }

    app.UseAbpSecurityHeaders();
    app.UseStaticFiles();
    app.UseRouting();
    app.UseCors();
    app.UseAuthentication();
    app.UseAbpOpenIddictValidation();

    if (MultiTenancyConsts.IsEnabled)
    {
        app.UseMultiTenancy();
    }

    app.UseUnitOfWork();

    app.UseAuthorization();
    app.UseSwagger();
    app.UseAbpSwaggerUI(options =>
    {
        options.SwaggerEndpoint("/swagger/v1/swagger.json", "Wbi API");

        var configuration = context.ServiceProvider.GetRequiredService&lt;IConfiguration&gt;();
        options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
    });
    app.UseAuditing();
    app.UseAbpSerilogEnrichers();
    app.UseConfiguredEndpoints();
}

}

can you please share documentation link,meanwhile i provide you the error message in angular app we are encountering

Thanks

Affichage de 1 à 10 sur 46 entrées
Made with ❤️ on ABP v8.2.0-preview Updated on mars 25, 2024, 15:11