Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change configuration at runtime ? #923

Closed
ch4mpy opened this issue Dec 24, 2020 · 17 comments
Closed

How to change configuration at runtime ? #923

ch4mpy opened this issue Dec 24, 2020 · 17 comments

Comments

@ch4mpy
Copy link

ch4mpy commented Dec 24, 2020

I couldn't find a way to change some configuration after lib initialisation.

My intention is to replace a "default" value for stsServer with one taken from a configuration form.

How to achieve this ?

@FabianGosebrink
Copy link
Collaborator

FabianGosebrink commented Jan 2, 2021

Hey, currently we do not have an option to change configuration at runtime. You could, however, save the sts server the user gave you, reload the application and provide it through a service. The service reads the sts server the user entered and passes it into the config. Add the servie to the deps array then.

@wolfpackt99
Copy link

wolfpackt99 commented Jan 29, 2021

Also interested in this. Not to fond of browser reload though.

@damienbod
Copy link
Owner

We could probably add support for this, does not seem like a big change or effort

@ch4mpy
Copy link
Author

ch4mpy commented Jan 31, 2021

Thank you.
Realoding the app is a kind of user experience I prefer to avoid.

@martijnvanschie
Copy link

Instead of opening a new issue for a related question. I think this is in line with what i'm looking for.
I want to allow different auth servers and the user can select which one (like google, facebook and OpenID).
Is this currently possible.

I used another library in the past and just updated the config when the user selected the IdP.
Regards,

@damienbod
Copy link
Owner

@martijnvanschie This is not supported at present. We plan to support this by using multiple IDP configuration support. We hope it makes version 12.

Greetings Damien

@martijnvanschie
Copy link

@damienbod that would be a very nice addition. Looking forward to this 😀

@philjones88
Copy link

I've got pretty far using this lib and Ionic + Capacitor but hit this roadblock when it came to deploy. We want customers to be able to enter their hosted URL of our app then we set the STS server to that. A full page refresh isn't really an option in an Ionic app.

Development wise, I've hooked into the urlHandler with Capacitor's Browser.open({ url }) and listened to the events, so locally it works fine. Just won't be deployable easily.

@FabianGosebrink
Copy link
Collaborator

FabianGosebrink commented Jun 11, 2021

Hey, I just gave this thing a look because we are heavily working on V12.

In V12 we are supporting multiple IDPs. So you can pass multiple configs and of course run with one single config as well.

Here are the things which came into my mind: Technically switching the config is not such a great deal, it is doable.

If we switch the configuration at runtime, we can not do a logout at the server, because this would cause a redirect to the sts. Which you do not want when you only want to switch configs. So we can only do logoffLocal erasing all local login information. That is the first thing which I saw.

Currently, we are not storing the complete config in the storage but only in memory because of performance reasons. We are only storing the authWellKnownEndpoints. So when you switch the configuration at runtime we would replace it in the memory, but when you hit refresh in the browser, the original config would be set again.

Also, when looking from the multiple config perspective we would have to support adding a config, replacing a single config, removing a config from multiple configs and replacing multiple configs with other configs.

And when refreshing all the original configs would be set again. So when replacing the config the user has configured A, but running with B OR has A, B, C, ... configured and is running with D, E and F ... This would lead so inconsistency.

Yeah, that is my two cents on that. I don't know how we can solve this to make it useable for the users and am open for proposals.

Thanks, Fabian

@CrazyBaran
Copy link

Hi. I struggling right now with such case. We had SaaS application where our tenants user should can setup their own oidc servers. So we right now kept this information on our backend about which sts server they want to use and then send it on app initialization. This is not a case of multiple IDPs cause each tenant can have only one, but how right now load this configuration into angular-auth-oidc-client so we can allow login into app from some sts?

@FabianGosebrink
Copy link
Collaborator

@CrazyBaran
Copy link

@FabianGosebrink Ah nice, so sorry for bother.

@FabianGosebrink
Copy link
Collaborator

No worries. All good, :-) We are improving the docs in V12 and hope this can be done more obvious then.

@FabianGosebrink
Copy link
Collaborator

After having no feedback on this, I am afraid we have to postpone this feature. I currently see no way to change the config at runtime without having an inconsistency in the configs.

@silviu-sterian
Copy link

Hi, I know this thread has been closed, but could you tell me if there is a way to switch between config at runtime at all? I upgraded to v14 and looks like OidcConfigService is not exported anymore or available - so my work around using .withConfigs does not work. I was combining that and overriding storage to load different configs (external providers) in a demo app.
It looks like I don;t have access anymore to any methods where I can pass in a config and initiate the auth process

@FabianGosebrink
Copy link
Collaborator

Yes, switching configs at runtime is not possible. Not without a reload.

@krunal-jethva-tark
Copy link

Hey @CrazyBaran, we support loading the config from an HTTP source. See https://github.com/damienbod/angular-auth-oidc-client/blob/main/projects/sample-code-flow-http-config/src/app/auth-config.module.ts for reference.

I tried the same thing on my application, but the http request never hits a backend. Just simply returning a BehaviorSubject works perfectly fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants