Starts in:
1 DAY
12 HRS
51 MIN
20 SEC
Starts in:
1 D
12 H
51 M
20 S

Activities of "fordz"

  • ABP Framework version: v7.2.2 Commercial
  • UI Type: N/A
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes

To recap... the initial issue we are trying to solve is: See ticket #6452 for background and details of issue.

"We're using the microservice template and using the auth-server app for authentication. The auth-server application has been slightly modified for custom branding. We have a .net API to get a token using the IdentityModel.Client.

When I call the API using Postman that's pointing to the auth-server running on localhost via Tye I'm able to successfully get a token. When I call the API pointing to the auth-server running in Azure Kubernetes I get an invalid username and password error.

The code is the exact same. The database is the same and the credentials are the exact same."

Based on feedback of things to try as suggested in responses to #6452:

Can you try to remove the HostTenantResolveContributer? You can override the HandlePasswordAsync method of TokenController. Output a log to show the current tenant. var tenant = await TenantConfigurationProvider.GetAsync(saveResolveResult: false); https://github.com/abpframework/abp/blob/dev/modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/TokenController.Password.cs#L78***

I'm getting a duplicate route error and am not quite sure how to get around it to override the HandlePasswordAysnc method of TokenController' as suggested to inspect the Tenant.Name. I cannot change the route of 'connect/token' as it is set by OAuth.

  • Exception message and full stack trace:

Here is the returned error.

[12:06:20 ERR] An unhandled exception has occurred while executing the request. Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches: CprOnAbp.AuthServer.MyTokenController.HandleAsync (CprOnAbp.AuthServer) Volo.Abp.OpenIddict.Controllers.TokenController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore) at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ReportAmbiguity(CandidateState[] candidateState) at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ProcessFinalCandidates(HttpContext httpContext, CandidateState[] candidateState) at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.MatchAsync(HttpContext httpContext) at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<&lt;UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<&lt;UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<&lt;UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context) [12:06:20 INF] Request finished HTTP/1.1 POST https://localhost:44322/connect/token application/x-[[[[www-form-urlencoded 387](http://www-form-urlencoded](http://www-form-urlencoded](http://www-form-urlencoded](http://www-form-urlencoded 387](http://www-form-urlencoded](http://www-form-urlencoded](http://www-form-urlencoded) 387](http://www-form-urlencoded](http://www-form-urlencoded](http://www-form-urlencoded)) 387](http://www-form-urlencoded) 387) - 500 - text/plain;+charset=utf-8 251.5204ms

  • Steps to reproduce the issue:

Created a TokenController inherited from Volo.Abp.OpenIddict.Controllers.TokenController to override HandlePasswordAsync. Here is the code.

MyTokenController in AuthServer

using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using OpenIddict.Abstractions; using Volo.Abp.OpenIddict.Controllers; using Volo.Abp.OpenIddict.ExtensionGrantTypes;

namespace CprOnAbp.AuthServer;

[Route("connect/token")] [IgnoreAntiforgeryToken] public class MyTokenController : TokenController {

public MyTokenController()
{
}

[HttpGet, HttpPost, Produces("application/json")]
public override async Task&lt;IActionResult&gt; HandleAsync()
{
    var request = await GetOpenIddictServerRequestAsync(HttpContext);

    if (request.IsPasswordGrantType())
    {
        return await HandlePasswordAsync(request); // Call the overridden HandlePasswordAsync method
    }

    // Add other grant type handling here as needed

    return await base.HandleAsync();
}

// Override the HandlePasswordAsync method
protected override async Task&lt;IActionResult&gt; HandlePasswordAsync(OpenIddictRequest request)
{
    // Your custom implementation goes here
    var tenant = await TenantConfigurationProvider.GetAsync(saveResolveResult: false);
    Console.WriteLine($"Tenant Name: {tenant.Name}");

    // Call the base implementation if needed
    return await base.HandlePasswordAsync(request);
}

}

I've shared our 2 projects that are needed to recreate this issue with Maliming. Auth-Server and oauth-api

Any ideas? Thanks.

Answer

hi,

So I was able to get to your suggestions in ticket #6452 and ran into an issue with overriding the connect/token endpoint of the TokenController to output a log to show the tenant.

To recap... the initial issue we are trying to solve is: "We're using the microservice template and using the auth-server app for authentication. The auth-server application has been slightly modified for custom branding. We have a .net API to get a token using the IdentityModel.Client. When I call the API using Postman that's pointing to the auth-server running on localhost via Tye I'm able to successfully get a token. When I call the API pointing to the auth-server running in Azure Kubernetes I get an invalid username and password error. The code is the exact same. The database is the same and the credentials are the exact same."

I'm getting a duplicate route error and am not quite sure how to get around it 'to override the HandlePasswordAysnc method of TokenController' as suggested to inspect the Tenant.Name. I cannot change the route of 'connect/token' as it is set by OAuth.

MyTokenController in AuthServer

using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using OpenIddict.Abstractions; using Volo.Abp.OpenIddict.Controllers; using Volo.Abp.OpenIddict.ExtensionGrantTypes;

namespace CprOnAbp.AuthServer{ [Route("connect/token")] [IgnoreAntiforgeryToken] public class MyTokenController : TokenController {

    public MyTokenController()
    {
    }

    [HttpGet, HttpPost, Produces("application/json")]
    public override async Task<IActionResult> HandleAsync()
    {
        var request = await GetOpenIddictServerRequestAsync(HttpContext);

        if (request.IsPasswordGrantType())
        {
            var tenant = await TenantConfigurationProvider.GetAsync(saveResolveResult: false);
            Console.WriteLine($"Tenant Name: {tenant.Name}");

            // Call the base implementation if needed
            return await base.HandlePasswordAsync(request);
            //return await HandlePasswordAsync(request); // Call the overridden HandlePasswordAsync method
        }

        // Add other grant type handling here as needed

        return await base.HandleAsync();
    }

    // Override the HandlePasswordAsync method
    //protected override async Task<IActionResult> HandlePasswordAsync(OpenIddictRequest request)
    //{
    //    // Your custom implementation goes here
    //    var tenant = await TenantConfigurationProvider.GetAsync(saveResolveResult: false);
    //    Console.WriteLine($"Tenant Name: {tenant.Name}");

    //    // Call the base implementation if needed
    //    return await base.HandlePasswordAsync(request);
    //}
}

}

Here is the returned error.

[12:06:20 ERR] An unhandled exception has occurred while executing the request. Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches: CprOnAbp.AuthServer.MyTokenController.HandleAsync (CprOnAbp.AuthServer) Volo.Abp.OpenIddict.Controllers.TokenController.HandleAsync (Volo.Abp.OpenIddict.AspNetCore) at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ReportAmbiguity(CandidateState[] candidateState) at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ProcessFinalCandidates(HttpContext httpContext, CandidateState[] candidateState) at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.MatchAsync(HttpContext httpContext) at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<&lt;UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<&lt;UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<&lt;UseMiddlewareInterface>b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context) [12:06:20 INF] Request finished HTTP/1.1 POST https://localhost:44322/connect/token application/x-[[[[www-form-urlencoded 387](http://www-form-urlencoded](http://www-form-urlencoded](http://www-form-urlencoded](http://www-form-urlencoded 387](http://www-form-urlencoded](http://www-form-urlencoded](http://www-form-urlencoded) 387](http://www-form-urlencoded](http://www-form-urlencoded](http://www-form-urlencoded)) 387](http://www-form-urlencoded) 387) - 500 - text/plain;+charset=utf-8 251.5204ms

I've shared our 2 projects that are needed to recreate this issue with Maliming. Auth-Server and oauth-api

Thanks for your help.

Thanks for the direction on this issue.

Thanks for this.

Have a follow-on question. Can I use dynamic proxy with the microservice solution or do I need to create a static proxy for the setting management update?

currently, I using the following for the dynamic proxy and am getting the following error:

abpQa5738Demo.administrationService.settingsManagement.setting.update(form).then(function (result) { $(document).trigger("AbpSettingSaved"); });

How do I find the dynamic proxy method to call? I've looked at the AdministrationService Get endpoint - /api/abp/api-definition for the method and found ---- abpQa5738Demo.administrationService.settingsManagement.setting.update

Thanks for your help.

Apologies.. Have made the repo private and added @maliming as collaborator.

here is a microservices test project that will reproduce the error on the 'save' of the 'More Settings' group menu. *** REMOVED ***

hi

How can I reproduce this? Can you share a minimal project? liming.ma@volosoft.com

Thanks for the quick response. Give me some time to create a sample microservice solution with this issue.

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, and please first use the search on the homepage. Provide us with the following info:

  • ABP Framework version: v7.2.2
  • UI Type: MVC
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (microservices): yes/yes
  • Exception message and full stack trace: > Volo.Abp.SettingManagement.Web.dll!AspNetCoreGeneratedDocument.Pages_SettingManagement_Index.ExecuteAsync.AnonymousMethod__12_5() Line 148 C# Microsoft.AspNetCore.Razor.Runtime.dll!Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync() Unknown Volo.Abp.SettingManagement.Web.dll!AspNetCoreGeneratedDocument.Pages_SettingManagement_Index.ExecuteAsync.AnonymousMethod__12_1() Line 174 C# Microsoft.AspNetCore.Razor.Runtime.dll!Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync() Unknown Volo.Abp.SettingManagement.Web.dll!AspNetCoreGeneratedDocument.Pages_SettingManagement_Index.ExecuteAsync() Line 181 C# Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(Microsoft.AspNetCore.Mvc.Razor.IRazorPage page, Microsoft.AspNetCore.Mvc.Rendering.ViewContext context) Unknown Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(Microsoft.AspNetCore.Mvc.Razor.IRazorPage page, Microsoft.AspNetCore.Mvc.Rendering.ViewContext context, bool invokeViewStarts) Unknown Microsoft.AspNetCore.Mvc.Razor.dll!Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(Microsoft.AspNetCore.Mvc.Rendering.ViewContext context) Unknown Microsoft.AspNetCore.Mvc.ViewFeatures.dll!Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(Microsoft.AspNetCore.Mvc.Rendering.ViewContext viewContext, string contentType, int? statusCode) Unknown ...
  • Steps to reproduce the issue: I have successfully extended (added new settings group ) to a layered (Bookstore) app following the instructions here: https://docs.abp.io/en/abp/latest/Modules/Setting-Management and can update the new settings fields.
  • However, we have a microservice solution and I'm trying to apply the same to the .web project of the AdministrationService microservice. I can get the new menu group to show and when clicked it will load the new settings. The issue is when clicking the 'save' button to persist the changes I get an 'object null reference' in the /Page/SettingManagement/Index.cshtml. The Model.SettingPageCreationContext object is null.
  • Not sure why it is 'reloading' the Settings Page and not calling the form post in the component default.js file.

Here is the file structure for the AdministrationService.Web project and the Default.cshtml.

Default.js

The Web (backend admin) application has been setup with "[DependsOn(... typeof(AdministrationServiceWebModule), typeof(AdministrationServiceHttpApiClientModule), ...)]" --- this is from the microservices template (default behavior).

Can I get some direction on how to proceed to solve this issue (what code I am missing). I cannot find any microservice example that extends the Settings Management module. I did find most of the patterns in the https://github.com/abpframework/abp/tree/dev/modules/setting-management/src/Volo.Abp.SettingManagement.Web project.

Thanks in advance.

Showing 11 to 18 of 18 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06