mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-09 01:21:14 +00:00
feat: Implement proper access recovery for DNS providers
This commit is contained in:
parent
ce017c6ea8
commit
232699bdb1
|
@ -56,7 +56,7 @@ class ResponseLoggingParser extends ResponseParser {
|
||||||
abstract class ApiMap {
|
abstract class ApiMap {
|
||||||
Future<GraphQLClient> getClient() async {
|
Future<GraphQLClient> getClient() async {
|
||||||
IOClient? ioClient;
|
IOClient? ioClient;
|
||||||
if (StagingOptions.stagingAcme) {
|
if (StagingOptions.stagingAcme || !StagingOptions.verifyCertificate) {
|
||||||
final HttpClient httpClient = HttpClient();
|
final HttpClient httpClient = HttpClient();
|
||||||
httpClient.badCertificateCallback = (
|
httpClient.badCertificateCallback = (
|
||||||
final cert,
|
final cert,
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
/// Controls staging environment for network, is used during manual
|
/// Controls staging environment for network
|
||||||
/// integration testing and such
|
|
||||||
class StagingOptions {
|
class StagingOptions {
|
||||||
/// Whether we request for staging temprorary certificates.
|
/// Whether we request for staging temprorary certificates.
|
||||||
/// Hardcode to 'true' in the middle of testing to not
|
/// Hardcode to 'true' in the middle of testing to not
|
||||||
/// get your domain banned by constant certificate renewal
|
/// get your domain banned by constant certificate renewal
|
||||||
|
///
|
||||||
|
/// If set to 'true', the 'verifyCertificate' becomes useless
|
||||||
static bool get stagingAcme => false;
|
static bool get stagingAcme => false;
|
||||||
|
|
||||||
|
/// Should we consider CERTIFICATE_VERIFY_FAILED code an error
|
||||||
|
/// For now it's just a global variable and DNS API
|
||||||
|
/// classes can change it at will
|
||||||
|
///
|
||||||
|
/// Doesn't matter if 'statingAcme' is set to 'true'
|
||||||
|
static bool verifyCertificate = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import 'package:cubit_form/cubit_form.dart';
|
import 'package:cubit_form/cubit_form.dart';
|
||||||
|
import 'package:selfprivacy/config/get_it_config.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/api_controller.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/api_controller.dart';
|
||||||
|
import 'package:selfprivacy/logic/api_maps/rest_maps/api_factory_settings.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||||
|
import 'package:selfprivacy/logic/get_it/api_config.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
||||||
|
|
||||||
|
|
|
@ -541,13 +541,20 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
||||||
customToken: serverDetails.apiToken,
|
customToken: serverDetails.apiToken,
|
||||||
isWithToken: true,
|
isWithToken: true,
|
||||||
).getServerProviderType();
|
).getServerProviderType();
|
||||||
if (provider == ServerProvider.unknown) {
|
final dnsProvider = await ServerApi(
|
||||||
|
customToken: serverDetails.apiToken,
|
||||||
|
isWithToken: true,
|
||||||
|
).getDnsProviderType();
|
||||||
|
if (provider == ServerProvider.unknown ||
|
||||||
|
dnsProvider == DnsProvider.unknown) {
|
||||||
getIt<NavigationService>()
|
getIt<NavigationService>()
|
||||||
.showSnackBar('recovering.generic_error'.tr());
|
.showSnackBar('recovering.generic_error'.tr());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await repository.saveServerDetails(serverDetails);
|
await repository.saveServerDetails(serverDetails);
|
||||||
|
await repository.saveDnsProviderType(dnsProvider);
|
||||||
setServerProviderType(provider);
|
setServerProviderType(provider);
|
||||||
|
setDnsProviderType(dnsProvider);
|
||||||
emit(
|
emit(
|
||||||
dataState.copyWith(
|
dataState.copyWith(
|
||||||
serverDetails: serverDetails,
|
serverDetails: serverDetails,
|
||||||
|
@ -700,14 +707,15 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
||||||
.showSnackBar('recovering.domain_not_available_on_token'.tr());
|
.showSnackBar('recovering.domain_not_available_on_token'.tr());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final dnsProviderType = await ServerApi(
|
||||||
|
customToken: dataState.serverDetails!.apiToken,
|
||||||
|
isWithToken: true,
|
||||||
|
).getDnsProviderType();
|
||||||
await repository.saveDomain(
|
await repository.saveDomain(
|
||||||
ServerDomain(
|
ServerDomain(
|
||||||
domainName: serverDomain.domainName,
|
domainName: serverDomain.domainName,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
provider: await ServerApi(
|
provider: dnsProviderType,
|
||||||
customToken: token,
|
|
||||||
isWithToken: true,
|
|
||||||
).getDnsProviderType(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await repository.saveDnsProviderKey(token);
|
await repository.saveDnsProviderKey(token);
|
||||||
|
|
|
@ -15,6 +15,7 @@ import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider.
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider_api_settings.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider_api_settings.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider.dart';
|
||||||
|
import 'package:selfprivacy/logic/api_maps/staging_options.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
import 'package:selfprivacy/logic/models/hive/backblaze_credential.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
import 'package:selfprivacy/logic/models/hive/server_details.dart';
|
||||||
|
@ -76,17 +77,20 @@ class ServerInstallationRepository {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dnsProvider != null ||
|
if (ApiController.currentDnsProviderApiFactory == null) {
|
||||||
(serverDomain != null &&
|
if (dnsProvider != null ||
|
||||||
serverDomain.provider != DnsProvider.unknown)) {
|
(serverDomain != null &&
|
||||||
ApiController.initDnsProviderApiFactory(
|
serverDomain.provider != DnsProvider.unknown)) {
|
||||||
DnsProviderApiFactorySettings(
|
ApiController.initDnsProviderApiFactory(
|
||||||
provider: dnsProvider ?? serverDomain!.provider,
|
DnsProviderApiFactorySettings(
|
||||||
),
|
provider: dnsProvider ?? serverDomain!.provider,
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (box.get(BNames.hasFinalChecked, defaultValue: false)) {
|
if (box.get(BNames.hasFinalChecked, defaultValue: false)) {
|
||||||
|
StagingOptions.verifyCertificate = true;
|
||||||
return ServerInstallationFinished(
|
return ServerInstallationFinished(
|
||||||
providerApiToken: providerApiToken!,
|
providerApiToken: providerApiToken!,
|
||||||
serverTypeIdentificator: serverTypeIdentificator ?? '',
|
serverTypeIdentificator: serverTypeIdentificator ?? '',
|
||||||
|
|
Loading…
Reference in a new issue