I’m trying to convert this to Aurelia but not having much luck, I just want my configuration in my app so it doesn’t need to be redeployed and it’s easy to switch config on the fly and this will allow me to use slots on azure.
My configuration service looks like this
import { HttpClient } from 'aurelia-fetch-client';
import { autoinject } from 'aurelia-framework';
import { Configuration } from 'resources/config/configuration';
import { log } from './log-service';
@autoinject()
export class ConfigurationService {
private readonly configUrlPath: string = 'ClientConfiguration';
private configData: Configuration;
constructor(private http: HttpClient) { }
public async loadConfigurationData() {
try {
const response = await this.http.fetch(`${this.configUrlPath}`);
this.configData = await response.json() as Configuration;
} catch (error) {
log.error('Config failed');
}
}
// A helper property to return the config object
get config(): Configuration {
return this.configData;
}
}
And my configure
function like this…
aurelia.use
.standardConfiguration()
const configHttp = new HttpClient();
const configurationService = new ConfigurationService(configHttp);
await configurationService.loadConfigurationData();
aurelia.container.registerInstance(ConfigurationService);
aurelia.use
.plugin(PLATFORM.moduleName('aurelia-open-id-connect'), () => oidcConfig);
And in my oidcConfig which is where I want to grab the URLs from config
import { OpenIdConnectConfiguration } from 'aurelia-open-id-connect';
import { UserManagerSettings, WebStorageStateStore } from 'oidc-client';
import { Configuration } from 'resources/config/configuration';
import { ConfigurationService } from 'services/configuration-service';
import {Container} from 'aurelia-dependency-injection';
const container = Container.instance;
const configurationService = container.get(ConfigurationService);
export default {
loginRedirectRoute: '',
logoutRedirectRoute: 'signin-oidc',
unauthorizedRedirectRoute: 'login',
userManagerSettings: {
accessTokenExpiringNotificationTime: 300,
authority: configurationService.config.authority,
automaticSilentRenew: true,
checkSessionInterval: 10000,
client_id: 'SomeClient',
filterProtocolClaims: true,
loadUserInfo: true,
post_logout_redirect_uri: `${configurationService.config.host}/signout-oidc`,
redirect_uri: `${configurationService.config.host}/signin-oidc`,
response_type: 'id_token token',
scope: 'openid email profile api',
silentRequestTimeout: 10000,
silent_redirect_uri: `${configurationService.config.host}/signin-oidc`,
userStore: new WebStorageStateStore({
prefix: 'oidc',
store: window.localStorage
})
} as UserManagerSettings
} as OpenIdConnectConfiguration;
When I attached a debugger it looks like it run the oidc config before the ConfigurationService
is ready which doesn’t make sense to me.