Make authstorage configurable
This commit is contained in:
36
projects/common/src/fm/shared/secureOAuthStorage.ts
Normal file
36
projects/common/src/fm/shared/secureOAuthStorage.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import {OAuthStorage} from 'angular-oauth2-oidc';
|
||||
import {Inject, Injectable} from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class SecureOAuthStorage extends OAuthStorage {
|
||||
private storage = {};
|
||||
|
||||
secureKey(key:string): boolean {
|
||||
if(key == "nonce") return false;
|
||||
if(key == "PKCI_verifier") return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
getItem(key: string): string {
|
||||
if(this.secureKey(key)) {
|
||||
return this.storage[key];
|
||||
} else {
|
||||
return window.sessionStorage.getItem(key);
|
||||
}
|
||||
|
||||
};
|
||||
removeItem(key: string): void {
|
||||
if(this.secureKey(key)) {
|
||||
delete this.storage[key];
|
||||
} else {
|
||||
window.sessionStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
setItem(key: string, data: string): void {
|
||||
if(this.secureKey(key)) {
|
||||
this.storage[key]=data;
|
||||
} else {
|
||||
window.sessionStorage.setItem(key,data);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user