The angular-auth-oidc-client package uses session storage by default. The problem is our users use this app in multiple tabs/windows at the same time. Session storage requires that the user authenticates in each tab. To prevent this, I want to use cookie storage. I used this article as a guide but once I used the custom storage I get an error in the browser when trying to authorize:
authWellKnownEndpoints is undefined
could not create url [null]
If I use the default storage, everything works as expected. Any ideas on what to do to solve this issue?
Here's the service I wrote for custom storage for reference:
export class AuthCookieStorageService implements AbstractSecurityStorage {
constructor(private _cookieService: CookieService) {}
public read(key: string): any {
const item = this._cookieService.get(key);
console.log('\nCookie Storage Service getting item: ', item, '\n');
if (!!item) {
return JSON.parse(item);
}
return null;
}
public write(key: string, value: any): void {
const writeValue = value || null;
this._cookieService.set(key, JSON.stringify(writeValue), undefined, undefined, undefined, true, 'Strict');
}
}
Edit
Originally I was using ngx-cookie-service to manage the cookies, and that seems to have been the issue. Moving to ngx-cookie solved the issue of not having access to certain auth data.
However, the issue now is that when I open the app in a new tab I still have to authenticate again. I can see the auth data in the cookies in the new tab, but they're apparently not being used when the app loads.