mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-26 22:03:55 +03:00
Merge PR #1378
This commit is contained in:
commit
773bc6d9a4
@ -20,11 +20,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../core/state.dart';
|
||||
import '../../desktop/models.dart';
|
||||
import '../../desktop/state.dart';
|
||||
import '../../management/models.dart';
|
||||
import '../message.dart';
|
||||
import '../state.dart';
|
||||
import 'elevate_fido_buttons.dart';
|
||||
import 'message_page.dart';
|
||||
|
||||
class AppFailurePage extends ConsumerWidget {
|
||||
@ -44,6 +45,7 @@ class AppFailurePage extends ConsumerWidget {
|
||||
bool centered = true;
|
||||
List<Capability>? capabilities;
|
||||
List<Widget> actions = [];
|
||||
String? footnote;
|
||||
|
||||
if (reason is RpcError) {
|
||||
if (reason.status == 'connection-error') {
|
||||
@ -64,37 +66,16 @@ class AppFailurePage extends ConsumerWidget {
|
||||
final currentApp = ref.read(currentAppProvider);
|
||||
title = currentApp.getDisplayName(l10n);
|
||||
capabilities = currentApp.capabilities;
|
||||
header = l10n.s_admin_privileges_required;
|
||||
header = l10n.l_admin_privileges_required;
|
||||
message = l10n.p_webauthn_elevated_permissions_required;
|
||||
centered = false;
|
||||
graphic = null;
|
||||
actions = [
|
||||
FilledButton.icon(
|
||||
label: Text(l10n.s_unlock),
|
||||
icon: const Icon(Icons.lock_open),
|
||||
onPressed: () async {
|
||||
final closeMessage = showMessage(
|
||||
context, l10n.l_elevating_permissions,
|
||||
duration: const Duration(seconds: 30));
|
||||
try {
|
||||
if (await ref.read(rpcProvider).requireValue.elevate()) {
|
||||
ref.invalidate(rpcProvider);
|
||||
} else {
|
||||
await ref.read(withContextProvider)(
|
||||
(context) async {
|
||||
showMessage(
|
||||
context,
|
||||
l10n.s_permission_denied,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
closeMessage();
|
||||
}
|
||||
},
|
||||
),
|
||||
const ElevateFidoButtons(),
|
||||
];
|
||||
if (isMicrosoftStore) {
|
||||
footnote = l10n.l_ms_store_permission_note;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -111,6 +92,7 @@ class AppFailurePage extends ConsumerWidget {
|
||||
graphic: graphic,
|
||||
header: header,
|
||||
message: message,
|
||||
footnote: footnote,
|
||||
actionsBuilder: (context, expanded) => actions,
|
||||
);
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ final _navExpandedKey = GlobalKey();
|
||||
|
||||
class AppPage extends StatelessWidget {
|
||||
final String? title;
|
||||
final String? footnote;
|
||||
final Widget Function(BuildContext context, bool expanded) builder;
|
||||
final Widget Function(BuildContext context)? detailViewBuilder;
|
||||
final List<Widget> Function(BuildContext context, bool expanded)?
|
||||
@ -50,6 +51,7 @@ class AppPage extends StatelessWidget {
|
||||
const AppPage({
|
||||
super.key,
|
||||
this.title,
|
||||
this.footnote,
|
||||
required this.builder,
|
||||
this.centered = false,
|
||||
this.keyActionsBuilder,
|
||||
@ -207,6 +209,17 @@ class AppPage extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (footnote != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Opacity(
|
||||
opacity: 0.6,
|
||||
child: Text(
|
||||
footnote!,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
return SingleChildScrollView(
|
||||
|
@ -21,10 +21,11 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../core/models.dart';
|
||||
import '../../core/state.dart';
|
||||
import '../../desktop/state.dart';
|
||||
import '../message.dart';
|
||||
import '../models.dart';
|
||||
import '../state.dart';
|
||||
import 'elevate_fido_buttons.dart';
|
||||
import 'message_page.dart';
|
||||
|
||||
class DeviceErrorScreen extends ConsumerWidget {
|
||||
@ -41,29 +42,12 @@ class DeviceErrorScreen extends ConsumerWidget {
|
||||
return MessagePage(
|
||||
title: currentApp.getDisplayName(l10n),
|
||||
capabilities: currentApp.capabilities,
|
||||
header: l10n.s_admin_privileges_required,
|
||||
header: l10n.l_admin_privileges_required,
|
||||
message: l10n.p_elevated_permissions_required,
|
||||
actionsBuilder: (context, expanded) => [
|
||||
FilledButton.icon(
|
||||
label: Text(l10n.s_unlock),
|
||||
icon: const Icon(Icons.lock_open),
|
||||
onPressed: () async {
|
||||
final closeMessage = showMessage(
|
||||
context, l10n.l_elevating_permissions,
|
||||
duration: const Duration(seconds: 30));
|
||||
try {
|
||||
if (await ref.read(rpcProvider).requireValue.elevate()) {
|
||||
ref.invalidate(rpcProvider);
|
||||
} else {
|
||||
await ref.read(withContextProvider)((context) async =>
|
||||
showMessage(context, l10n.s_permission_denied));
|
||||
}
|
||||
} finally {
|
||||
closeMessage();
|
||||
}
|
||||
},
|
||||
),
|
||||
const ElevateFidoButtons(),
|
||||
],
|
||||
footnote: isMicrosoftStore ? l10n.l_ms_store_permission_note : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
71
lib/app/views/elevate_fido_buttons.dart
Normal file
71
lib/app/views/elevate_fido_buttons.dart
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Yubico.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../desktop/state.dart';
|
||||
import '../message.dart';
|
||||
import '../state.dart';
|
||||
|
||||
class ElevateFidoButtons extends ConsumerWidget {
|
||||
const ElevateFidoButtons({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
return Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
FilledButton.icon(
|
||||
label: Text(l10n.s_request_access),
|
||||
icon: const Icon(Icons.lock_open),
|
||||
onPressed: () async {
|
||||
final closeMessage = showMessage(
|
||||
context, l10n.l_elevating_permissions,
|
||||
duration: const Duration(seconds: 30));
|
||||
try {
|
||||
if (await ref.read(rpcProvider).requireValue.elevate()) {
|
||||
ref.invalidate(rpcProvider);
|
||||
} else {
|
||||
await ref.read(withContextProvider)((context) async =>
|
||||
showMessage(context, l10n.s_permission_denied));
|
||||
}
|
||||
} finally {
|
||||
closeMessage();
|
||||
}
|
||||
},
|
||||
),
|
||||
OutlinedButton.icon(
|
||||
label: Text(l10n.s_open_windows_settings),
|
||||
icon: const Icon(Icons.open_in_new),
|
||||
onPressed: () async {
|
||||
await Process.start('powershell.exe', [
|
||||
'-NoProfile',
|
||||
'-Command',
|
||||
'Start',
|
||||
'ms-settings:signinoptions-launchsecuritykeyenrollment'
|
||||
]);
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@ class MessagePage extends StatelessWidget {
|
||||
final Widget? graphic;
|
||||
final String? header;
|
||||
final String? message;
|
||||
final String? footnote;
|
||||
final bool delayedContent;
|
||||
final Widget Function(BuildContext context)? keyActionsBuilder;
|
||||
final Widget Function(BuildContext context)? actionButtonBuilder;
|
||||
@ -43,6 +44,7 @@ class MessagePage extends StatelessWidget {
|
||||
this.graphic,
|
||||
this.header,
|
||||
this.message,
|
||||
this.footnote,
|
||||
this.keyActionsBuilder,
|
||||
this.actionButtonBuilder,
|
||||
this.actionsBuilder,
|
||||
@ -58,6 +60,7 @@ class MessagePage extends StatelessWidget {
|
||||
Widget build(BuildContext context) => AppPage(
|
||||
title: title,
|
||||
capabilities: capabilities,
|
||||
footnote: footnote,
|
||||
centered: centered,
|
||||
keyActionsBuilder: keyActionsBuilder,
|
||||
keyActionsBadge: keyActionsBadge,
|
||||
|
@ -14,23 +14,25 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../app/models.dart';
|
||||
|
||||
bool get isDesktop {
|
||||
return const [
|
||||
TargetPlatform.windows,
|
||||
TargetPlatform.macOS,
|
||||
TargetPlatform.linux
|
||||
].contains(defaultTargetPlatform);
|
||||
}
|
||||
bool get isDesktop => const [
|
||||
TargetPlatform.windows,
|
||||
TargetPlatform.macOS,
|
||||
TargetPlatform.linux
|
||||
].contains(defaultTargetPlatform);
|
||||
|
||||
bool get isAndroid {
|
||||
return defaultTargetPlatform == TargetPlatform.android;
|
||||
}
|
||||
bool get isAndroid => defaultTargetPlatform == TargetPlatform.android;
|
||||
|
||||
bool get isMicrosoftStore =>
|
||||
Platform.isWindows &&
|
||||
Platform.resolvedExecutable.contains('\\WindowsApps\\');
|
||||
|
||||
// This must be initialized before use, in main.dart.
|
||||
final prefProvider = Provider<SharedPreferences>((ref) {
|
||||
|
@ -117,7 +117,8 @@ class _FidoLockedPage extends ConsumerWidget {
|
||||
: l10n.l_ready_to_use,
|
||||
message: isBio
|
||||
? l10n.p_setup_fingerprints_desc
|
||||
: '${l10n.l_register_sk_on_websites}\n\n${l10n.l_non_passkeys_note}',
|
||||
: l10n.l_register_sk_on_websites,
|
||||
footnote: isBio ? null : l10n.l_non_passkeys_note,
|
||||
keyActionsBuilder: hasActions && !isBio ? _buildActions : null,
|
||||
keyActionsBadge: !isBio ? fidoShowActionsNotifier(state) : false,
|
||||
);
|
||||
@ -128,8 +129,8 @@ class _FidoLockedPage extends ConsumerWidget {
|
||||
title: l10n.s_passkeys,
|
||||
capabilities: const [Capability.fido2],
|
||||
header: l10n.l_ready_to_use,
|
||||
message:
|
||||
'${l10n.l_register_sk_on_websites}\n\n${l10n.l_non_passkeys_note}',
|
||||
message: l10n.l_register_sk_on_websites,
|
||||
footnote: l10n.l_non_passkeys_note,
|
||||
keyActionsBuilder: hasActions ? _buildActions : null,
|
||||
keyActionsBadge: fidoShowActionsNotifier(state),
|
||||
);
|
||||
@ -200,8 +201,8 @@ class _FidoUnlockedPageState extends ConsumerState<_FidoUnlockedPage> {
|
||||
title: l10n.s_passkeys,
|
||||
capabilities: const [Capability.fido2],
|
||||
header: l10n.l_no_discoverable_accounts,
|
||||
message:
|
||||
'${l10n.l_register_sk_on_websites}\n\n${l10n.l_non_passkeys_note}',
|
||||
message: l10n.l_register_sk_on_websites,
|
||||
footnote: l10n.l_non_passkeys_note,
|
||||
keyActionsBuilder: hasActions
|
||||
? (context) =>
|
||||
passkeysBuildActions(context, widget.node, widget.state)
|
||||
@ -221,13 +222,13 @@ class _FidoUnlockedPageState extends ConsumerState<_FidoUnlockedPage> {
|
||||
title: l10n.s_passkeys,
|
||||
capabilities: const [Capability.fido2],
|
||||
header: l10n.l_no_discoverable_accounts,
|
||||
message:
|
||||
'${l10n.l_register_sk_on_websites}\n\n${l10n.l_non_passkeys_note}',
|
||||
message: l10n.l_register_sk_on_websites,
|
||||
keyActionsBuilder: hasActions
|
||||
? (context) =>
|
||||
passkeysBuildActions(context, widget.node, widget.state)
|
||||
: null,
|
||||
keyActionsBadge: fidoShowActionsNotifier(widget.state),
|
||||
footnote: l10n.l_non_passkeys_note,
|
||||
);
|
||||
}
|
||||
|
||||
@ -270,6 +271,7 @@ class _FidoUnlockedPageState extends ConsumerState<_FidoUnlockedPage> {
|
||||
builder: (context) => AppPage(
|
||||
title: l10n.s_passkeys,
|
||||
capabilities: const [Capability.fido2],
|
||||
footnote: l10n.l_non_passkeys_note,
|
||||
detailViewBuilder: credential != null
|
||||
? (context) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@ -349,26 +351,18 @@ class _FidoUnlockedPageState extends ConsumerState<_FidoUnlockedPage> {
|
||||
}),
|
||||
}
|
||||
},
|
||||
child:
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
...credentials.map(
|
||||
(cred) => _CredentialListItem(
|
||||
cred,
|
||||
expanded: expanded,
|
||||
selected: _selected == cred,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Opacity(
|
||||
opacity: 0.6,
|
||||
child: Text(
|
||||
l10n.l_non_passkeys_note,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: credentials
|
||||
.map(
|
||||
(cred) => _CredentialListItem(
|
||||
cred,
|
||||
expanded: expanded,
|
||||
selected: _selected == cred,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -596,12 +596,15 @@
|
||||
|
||||
"@_permissions": {},
|
||||
"s_enable_nfc": "NFC aktivieren",
|
||||
"s_request_access": null,
|
||||
"s_permission_denied": "Zugriff verweigert",
|
||||
"l_elevating_permissions": "Erhöhe Berechtigungen\u2026",
|
||||
"s_review_permissions": "Berechtigungen überprüfen",
|
||||
"s_admin_privileges_required": null,
|
||||
"s_open_windows_settings": null,
|
||||
"l_admin_privileges_required": null,
|
||||
"p_elevated_permissions_required": "Die Verwaltung dieses Geräts benötigt erhöhte Berechtigungen.",
|
||||
"p_webauthn_elevated_permissions_required": "WebAuthn-Verwaltung benötigt erhöhte Berechtigungen.",
|
||||
"l_ms_store_permission_note": null,
|
||||
"p_need_camera_permission": "Yubico Authenticator benötigt Zugriff auf die Kamera um QR-Codes aufnehmen zu können.",
|
||||
|
||||
"@_qr_codes": {},
|
||||
|
@ -596,12 +596,15 @@
|
||||
|
||||
"@_permissions": {},
|
||||
"s_enable_nfc": "Enable NFC",
|
||||
"s_request_access": "Request access",
|
||||
"s_permission_denied": "Permission denied",
|
||||
"l_elevating_permissions": "Elevating permissions\u2026",
|
||||
"s_review_permissions": "Review permissions",
|
||||
"s_admin_privileges_required": "Admin privileges required",
|
||||
"p_elevated_permissions_required": "Managing this device requires elevated privileges.",
|
||||
"p_webauthn_elevated_permissions_required": "WebAuthn management requires elevated privileges.",
|
||||
"s_open_windows_settings": "Open Windows settings",
|
||||
"l_admin_privileges_required": "Administrator privileges required",
|
||||
"p_elevated_permissions_required": "Managing this device requires elevated privileges. Alternatively, you can use Windows Settings to manage FIDO configuration.",
|
||||
"p_webauthn_elevated_permissions_required": "WebAuthn management requires elevated privileges. Alternatively, you can use Windows Settings to manage FIDO configuration.",
|
||||
"l_ms_store_permission_note": "The Microsoft Store version of the app may be unable to elevate permissions",
|
||||
"p_need_camera_permission": "Yubico Authenticator needs Camera permissions for scanning QR codes.",
|
||||
|
||||
"@_qr_codes": {},
|
||||
|
@ -596,12 +596,15 @@
|
||||
|
||||
"@_permissions": {},
|
||||
"s_enable_nfc": "Activer le NFC",
|
||||
"s_request_access": null,
|
||||
"s_permission_denied": "Permission refusée",
|
||||
"l_elevating_permissions": "Élevation des permissions\u2026",
|
||||
"s_review_permissions": "Révision des permissions",
|
||||
"s_admin_privileges_required": null,
|
||||
"s_open_windows_settings": null,
|
||||
"l_admin_privileges_required": null,
|
||||
"p_elevated_permissions_required": "Gérer cet appareil demande des privilèges plus élevés.",
|
||||
"p_webauthn_elevated_permissions_required": "La gestion WebAuthn demande des privilèges plus élevés.",
|
||||
"l_ms_store_permission_note": null,
|
||||
"p_need_camera_permission": "Yubico Authenticator a besoin des permission d'utiliser la caméra pour scanner les QR code.",
|
||||
|
||||
"@_qr_codes": {},
|
||||
|
@ -596,12 +596,15 @@
|
||||
|
||||
"@_permissions": {},
|
||||
"s_enable_nfc": "NFCを有効にする",
|
||||
"s_request_access": null,
|
||||
"s_permission_denied": "権限がありません",
|
||||
"l_elevating_permissions": "権限の昇格\u2026",
|
||||
"s_review_permissions": "権限の確認",
|
||||
"s_admin_privileges_required": null,
|
||||
"s_open_windows_settings": null,
|
||||
"l_admin_privileges_required": null,
|
||||
"p_elevated_permissions_required": "このデバイスを管理するには権限の昇格が必要です",
|
||||
"p_webauthn_elevated_permissions_required": "WebAuthn管理には権限の昇格が必要です",
|
||||
"l_ms_store_permission_note": null,
|
||||
"p_need_camera_permission": "Yubico AuthenticatorにはQRコードをスキャンするためのカメラ権限が必要です",
|
||||
|
||||
"@_qr_codes": {},
|
||||
|
@ -596,12 +596,15 @@
|
||||
|
||||
"@_permissions": {},
|
||||
"s_enable_nfc": "Włącz NFC",
|
||||
"s_request_access": null,
|
||||
"s_permission_denied": "Odmowa dostępu",
|
||||
"l_elevating_permissions": "Podnoszenie uprawnień\u2026",
|
||||
"s_review_permissions": "Przegląd uprawnień",
|
||||
"s_admin_privileges_required": "Wymagane uprawnienia administratora",
|
||||
"s_open_windows_settings": null,
|
||||
"l_admin_privileges_required": "Wymagane uprawnienia administratora",
|
||||
"p_elevated_permissions_required": "Zarządzanie tym urządzeniem wymaga podwyższonych uprawnień.",
|
||||
"p_webauthn_elevated_permissions_required": "Zarządzanie WebAuthn wymaga podwyższonych uprawnień.",
|
||||
"l_ms_store_permission_note": null,
|
||||
"p_need_camera_permission": "Yubico Authenticator wymaga dostępu do aparatu w celu skanowania kodów QR.",
|
||||
|
||||
"@_qr_codes": {},
|
||||
|
Loading…
Reference in New Issue
Block a user