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

[Question]: Is it possible to implement multiple configurations for Angular 17 standalone components project?

Open soniafaria opened this issue 1 year ago • 3 comments

What Version of the library are you using? 17.0.0

Question How can I implement multiple authentication configurations and router guards for an Angular 17 project, using standalone components?

soniafaria avatar Feb 21 '24 14:02 soniafaria

Hi, the capabilities of the "standalone" VS "module" should be the same. The only difference is "how" this is configured within an app.

In other words, a standalone project can still use multiple configurations. As an example you can take a look at https://github.com/damienbod/angular-auth-oidc-client/blob/main/projects/sample-code-flow-standalone/src/app/app.config.ts (which is configured for a single config, but you can also provide an array of configs just as with the module approach).

timdeschryver avatar Feb 21 '24 19:02 timdeschryver

Thanks for your response @timdeschryver! I have successfully implemented multiple configurations, but one thing that I am not achieving is the protection of routes via custom guard, when using multiple configurations. I saw this example in the documentation but isAuthentication is always false. I understood by the documentation that this value returns false when having multiple configurations, is there any other way I can implement it? Thanks 😀

soniafaria avatar Feb 22 '24 10:02 soniafaria

@soniafaria I don't have "real" experience with it. But AFAIK if you use isAuthenticated instead of isAuthenticated$ you can provide a configId. If you provide the configuration id, isAuthenticated will return the result for that configuration.

timdeschryver avatar Feb 22 '24 16:02 timdeschryver