TF-886 Add encryption cipher for token oidc in hive database

This commit is contained in:
dab246
2022-09-07 10:40:25 +07:00
committed by Dat H. Pham
parent 6018cd383a
commit e255ea0b61
@@ -98,10 +98,14 @@ class TokenOidcCacheClient extends HiveCacheClient<TokenOidcCache> {
@override
Future<Box<TokenOidcCache>> openBox() async {
if (Hive.isBoxOpen(tableName)) {
return Hive.box<TokenOidcCache>(tableName);
}
return Hive.openBox<TokenOidcCache>(tableName);
return Future.sync(() async {
final encryptionKey = await getEncryptionKey();
return Hive.openBox<TokenOidcCache>(
tableName,
encryptionCipher: HiveAesCipher(encryptionKey!));
}).catchError((error) {
throw error;
});
}
@override