Open Closed

Angular (Code Flow) + OpenIddict - multiple compatibility issues after IdentityServer migration #10735


User avatar
0
rian.corry@allsop.software created

Environment:

  • ABP Commercial (latest), Angular UI, Separated architecture (AuthServer + HttpApi.Host + Angular SPA)
  • Migrated from IdentityServer to OpenIddict following ABP documentation
  • All backend layers migrated successfully, issues are Angular-side

Issues encountered:

  1. Infinite redirect loop after login (auth guard vs code exchange race)

After the auth server redirects back with the authorization code, ABP's AuthGuard on the root route (/) fires immediately. At that point, the code exchange has not completed yet, so hasValidAccessToken() returns false. The guard redirects to login, the auth server auto-authenticates (session still active), redirects back - infinite loop. We had to create a dedicated /oauth/code callback route without an auth guard, and update the redirect_uri in both the Angular config and the OpenIddict application registration. Is there a recommended callback route for the code flow, or should ABP's auth guard wait for an in-progress code exchange before redirecting?

  1. tryLogin() silently fails due to nonce validation

After the authorization code redirect, ABP's OAuth module calls tryLogin() without passing disableNonceCheck. The angular-oauth2-oidc library validates the nonce from the state parameter, fails, and rejects the promise - but ABP catches it with .catch(noop). The authorization code is consumed and discarded with no error surfaced to the developer. Is there a recommended way to disable nonce validation, or should ABP's OAuth module be passing disableNonceCheck: true for OpenIddict?

  1. PKCE code_verifier lost between redirects

The library stores the PKCE verifier in sessionStorage by default. After the redirect back from the auth server, the verifier is gone and the token exchange fails with "code_verifier missing". We resolved this with saveNoncesInLocalStorage: true. Should this be the default for ABP's OpenIddict configuration?

  1. CHECK_AUTHENTICATION_STATE_FN clears tokens on startup

After a successful code exchange, the token is stored in memory. ABP then calls /api/abp/application-configuration. If there is any timing issue or the API does not recognize the token immediately, ABP's checkAccessToken function clears all token storage. Is there a recommended approach to prevent this race condition, or is the no-op override for CHECK_AUTHENTICATION_STATE_FN_KEY intentional for OpenIddict setups?

  1. revokeTokenAndLogout does not redirect on CORS failure

During logout, ABP calls oAuthService.revokeTokenAndLogout() without setting ignoreCorsIssues = true. If the revocation endpoint returns a CORS error (status 0), the logOut() method (which redirects to the end_session endpoint) is never called - the user appears stuck. Should ABP's code flow strategy be passing ignoreCorsIssues = true, or is there a CORS configuration we are missing?

Workarounds applied:

  • Created /oauth/code route without auth guard as callback URL
  • Monkey-patched tryLogin() to inject disableNonceCheck: true
  • Set saveNoncesInLocalStorage: true in oAuthConfig
  • Overrode CHECK_AUTHENTICATION_STATE_FN_KEY with no-op
  • Monkey-patched revokeTokenAndLogout() to force ignoreCorsIssues = true

Question: Are these known issues with the Angular + OpenIddict code flow? Is there planned documentation or a fix in ABP's @abp/ng.oauth module to handle these scenarios, or are we expected to apply these workarounds manually? We would also appreciate guidance on which workarounds are safe for production vs temporary.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

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

    Hi,

    Thanks for the detailed write-up - having the symptoms already mapped to specific lib functions saves us a lot of digging.

    A couple of these are real gaps in our OAuth strategy on the framework side - the silent tryLogin().catch(noop) and the missing ignoreCorsIssues on revokeTokenAndLogout - and I have those queued for a fix. But the nonce/PKCE race and the application-configuration timing don't trigger consistently in the default Angular template, so something specific to your setup is likely pushing them (SSR config, custom OAuthStorage, AuthServer CORS, browser storage policy, or how OpenIddict is configured to return the id_token / nonce).

    Easiest path forward: could you create a minimal repro in a private GitHub repo and add maliming as a collaborator? Just enough to trigger the loop and the silent failures - your AuthServer + HttpApi.Host + Angular wired the way they currently are, with the same package versions. Once I have access I'll push the fixes directly to a branch there, so you can pull the actual changes instead of carrying monkey-patches across upgrades.

    If a private repo doesn't fit, you can zip the project and send it via WeTransfer to liming.ma@volosoft.com - just strip any secrets / connection strings first.

    Thanks

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 07:12
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.