Open Closed

Can't connect to IP address in Maui App running on local device #3915


User avatar
0
learnabp created

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v6.0.0
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:

[0:] An error occurred: 'Error loading discovery document: Issuer name does not match authority: https://localhost:44343/'. Callstack: ' at IdentityModel.OidcClient.OidcClient.EnsureProviderInformationAsync(CancellationToken cancellationToken) in //src/OidcClient/OidcClient.cs:line 410 at IdentityModel.OidcClient.OidcClient.EnsureConfigurationAsync(CancellationToken cancellationToken) in //src/OidcClient/OidcClient.cs:line 371 at IdentityModel.OidcClient.OidcClient.LoginAsync(LoginRequest request, CancellationToken cancellationToken) in /_/src/OidcClient/OidcClient.cs:line 73 at Amazing.Software.Mobile.Maui.Oidc.LoginService.LoginAsync() in C:\LearnABP\Amazing.Software.Mobile\aspnet-core\src\Amazing.Software.Mobile.Maui\Oidc\LoginService.cs:line 21 at Amazing.Software.Mobile.Maui.ViewModels.MainPageViewModel.LoginOrLogoutAsync() in C:\LearnABP\Amazing.Software.Mobile\aspnet-core\src\Amazing.Software.Mobile.Maui\ViewModels\MainPageViewModel.cs:line 53 at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state) at Foundation.NSAsyncSynchronizationContextDispatcher.Apply() at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) at Amazing.Software.Mobile.Maui.Program.Main(String[] args) in C:\LearnABP\Amazing.Software.Mobile\aspnet-core\src\Amazing.Software.Mobile.Maui\Platforms\iOS\Program.cs:line 12 at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)' The app has been terminated.

appsettings.json of web project

{
  "App": {
    "SelfUrl": "https://localhost:44343/"
  },
  "Redis": {
    "Configuration": "127.0.0.1"
  },
  "ConnectionStrings": {
    "Default": "Server=localhost;Database=AmazingSoftwareMobile;Trusted_Connection=True"
  },
  "AuthServer": {
    "Authority": "https://localhost:44343/",
    "RequireHttpsMetadata": "false",
    "ValidIssuers": [ "https://10.10.30.30:45455/" ]
  },
  "StringEncryption": {
    "DefaultPassPhrase": "MBvujhnLzlU9atyZ"
  }  
}

appsettings.json of maui project

{
  "Oidc": {
    "Options": {
      "Authority": "https://10.10.30.30:45455/",
      "ClientId": "Mobile_Maui",
      "RedirectUri": "mobile://",
      "PostLogoutRedirectUri": "mobile://",
      "Scope": "offline_access Mobile"
    }
  },
  "RemoteServices": {
    "Default": {
      "BaseUrl": "https://10.10.30.30:45455/"
    }
  }
}

ConfigureAuthentication Method in MobileWebModule as you can see I have added the Valid Issuer as 10.10.30.30

private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{

    context.Services.AddAuthentication().AddJwtBearer(options => {
        options.TokenValidationParameters.ValidIssuers = configuration.GetSection("AuthServer:ValidIssuers").Get&lt;string[]&gt;();
    });

    context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
}
  • Steps to reproduce the issue:"
  • Create a new Maui Startup template using abp suite
  • Run the .web project in cmd prompt
  • Deploy .Maui project to local device (in my case iphone)
  • Click on Loging button the app craches

The local address of my pc is https://10.10.30.30, I can browse the website in my browser security with no errors and can also download the https://10.10.30.30:45455/.well-known/openid-configuration

I am using Conveyor by Keyoti for tunneling because can't use the local host as suggested in Microsoft Docs to use the HostName or IP address of the computer the ports 44343 and 45455 are both open in the windows firewall


1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can add the following code to ConfigureOidcClient method of *.MauiModule class

    Configure<OidcClientOptions>(options =>
    {
        options.Policy.Discovery.ValidateIssuerName = false;
    });
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15