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