Closed salamichele closed 1 week ago
I met the same question, after looked into source code. I found a way to use localstorage.
below is provideAuth source code, use can see AbstractSecurityStorage
using session storage
export function _provideAuth(passedConfig) {
return [
// Make the PASSED_CONFIG available through injection
{ provide: PASSED_CONFIG, useValue: passedConfig },
// Create the loader: Either the one getting passed or a static one
passedConfig?.loader || {
provide: StsConfigLoader,
useFactory: createStaticLoader,
deps: [PASSED_CONFIG],
},
{
provide: AbstractSecurityStorage,
useClass: DefaultSessionStorageService,
},
{ provide: AbstractLoggerService, useClass: ConsoleLoggerService },
];
}
So, for overriding it, add this line below
//app.config.ts
providers: [
provideAuth(authConfig),
// this is for overriding default config, must after procideAuth
{ provide: AbstractSecurityStorage, useClass: DefaultLocalStorageService }
]
This is documented at https://nice-hill-002425310.azurestaticapps.net/docs/documentation/configuration#using-localstorage-instead-of-default-sessionstorage (for Modules).
As @jaredhan418 , you can provide your own implementation or use the local storage implementation:
{ provide: AbstractSecurityStorage, useClass: DefaultLocalStorageService }
Can someone provide any example of setting up custom storage using standalone api ? My goal is to store access token in local storage instead of session storage. Docs does not provide any references