mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 10:11:52 +03:00
disable FIDO2 on Chromebook
This commit is contained in:
parent
a847364f17
commit
7342f1fb30
@ -494,6 +494,11 @@ class MainActivity : FlutterFragmentActivity() {
|
||||
startActivity(Intent(ACTION_NFC_SETTINGS))
|
||||
result.success(true)
|
||||
}
|
||||
|
||||
"isArc" -> {
|
||||
val regex = ".+_cheets|cheets_.+".toRegex()
|
||||
result.success(Build.DEVICE?.matches(regex) ?: false)
|
||||
}
|
||||
else -> logger.warn("Unknown app method: {}", methodCall.method)
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,6 @@ class DeviceManager(
|
||||
try {
|
||||
Ctap2Session(it)
|
||||
operationContexts.add(OperationContext.FidoPasskeys)
|
||||
operationContexts.add(OperationContext.FidoFingerprints)
|
||||
} catch (e: Throwable) { // ignored
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,10 @@ Future<int> getAndroidSdkVersion() async {
|
||||
return await appMethodsChannel.invokeMethod('getAndroidSdkVersion');
|
||||
}
|
||||
|
||||
Future<bool> getAndroidIsArc() async {
|
||||
return await appMethodsChannel.invokeMethod('isArc');
|
||||
}
|
||||
|
||||
Future<Color> getPrimaryColor() async {
|
||||
final value = await appMethodsChannel.invokeMethod('getPrimaryColor');
|
||||
return value != null ? Color(value) : defaultPrimaryColor;
|
||||
|
@ -27,6 +27,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../app/app.dart';
|
||||
import '../app/features.dart' as features;
|
||||
import '../app/logging.dart';
|
||||
import '../app/models.dart';
|
||||
import '../app/state.dart';
|
||||
import '../app/views/main_page.dart';
|
||||
import '../core/state.dart';
|
||||
@ -53,6 +54,8 @@ Future<Widget> initialize() async {
|
||||
|
||||
_initLicenses();
|
||||
|
||||
final isArc = await getAndroidIsArc();
|
||||
|
||||
return ProviderScope(
|
||||
overrides: [
|
||||
prefProvider.overrideWithValue(await SharedPreferences.getInstance()),
|
||||
@ -82,6 +85,12 @@ Future<Widget> initialize() async {
|
||||
),
|
||||
androidSdkVersionProvider.overrideWithValue(await getAndroidSdkVersion()),
|
||||
androidNfcSupportProvider.overrideWithValue(await getHasNfc()),
|
||||
supportedSectionsProvider.overrideWithValue(
|
||||
[Section.home, Section.accounts, Section.passkeys]),
|
||||
// this specifies the priority of sections to show when
|
||||
// the connected YubiKey does not support current section
|
||||
androidSectionPriority.overrideWithValue(
|
||||
[Section.accounts, Section.passkeys, Section.home]),
|
||||
supportedThemesProvider.overrideWith(
|
||||
(ref) => ref.watch(androidSupportedThemesProvider),
|
||||
),
|
||||
@ -102,6 +111,7 @@ Future<Widget> initialize() async {
|
||||
// Disable unimplemented feature
|
||||
..setFeature(features.piv, false)
|
||||
..setFeature(features.otp, false)
|
||||
..setFeature(features.fido, !isArc)
|
||||
..setFeature(features.management, false);
|
||||
});
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2023 Yubico.
|
||||
* Copyright (C) 2022-2024 Yubico.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -77,6 +77,8 @@ class NfcStateNotifier extends StateNotifier<bool> {
|
||||
}
|
||||
}
|
||||
|
||||
final androidSectionPriority = Provider<List<Section>>((ref) => []);
|
||||
|
||||
final androidSdkVersionProvider = Provider<int>((ref) => -1);
|
||||
|
||||
final androidNfcSupportProvider = Provider<bool>((ref) => false);
|
||||
@ -104,8 +106,8 @@ final androidAppContextHandler =
|
||||
Provider<AndroidAppContextHandler>((ref) => AndroidAppContextHandler());
|
||||
|
||||
CurrentSectionNotifier androidCurrentSectionNotifier(Ref ref) {
|
||||
final notifier =
|
||||
AndroidCurrentSectionNotifier(ref.watch(androidAppContextHandler));
|
||||
final notifier = AndroidCurrentSectionNotifier(
|
||||
ref.watch(androidSectionPriority), ref.watch(androidAppContextHandler));
|
||||
ref.listen<AsyncValue<YubiKeyData>>(currentDeviceDataProvider, (_, data) {
|
||||
notifier._notifyDeviceChanged(data.whenOrNull(data: ((data) => data)));
|
||||
}, fireImmediately: true);
|
||||
@ -113,10 +115,13 @@ CurrentSectionNotifier androidCurrentSectionNotifier(Ref ref) {
|
||||
}
|
||||
|
||||
class AndroidCurrentSectionNotifier extends CurrentSectionNotifier {
|
||||
final List<Section> _supportedSectionsByPriority;
|
||||
final AndroidAppContextHandler _appContextHandler;
|
||||
|
||||
AndroidCurrentSectionNotifier(this._appContextHandler)
|
||||
: super(Section.accounts);
|
||||
AndroidCurrentSectionNotifier(
|
||||
this._supportedSectionsByPriority,
|
||||
this._appContextHandler,
|
||||
) : super(Section.accounts);
|
||||
|
||||
@override
|
||||
void setCurrentSection(Section section) {
|
||||
@ -131,22 +136,17 @@ class AndroidCurrentSectionNotifier extends CurrentSectionNotifier {
|
||||
return;
|
||||
}
|
||||
|
||||
// current section priority
|
||||
final availableSections = [
|
||||
Section.accounts,
|
||||
Section.passkeys,
|
||||
Section.home,
|
||||
].where(
|
||||
final supportedSections = _supportedSectionsByPriority.where(
|
||||
(e) => e.getAvailability(data) == Availability.enabled,
|
||||
);
|
||||
|
||||
if (availableSections.contains(state)) {
|
||||
if (supportedSections.contains(state)) {
|
||||
// the key supports current section
|
||||
_log.debug('Keeping current section because new key support $state');
|
||||
return;
|
||||
}
|
||||
|
||||
setCurrentSection(availableSections.firstOrNull ?? Section.home);
|
||||
setCurrentSection(supportedSections.firstOrNull ?? Section.home);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user