Open Closed

OpenIdConnect redirection issue #8731


User avatar
0
SharmaAtul created
  • ABP Framework version: v9.0.2
  • UI Type: MVC
  • Database System: EF Core (SQL Server)
  • **Tiered (for MVC) or Auth Server Separated: yes
  • Exception message and full stack trace: I am back and forward on redirect URL after authenticating with Microsoft Azure AD
  • Steps to reproduce the issue: I have added my configuration for OpenIdConnect and after that I am facing that issue. Also I am attaching video for reference as well. Video https://jmp.sh/jrphAyUq

These are the logs

2025-01-31 16:46:27.271 +05:30 [INF] Request starting HTTP/2 GET https://localhost:44362/Identity/OrganizationUnits - null null 2025-01-31 16:46:27.274 +05:30 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessRequestContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ResolveRequestUri. 2025-01-31 16:46:27.275 +05:30 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ResolveRequestUri. 2025-01-31 16:46:27.275 +05:30 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.OpenIddictServerHandlers+InferEndpointType. 2025-01-31 16:46:27.275 +05:30 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by Volo.Abp.Account.Web.Pages.Account.OpenIddictImpersonateInferEndpointType. 2025-01-31 16:46:27.275 +05:30 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ValidateTransportSecurityRequirement. 2025-01-31 16:46:27.275 +05:30 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ValidateHostHeader. 2025-01-31 16:46:27.287 +05:30 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ValidateHostHeader. 2025-01-31 16:46:27.287 +05:30 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.OpenIddictValidationHandlers+EvaluateValidatedTokens. 2025-01-31 16:46:27.288 +05:30 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromAuthorizationHeader. 2025-01-31 16:46:27.288 +05:30 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromBodyForm. 2025-01-31 16:46:27.288 +05:30 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromQueryString. 2025-01-31 16:46:27.288 +05:30 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateRequiredTokens. 2025-01-31 16:46:27.288 +05:30 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was marked as rejected by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateRequiredTokens. 2025-01-31 16:46:27.288 +05:30 [DBG] AuthenticationScheme: OpenIddict.Validation.AspNetCore was not authenticated. 2025-01-31 16:46:27.295 +05:30 [INF] Authorization failed. These requirements were not met: PermissionRequirement: AbpIdentity.OrganizationUnits 2025-01-31 16:46:27.296 +05:30 [INF] AuthenticationScheme: OpenIdConnect was challenged. 2025-01-31 16:46:27.300 +05:30 [INF] Request finished HTTP/2 GET https://localhost:44362/Identity/OrganizationUnits - 302 null null 29.4896ms


115 Answer(s)
  • User Avatar
    0
    SharmaAtul created

    What if I do not set credentials for host and add for Tenant only?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    https://github.com/maliming/NextGenPortal/blob/main/src/NextGen.Portal.Web/PortalWebModule.cs#L281-L313

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    What if I do not set credentials for host and add for Tenant only?

    It's possiable. but let us solve the error first.

  • User Avatar
    0
    SharmaAtul created

    Ok it is working if i add the credentials for Host as well. If i just enable the provider then override value for Tenant then I am getting an error.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Ok it is working if i add the credentials for Host as well. If i just enable the provider then override value for Tenant then I am getting an error.

    Can you share more details?

    How can I get the same error with https://github.com/maliming/NextGenPortal

    Thanks.

  • User Avatar
    0
    SharmaAtul created

    First remove the Azure Open Id credentials from host and just checked Enable checkbox.

    Make sure Tenant have the credentials that I shared and check.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I can log in in with a tenant . But I can't log in in with the host.

    Because host doesn't has client id...

  • User Avatar
    0
    SharmaAtul created

    Also is it compulsory to have Azure AD credentials in appsettings.json file as we already added credentials for the tenant using UI? Because if you remove the credentials then you will get this error

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    This commit will disable for host if the client id is null or empty

    https://github.com/maliming/NextGenPortal/commit/07f8638fdc1023785428e7e63a1f27ebbedd48d5

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Because if you remove the credentials then you will get this error

    You have to set a value but the setting will override it.

    The azure will check the clientid and throw exception if if empty.

  • User Avatar
    0
    SharmaAtul created

    I removed the Azure AD credentials from appsettings.json file and set the values for Tenant using UI.

    I am getting the error which I mentioned in the previous comment with screenshot.

    Can you please try that and let me know?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You have to set some values for it. but the values will be overridden by abp.

    You can set any value but there must have value when app start.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You have to set some values for it. but the values will be overridden by abp.

    You can set any value but there must have value when app start.

    eg: clientid=123123 it also works

  • User Avatar
    0
    SharmaAtul created

    I have set initial values like this and

    After that I am getting this error

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    well, the authority must be set as a url.

    And the well-known endpoint also need to be valid.

  • User Avatar
    0
    SharmaAtul created

    we need to pass the correct values for clientId and client secret also else it throws above error. So there is no option to remove these settings from appsetting?

  • User Avatar
    0
    SharmaAtul created

    Also, Can we deploy and run app on IIS with http?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    we need to pass the correct values for clientId and client secret also else it throws above error. So there is no option to remove these settings from appsetting?

    I will find a way.

    Also, Can we deploy and run app on IIS with http?

    Can you create a new question?

    Thanks

  • User Avatar
    0
    SharmaAtul created

    Ok thanks

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    we need to pass the correct values for clientId and client secret also else it throws above error. So there is no option to remove these settings from appsetting?

    Can you test this commit?

    https://github.com/maliming/NextGenPortal/commit/cfd5a88a06eafc03b97981763b16b17199dbc526

  • User Avatar
    0
    SharmaAtul created

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    https://github.com/alpeshkalena Can access this repo.

  • User Avatar
    0
    SharmaAtul created

    Ok let me check now

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    ok

  • User Avatar
    0
    SharmaAtul created

    So on app start at least we need to pass authority url. I applied changes like this

    And after that I am getting this error

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.2.0-preview. Updated on March 20, 2025, 18:00