mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 00:51:20 +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 {
|
||||
Future<GraphQLClient> getClient() async {
|
||||
IOClient? ioClient;
|
||||
if (StagingOptions.stagingAcme) {
|
||||
if (StagingOptions.stagingAcme || !StagingOptions.verifyCertificate) {
|
||||
final HttpClient httpClient = HttpClient();
|
||||
httpClient.badCertificateCallback = (
|
||||
final cert,
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
/// Controls staging environment for network, is used during manual
|
||||
/// integration testing and such
|
||||
/// Controls staging environment for network
|
||||
class StagingOptions {
|
||||
/// Whether we request for staging temprorary certificates.
|
||||
/// Hardcode to 'true' in the middle of testing to not
|
||||
/// get your domain banned by constant certificate renewal
|
||||
///
|
||||
/// If set to 'true', the 'verifyCertificate' becomes useless
|
||||
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: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_factory_settings.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/get_it/api_config.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
||||
|
||||
|
|
|
@ -541,13 +541,20 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
|||
customToken: serverDetails.apiToken,
|
||||
isWithToken: true,
|
||||
).getServerProviderType();
|
||||
if (provider == ServerProvider.unknown) {
|
||||
final dnsProvider = await ServerApi(
|
||||
customToken: serverDetails.apiToken,
|
||||
isWithToken: true,
|
||||
).getDnsProviderType();
|
||||
if (provider == ServerProvider.unknown ||
|
||||
dnsProvider == DnsProvider.unknown) {
|
||||
getIt<NavigationService>()
|
||||
.showSnackBar('recovering.generic_error'.tr());
|
||||
return;
|
||||
}
|
||||
await repository.saveServerDetails(serverDetails);
|
||||
await repository.saveDnsProviderType(dnsProvider);
|
||||
setServerProviderType(provider);
|
||||
setDnsProviderType(dnsProvider);
|
||||
emit(
|
||||
dataState.copyWith(
|
||||
serverDetails: serverDetails,
|
||||
|
@ -700,14 +707,15 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
|||
.showSnackBar('recovering.domain_not_available_on_token'.tr());
|
||||
return;
|
||||
}
|
||||
final dnsProviderType = await ServerApi(
|
||||
customToken: dataState.serverDetails!.apiToken,
|
||||
isWithToken: true,
|
||||
).getDnsProviderType();
|
||||
await repository.saveDomain(
|
||||
ServerDomain(
|
||||
domainName: serverDomain.domainName,
|
||||
zoneId: zoneId,
|
||||
provider: await ServerApi(
|
||||
customToken: token,
|
||||
isWithToken: true,
|
||||
).getDnsProviderType(),
|
||||
provider: dnsProviderType,
|
||||
),
|
||||
);
|
||||
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/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/staging_options.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/server_details.dart';
|
||||
|
@ -76,17 +77,20 @@ class ServerInstallationRepository {
|
|||
);
|
||||
}
|
||||
|
||||
if (dnsProvider != null ||
|
||||
(serverDomain != null &&
|
||||
serverDomain.provider != DnsProvider.unknown)) {
|
||||
ApiController.initDnsProviderApiFactory(
|
||||
DnsProviderApiFactorySettings(
|
||||
provider: dnsProvider ?? serverDomain!.provider,
|
||||
),
|
||||
);
|
||||
if (ApiController.currentDnsProviderApiFactory == null) {
|
||||
if (dnsProvider != null ||
|
||||
(serverDomain != null &&
|
||||
serverDomain.provider != DnsProvider.unknown)) {
|
||||
ApiController.initDnsProviderApiFactory(
|
||||
DnsProviderApiFactorySettings(
|
||||
provider: dnsProvider ?? serverDomain!.provider,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (box.get(BNames.hasFinalChecked, defaultValue: false)) {
|
||||
StagingOptions.verifyCertificate = true;
|
||||
return ServerInstallationFinished(
|
||||
providerApiToken: providerApiToken!,
|
||||
serverTypeIdentificator: serverTypeIdentificator ?? '',
|
||||
|
|
Loading…
Reference in a new issue