angular-auth-oidc-client icon indicating copy to clipboard operation
angular-auth-oidc-client copied to clipboard

[Bug]: AuthInterceptor has wrong matchingConfig when more than one config have the same secureRoutes

Open vds-simon-lapointe opened this issue 2 years ago • 5 comments

I am using Ad B2C Authentication and I have 2 configurations: SignUpSignIn and SignUp. Both are registered with AuthModule.forRoot, but they share almost the same parameters, especially regarding secureRoutes. I checked the code, and in AuthInterceptor you do:

const { matchingConfig, matchingRoute } = deps.closestMatchingRouteService.getConfigIdForClosestMatchingRoute(req.url, allConfigurations);

Which always give the first config. So when I am logged with the second one, the first config is returned, and then when you do this:

const token = deps.authStateService.getAccessToken(matchingConfig);

I get a null token. I very easy fix would be to change getConfigIdForClosestMatchingRoute so that it returns a ClosestMatchingRouteResult[] instead of stopping on the first one, then loop over the matching configs and try to getAccessToken until one is found and then use it.

It seems like a very easy fix, unless I forgot something! Should I be making a PR ?

Version

15.0.3

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Steps to reproduce the behavior

No response

A clear and concise description of what you expected to happen.

Additional context

No response

vds-simon-lapointe avatar May 11 '23 02:05 vds-simon-lapointe

Started reading issues and this bug was mentionned here: #1566

But I think there should be an official fix.

vds-simon-lapointe avatar May 11 '23 03:05 vds-simon-lapointe

I have the same problem!!

Blyzaurd avatar May 11 '23 17:05 Blyzaurd

Same problem here

tlucas-linda avatar Dec 06 '23 11:12 tlucas-linda