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
problem with allowedUrls and AOT #361
Comments
I suggest doing this in import { OAuthModuleConfig, OAuthModule } from 'angular-oauth2-oidc';
import { authConfigFactory } from './auth-config-factory';
//...
imports: [
OAuthModule.forRoot(),
// ...
],
providers: [
{ provide: OAuthModuleConfig , useFactory: authConfigFactory, deps: [ConfigService] },
// ...
]
// ... and then this in // imports here
export function authConfigFactory(service: ConfigService): OAuthModuleConfig {
return {
resourceServer: {
allowedUrls: [service.getVarFromConf()],
sendAccessToken: true,
}
};
} or something similar... |
You made my day @jeroenheijmans 👌 |
I'm having a similar issue. I'm using Here's what my
|
You might have a related but different issue @westerncj. I'm unable to tell based on shown code alone though. Most likely your scenario is not really an issue with the library, but a question about how to structure/order things in your app. Perhaps a Stack Overflow question would be a better fit? Otherwise opening a new issue could possibly work. But in either case it might be good to have a little more code (a StackBlitz example would be nice). |
I'm having the same issue as the Original Poster. Does it have anything to do with the library or is it just an Angular problem? |
@Maximaximum What is the 'problem' that's left over? If your OAuthModuleConfig has a dependency on dynamic data, then Angular DI and a Service seem like the idiomatic solution? Either way, I'm pretty confident that there's no other way (though happy to learn one of course!). Perhaps the only thing to simplify this approach is to import environment stuff directly to be part of a constant config (but OP suggested needing something more dynamic). |
Ok, I just figured out that I was using a dynamic value whereas I should use a static one. I've fixed my problem, so sorry for bothering. |
I'm having the same ordering issue as @westerncj above. The OAuthConfig is setting the allowedUrl before the call to get the dynamic variables is finished. The relevant code bits:
How can I force the authConfigFactory to wait to run until after the loadAppConfig async call is finished? |
@westerncj @rutgervd The factory for the OAuthModuleConfig initialized the
The APP_INITIALIZER then gets the OAuthModuleConfig injected and after loading the config from the server it sets the
This seemed to work ... |
Original question seems to have several good solutions and workarounds from follow-up comments. Let us know if there's still an open issue and we could reopen and investigate further! |
I faced the same problem and found a different solution. You can however load the settings BEFORE bootstrapping the Module. Inside your App.module/other components you can access your settings without having to fear the settings are not loaded. I have created an example of how to accomplish this: github.com/dtiemstra/AngularConfigDemo |
I have a problem with allowedUrls in :
I want to pass a variable to it because it come from configuration stuff but when it's compile by AOT my variable is replaced by null and so authorization token is not sent later.
Is there any workaround for this problem ? I dont want to hard code here my allowed urls...
for the moment what I did is to iOAuthModuleConfig from may main app.component and then set resoureServer from there.
But I don't know if it's a good thing
The text was updated successfully, but these errors were encountered: