You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-07-17 15:47:54 +02:00
feat(mobile): Adding setting in mobile app to TLS client certificate (#10860)
* feat(mobile): Adding setting in mobile app to import TLS client certificate and private key * Formating dart source code to pass dart format test * Adding missed required trailing commas to pass dart static analysis * update lock file * variable names --------- Co-authored-by: Yun Jiang <yjiang@roku.com> Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
@ -1,3 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:immich_mobile/entities/user.entity.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
@ -140,6 +143,36 @@ class StoreValue {
|
||||
}
|
||||
}
|
||||
|
||||
class SSLClientCertStoreVal {
|
||||
final Uint8List data;
|
||||
final String? password;
|
||||
|
||||
SSLClientCertStoreVal(this.data, this.password);
|
||||
|
||||
void save() {
|
||||
final b64Str = base64Encode(data);
|
||||
Store.put(StoreKey.sslClientCertData, b64Str);
|
||||
if (password != null) {
|
||||
Store.put(StoreKey.sslClientPasswd, password!);
|
||||
}
|
||||
}
|
||||
|
||||
static SSLClientCertStoreVal? load() {
|
||||
final b64Str = Store.tryGet<String>(StoreKey.sslClientCertData);
|
||||
if (b64Str == null) {
|
||||
return null;
|
||||
}
|
||||
final Uint8List certData = base64Decode(b64Str);
|
||||
final passwd = Store.tryGet<String>(StoreKey.sslClientPasswd);
|
||||
return SSLClientCertStoreVal(certData, passwd);
|
||||
}
|
||||
|
||||
static void delete() {
|
||||
Store.delete(StoreKey.sslClientCertData);
|
||||
Store.delete(StoreKey.sslClientPasswd);
|
||||
}
|
||||
}
|
||||
|
||||
class StoreKeyNotFoundException implements Exception {
|
||||
final StoreKey key;
|
||||
StoreKeyNotFoundException(this.key);
|
||||
@ -164,6 +197,8 @@ enum StoreKey<T> {
|
||||
serverEndpoint<String>(12, type: String),
|
||||
autoBackup<bool>(13, type: bool),
|
||||
backgroundBackup<bool>(14, type: bool),
|
||||
sslClientCertData<String>(15, type: String),
|
||||
sslClientPasswd<String>(16, type: String),
|
||||
// user settings from [AppSettingsEnum] below:
|
||||
loadPreview<bool>(100, type: bool),
|
||||
loadOriginal<bool>(101, type: bool),
|
||||
|
Reference in New Issue
Block a user