Ends in:
5 DAYS
18 HRS
4 MIN
1 SEC
Ends in:
5 D
18 H
4 M
1 S
Open Closed

Angular multitenancy #1853


User avatar
0
can.ercan created
  • ABP Framework version: v4.2.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

I am trying to implement multitenancy. My app.settings and angular environment variables are like below

{ "App": { "SelfUrl": "https://pbxticketapi.azurewebsites.net", "AngularUrl": "https://merlinvoip.com", "CorsOrigins": "https://merlinvoip.com,https://.merlinvoip.com,https://dva.merlinvoip.com,https://pbxticketclient.azurewebsites.net", "RedirectAllowedUrls": "https://merlinvoip.com,https://.merlinvoip.com,https://dva.merlinvoip.com,https://pbxticketclient.azurewebsites.net" }, "Redis": { "Configuration": "127.0.0.1" }, "ConnectionStrings": { "Default": ";" }, "AuthServer": { "Authority": "https://pbxticketapi.azurewebsites.net", "RequireHttpsMetadata": "false", "SwaggerClientId": "TestApp2_Swagger", "SwaggerClientSecret": "1q2w3e*" }, "StringEncryption": { "DefaultPassPhrase": "rL1OCmPHd9IOQZ7w" }, "Settings": { "Volo.Abp.LeptonTheme.Style": "Style6", "Volo.Abp.LeptonTheme.Layout.MenuPlacement": "Left", "Volo.Abp.LeptonTheme.Layout.MenuStatus": "AlwaysOpened", "Volo.Abp.LeptonTheme.Layout.Boxed": "False" } }

import { Environment } from '@abp/ng.core';

const baseUrl = 'https://{0}.merlinvoip.com';

export const environment = { production: true, application: { baseUrl, name: 'TestApp2', }, oAuthConfig: { issuer: 'https://pbxticketapi.azurewebsites.net', redirectUri: baseUrl, clientId: 'TestApp2_App', responseType: 'code', scope: 'offline_access TestApp2', requireHttps: false }, apis: { default: { url: 'https://pbxticketapi.azurewebsites.net', rootNamespace: 'TestApp2', }, }, } as Environment;

I put the code

Configure<AbpTenantResolveOptions>(options => { options.AddDomainTenantResolver("{0}.merlinvoip.com"); }); to HttpApiHostModule/ConfigureServices

When i try to login with a subdomain like https://dva.merlinvoip.com when cliecked to login i get 500 error code. When i looked at the logs i found error:

Invalid client configuration for client TestApp2_App: AllowedCorsOrigins contains invalid origin: https://*.merlinvoip.com

I tried changing the IdentityServerClientCorsOrigins table value to https://{0}.merlinvoip.com it didn't work either. Only way i can make it work is changing the value to https://merlinvoip.com and login as host admin but then i can't resolve tenant with subdomain that way. And i can't login with subdomain because i get redirect uri error when i click login that way.

I must be able to user both https://merlinvoip.com as an host admin and https://dva.merlinvoip.com as a tenant. I have a tenant created in the database as dva.

How should i set the values to IdentityServerClientCorsOrigins and IdentityServerClientRedirectUris tables in the database?

Thanks, Can Ercan


11 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    https://github.com/abpframework/abp-samples/tree/master/DomainTenantResolver https://github.com/abpframework/abp-samples/blob/master/DomainTenantResolver/NG/aspnet-core/src/BookStore.HttpApi.Host/BookStoreHttpApiHostModule.cs#L58-L64

  • User Avatar
    0
    can.ercan created

    Hi,

    I updated the HttpApiHostModule according to the sample app link you provided like below:

        context.Services.AddAbpStrictRedirectUriValidator();
        context.Services.AddAbpClientConfigurationValidator();
        context.Services.AddAbpWildcardSubdomainCorsPolicyService();
        Configure<AbpTenantResolveOptions>(options =>
        {       
            options.AddDomainTenantResolver("{0}.api.merlinvoip.com");
        });
    

    My appsettings.json file:

    {
    "App": {
      "SelfUrl": "https://api.merlinvoip.com",
      "CorsOrigins": "https://merlinvoip.com,https://*.merlinvoip.com"
    },
    "Redis": {
      "Configuration": "127.0.0.1"
    },
    "ConnectionStrings": {
      "Default": ""
    },
    "AuthServer": {
      "Authority": "https://api.merlinvoip.com",
      "RequireHttpsMetadata": "false",
      "SwaggerClientId": "TestApp2_Swagger",
      "SwaggerClientSecret": "1q2w3e*"
    },
    "StringEncryption": {
      "DefaultPassPhrase": "rL1OCmPHd9IOQZ7w"
    },
    "Settings": {
      "Volo.Abp.LeptonTheme.Style": "Style6",
      "Volo.Abp.LeptonTheme.Layout.MenuPlacement": "Left",
      "Volo.Abp.LeptonTheme.Layout.MenuStatus": "AlwaysOpened",
      "Volo.Abp.LeptonTheme.Layout.Boxed": "False"
    }
    }
    
    **DbMigrator appsettings.json:**
    {
    "ConnectionStrings": {
      "Default": ""
    },
    "IdentityServer": {
      "Clients": {
        "TestApp2_App": {
          "ClientId": "TestApp2_App",
          "ClientSecret": "1q2w3e*",
          "RootUrl": "https://{0}.merlinvoip.com"
        },
      
        "TestApp2_Swagger": {
          "ClientId": "TestApp2_Swagger",
          "RootUrl": "https://api.merlinvoip.com"
        }
      }
    }
    }
    **My angular client environment variables:** 
    
    const baseUrl = 'https://{0}.merlinvoip.com';
    export const environment = {
    production: true,
    application: {
      baseUrl,
      name: 'TestApp2',
    },
    oAuthConfig: {
      issuer: 'https://api.merlinvoip.com',
      redirectUri: baseUrl,
      clientId: 'TestApp2_App',
      responseType: 'code',
      scope: 'offline_access TestApp2',
      requireHttps: true
    },
    apis: {
      default: {
        url: 'https://api.merlinvoip.com',
        rootNamespace: 'TestApp2',
      },
    },
    } as Environment;
    

    In the database:

    IdentityServerClientCorsOrigins table:
    33764f2e-a4b3-ba64-06d1-39fef527bc9e	https://{0}.merlinvoip.com
    2f3968f2-6d8f-70fc-b233-39fef527bd61	   https://api.merlinvoip.com
    IdentityServerClientRedirectUris table:
    33764f2e-a4b3-ba64-06d1-39fef527bc9e	https://{0}.merlinvoip.com
    2f3968f2-6d8f-70fc-b233-39fef527bd61	   https://api.merlinvoip.com
    

    When i go to the url https://merlinvoip.com and click login i get 500 server error.

    The log shows :

    2021-09-20 11:02:05.450 +00:00 [INF] Request starting HTTP/1.1 GET https://api.merlinvoip.com/Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fresponse_type%3Dcode%26client_id%3DTestApp2_App%26state%3DV3AtQVRXLlFhYUtfLkdfdzFiRVQ2dzFqS3BKblpUMlV-TFNFc1p2d3YwTVcz%26redirect_uri%3Dhttps%253A%252F%252Fmerlinvoip.com%26scope%3Dopenid%2520offline_access%2520TestApp2%26code_challenge%3DzbaeuulWht0iscH43qvlt3Y0VRgkLQlcOwbnOH2wW9o%26code_challenge_method%3DS256%26nonce%3DV3AtQVRXLlFhYUtfLkdfdzFiRVQ2dzFqS3BKblpUMlV-TFNFc1p2d3YwTVcz%26culture%3Dtr%26ui-culture%3Dtr - -
    2021-09-20 11:02:05.615 +00:00 [INF] Executing endpoint '/Account/Login'
    2021-09-20 11:02:05.616 +00:00 [INF] Route matched with {page = "/Account/Login", action = "", controller = "", area = ""}. Executing page /Account/Login
    2021-09-20 11:02:05.616 +00:00 [INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy
    2021-09-20 11:02:05.627 +00:00 [INF] Executed page /Account/Login in 10.8974ms
    2021-09-20 11:02:05.627 +00:00 [INF] Executed endpoint '/Account/Login'
    2021-09-20 11:02:05.718 +00:00 [ERR] An unhandled exception has occurred while executing the request.
    Autofac.Core.DependencyResolutionException: An exception was thrown while activating Volo.Abp.Account.Web.Pages.Account.IdentityServerSupportedLoginModel -> Volo.Abp.Account.AccountAppService -> Volo.Abp.Account.Emailing.AccountEmailer -> Volo.Abp.UI.Navigation.Urls.AppUrlProvider.
     ---> Autofac.Core.DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.Extensions.Options.IOptions`1[Volo.Abp.UI.Navigation.Urls.AppUrlOptions], Volo.Abp.MultiTenancy.ICurrentTenant, Volo.Abp.MultiTenancy.ITenantStore)' on type 'AppUrlProvider'.
     ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at TestApp2.TestApp2HttpApiHostModule.&lt;&gt;c__DisplayClass2_0.&lt;ConfigureUrls&gt;b__0(AppUrlOptions options) in E:\abp\TestApp2\aspnet-core\src\TestApp2.HttpApi.Host\TestApp2HttpApiHostModule.cs:line 103
       at Microsoft.Extensions.Options.ConfigureNamedOptions`1.Configure(String name, TOptions options)
       at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
       at Microsoft.Extensions.Options.OptionsManager`1.<>c__DisplayClass5_0.<Get>b__0()
       at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
    --- End of stack trace from previous location ---
       at System.Lazy`1.CreateValue()
       at Microsoft.Extensions.Options.OptionsCache`1.GetOrAdd(String name, Func`1 createOptions)
       at Microsoft.Extensions.Options.OptionsManager`1.Get(String name)
       at Microsoft.Extensions.Options.OptionsManager`1.get_Value()
       at lambda_method945(Closure , Object[] )
       at Autofac.Core.Activators.Reflection.BoundConstructor.Instantiate()
       --- End of inner exception stack trace ---
       at Autofac.Core.Activators.Reflection.BoundConstructor.Instantiate()
       at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
       at Autofac.Core.Activators.Reflection.ReflectionActivator.&lt;ConfigurePipeline&gt;b__11_0(ResolveRequestContext ctxt, Action`1 next)
       at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
       at Autofac.Builder.RegistrationBuilder`3.&lt;&gt;c__DisplayClass41_0.&lt;PropertiesAutowired&gt;b__0(ResolveRequestContext ctxt, Action`1 next)
       at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       --- End of inner exception stack trace ---
       at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Pipeline.ResolvePipeline.Invoke(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.Middleware.RegistrationPipelineInvokeMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.Middleware.ScopeSelectionMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Pipeline.ResolvePipeline.Invoke(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)
       at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request)
       at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ResolveRequest request)
       at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
       at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
       at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
       at Volo.Abp.AspNetCore.Mvc.UI.RazorPages.ServiceBasedPageModelActivatorProvider.&lt;&gt;c__DisplayClass0_0.&lt;CreateActivator&gt;b__0(PageContext context)
       at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DefaultPageModelFactoryProvider.&lt;&gt;c__DisplayClass3_0.&lt;CreateModelFactory&gt;b__0(PageContext pageContext)
       at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.CreateInstance()
       at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync()
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeNextExceptionFilterAsync&gt;g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResourceFilter()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeAsync&gt;g__Logged|17_1(ResourceInvoker invoker)
       at Microsoft.AspNetCore.Routing.EndpointMiddleware.&lt;Invoke&gt;g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
       at Volo.Abp.AspNetCore.Serilog.AbpSerilogMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.&lt;&gt;c__DisplayClass6_1.&lt;&lt;UseMiddlewareInterface&gt;b__1>d.MoveNext()
    --- End of stack trace from previous location ---
       at Volo.Abp.AspNetCore.Auditing.AbpAuditingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Volo.Abp.AspNetCore.Auditing.AbpAuditingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.&lt;&gt;c__DisplayClass6_1.&lt;&lt;UseMiddlewareInterface&gt;b__1>d.MoveNext()
    --- End of stack trace from previous location ---
       at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
       at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
       at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
       at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events, IBackChannelLogoutService backChannelLogoutService)
       at IdentityServer4.Hosting.MutualTlsEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes)
       at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
       at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)
       at Volo.Abp.AspNetCore.Uow.AbpUnitOfWorkMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.&lt;&gt;c__DisplayClass6_1.&lt;&lt;UseMiddlewareInterface&gt;b__1>d.MoveNext()
    --- End of stack trace from previous location ---
       at Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.&lt;&gt;c__DisplayClass6_1.&lt;&lt;UseMiddlewareInterface&gt;b__1>d.MoveNext()
    --- End of stack trace from previous location ---
       at Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
       at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.&lt;&gt;c__DisplayClass6_1.&lt;&lt;UseMiddlewareInterface&gt;b__1>d.MoveNext()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Builder.ApplicationBuilderAbpJwtTokenMiddlewareExtension.&lt;&gt;c__DisplayClass0_0.&lt;&lt;UseJwtTokenMiddleware&gt;b__0>d.MoveNext()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
       at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.&lt;Invoke&gt;g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
    

    We tried countless variations of this setup to make it work but failed.

    Thanks, Can Ercan

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you check the ConfigureUrls method??

    System.NullReferenceException: Object reference not set to an instance of an object.
    at TestApp2.TestApp2HttpApiHostModule.<>c__DisplayClass2_0.<ConfigureUrls>b__0(AppUrlOptions options)
    in E:\abp\TestApp2\aspnet-core\src\TestApp2.HttpApi.Host\TestApp2HttpApiHostModule.cs:line 103
    
  • User Avatar
    0
    can.ercan created

    Configure<AppUrlOptions>(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"; );

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    It seems there is not App:AngularUrl

    "App": {
      "SelfUrl": "https://api.merlinvoip.com",
      "CorsOrigins": "https://merlinvoip.com,https://*.merlinvoip.com"
    },
    
  • User Avatar
    0
    can.ercan created

    Hmm ok, I couldn't find it in the sample project so i removed it. Sample project code:

    "App": {
        "SelfUrl": "https://api.getabp.net:44301",
        "CorsOrigins": "https://*.ng.getabp.net:4200,https://ng.getabp.net:4200/"
      }
    
    Configure<AppUrlOptions>(options =>
    {
       options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
       options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"];
       options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password";
       });
    

    Should i put https://merlinvoip.com or https://*.merlinvoip.com

    I remember trying with https://*.merlinvoip.com and getting invalid uri error from IdentityServer.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    You can try to use https://{{tenantName}}.merlinvoip.com

    "App": {
        "SelfUrl": "https://api.getabp.net:44301",
        "AngularUrl": "https://{{tenantName}}.merlinvoip.com",
        "CorsOrigins": "https://*.ng.getabp.net:4200,https://ng.getabp.net:4200/"
    }
    
  • User Avatar
    0
    can.ercan created

    Hi,

    When i tried to login from https://merlinvoip.com i didn't get the previous error but when i logged in and then redirected to client app i didn't appear to be logged in and the log shows:

    2021-09-21 13:01:15.892 +00:00 [INF] Invoking IdentityServer endpoint: IdentityServer4.Endpoints.TokenEndpoint for /connect/token
    2021-09-21 13:01:15.920 +00:00 [INF] {"ClientId":"TestApp2_App","AuthenticationMethod":"NoSecret","Category":"Authentication","Name":"Client Authentication Success","EventType":"Success","Id":1010,"Message":null,"ActivityId":"800001a7-0000-cb00-b63f-84710c7967bb","TimeStamp":"2021-09-21T13:01:15.0000000Z","ProcessId":6384,"LocalIpAddress":"10.11.0.130:443","RemoteIpAddress":"88.243.86.198","$type":"ClientAuthenticationSuccessEvent"}
    2021-09-21 13:01:15.995 +00:00 [INF] Token request validation success, {"ClientId":"TestApp2_App","ClientName":"TestApp2_App","GrantType":"authorization_code","Scopes":null,"AuthorizationCode":"****82BB","RefreshToken":"********","UserName":null,"AuthenticationContextReferenceClasses":null,"Tenant":null,"IdP":null,"Raw":{"grant_type":"authorization_code","code":"9A7EC69860CCE8494775D54C5FC01816A1480304478A2AEE49CE7BE5037382BB","redirect_uri":"https://merlinvoip.com","code_verifier":"N3RuWU5BWHFfN2dDfkpuazVaQko4ZnNrMGpzdmJ6UFBtVVRVcnphSWl0MU1j","client_id":"TestApp2_App"},"$type":"TokenRequestValidationLog"}
    2021-09-21 13:01:16.152 +00:00 [INF] {"ClientId":"TestApp2_App","ClientName":"TestApp2_App","RedirectUri":null,"Endpoint":"Token","SubjectId":"04a49bf7-0341-52cf-f8c8-39fef527ad38","Scopes":"openid offline_access TestApp2","GrantType":"authorization_code","Tokens":[{"TokenType":"id_token","TokenValue":"****YXBg","$type":"Token"},{"TokenType":"refresh_token","TokenValue":"****DF50","$type":"Token"},{"TokenType":"access_token","TokenValue":"****803Q","$type":"Token"}],"Category":"Token","Name":"Token Issued Success","EventType":"Success","Id":2000,"Message":null,"ActivityId":"800001a7-0000-cb00-b63f-84710c7967bb","TimeStamp":"2021-09-21T13:01:16.0000000Z","ProcessId":6384,"LocalIpAddress":"10.11.0.130:443","RemoteIpAddress":"88.243.86.198","$type":"TokenIssuedSuccessEvent"}
    2021-09-21 13:01:16.205 +00:00 [INF] Request finished HTTP/1.1 POST https://pbxticketapi.azurewebsites.net/connect/token application/x-www-form-urlencoded 233 - 200 - application/json;+charset=UTF-8 386.8135ms
    2021-09-21 13:01:16.283 +00:00 [INF] Request starting HTTP/1.1 OPTIONS https://pbxticketapi.azurewebsites.net/api/abp/application-configuration - -
    2021-09-21 13:01:16.283 +00:00 [INF] CORS policy execution successful.
    2021-09-21 13:01:16.283 +00:00 [INF] Request finished HTTP/1.1 OPTIONS https://pbxticketapi.azurewebsites.net/api/abp/application-configuration - - - 204 - - 0.5517ms
    2021-09-21 13:01:16.363 +00:00 [INF] Request starting HTTP/1.1 GET https://pbxticketapi.azurewebsites.net/api/abp/application-configuration - -
    2021-09-21 13:01:16.363 +00:00 [INF] CORS policy execution successful.
    2021-09-21 13:01:16.402 +00:00 [INF] Failed to validate the token.
    Microsoft.IdentityModel.Tokens.SecurityTokenInvalidIssuerException: IDX10205: Issuer validation failed. Issuer: 'System.String'. Did not match: validationParameters.ValidIssuer: 'System.String' or validationParameters.ValidIssuers: 'System.String'.
       at Microsoft.IdentityModel.Tokens.Validators.ValidateIssuer(String issuer, SecurityToken securityToken, TokenValidationParameters validationParameters)
       at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateIssuer(String issuer, JwtSecurityToken jwtToken, TokenValidationParameters validationParameters)
       at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateTokenPayload(JwtSecurityToken jwtToken, TokenValidationParameters validationParameters)
       at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken)
       at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
    

    One thing I noticed is identity server uses the https://pbxticketapi.azurewebsites.net url.I used to use this url but i changed it.

    "App": {
      "SelfUrl": "https://api.merlinvoip.com",
      "AngularUrl": "https://{{tenantName}}.merlinvoip.com",
      "CorsOrigins": "https://merlinvoip.com,https://*.merlinvoip.com"    
    }
    "AuthServer": {
      "Authority": "https://api.merlinvoip.com",
      "RequireHttpsMetadata": "false",
      "SwaggerClientId": "TestApp2_Swagger",
      "SwaggerClientSecret": "1q2w3e*"
    },
    
    Angular environment variables:
    oAuthConfig: {
      issuer: 'http://{0}.api.merlinvoip.com',
      redirectUri: baseUrl,
      clientId: 'TestApp2_App',
      responseType: 'code',
      scope: 'offline_access TestApp2',
      requireHttps: false
    },
    apis: {
      default: {
        url: 'http://{0}.api.merlinvoip.com',
        rootNamespace: 'TestApp2',
      },
    },
    

    These are my settings but system still uses the old url for identity server. I cleared cookies and caches and restarted both apps but still the old url is used. Is it in the database somewhere?

    Thanks, Can Ercan

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    https://github.com/abpframework/abp/pull/8884 https://github.com/maliming/Owl.TokenWildcardIssuerValidator

  • User Avatar
    0
    can.ercan created

    Hi Problem is solved.

    Thanks, Can Ercan

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Good news!

Made with ❤️ on ABP v9.1.0-preview. Updated on November 26, 2024, 12:49