Add Windows Settings button for FIDO

This commit is contained in:
Dain Nilsson 2024-02-06 13:54:47 +01:00
parent 02a3bc3a57
commit 1c3ac84afb
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8
8 changed files with 88 additions and 49 deletions

View File

@ -23,8 +23,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../desktop/models.dart'; import '../../desktop/models.dart';
import '../../desktop/state.dart'; import '../../desktop/state.dart';
import '../../management/models.dart'; import '../../management/models.dart';
import '../message.dart';
import '../state.dart'; import '../state.dart';
import 'elevate_fido_buttons.dart';
import 'message_page.dart'; import 'message_page.dart';
class AppFailurePage extends ConsumerWidget { class AppFailurePage extends ConsumerWidget {
@ -69,31 +69,7 @@ class AppFailurePage extends ConsumerWidget {
centered = false; centered = false;
graphic = null; graphic = null;
actions = [ actions = [
FilledButton.icon( const ElevateFidoButtons(),
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();
}
},
),
]; ];
} }
break; break;

View File

@ -22,9 +22,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/models.dart'; import '../../core/models.dart';
import '../../desktop/state.dart'; import '../../desktop/state.dart';
import '../message.dart';
import '../models.dart'; import '../models.dart';
import '../state.dart'; import '../state.dart';
import 'elevate_fido_buttons.dart';
import 'message_page.dart'; import 'message_page.dart';
class DeviceErrorScreen extends ConsumerWidget { class DeviceErrorScreen extends ConsumerWidget {
@ -44,25 +44,7 @@ class DeviceErrorScreen extends ConsumerWidget {
header: l10n.s_admin_privileges_required, header: l10n.s_admin_privileges_required,
message: l10n.p_elevated_permissions_required, message: l10n.p_elevated_permissions_required,
actionsBuilder: (context, expanded) => [ actionsBuilder: (context, expanded) => [
FilledButton.icon( const ElevateFidoButtons(),
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();
}
},
),
], ],
); );
} }

View 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'
]);
},
)
],
);
}
}

View File

@ -596,9 +596,11 @@
"@_permissions": {}, "@_permissions": {},
"s_enable_nfc": "NFC aktivieren", "s_enable_nfc": "NFC aktivieren",
"s_request_access": null,
"s_permission_denied": "Zugriff verweigert", "s_permission_denied": "Zugriff verweigert",
"l_elevating_permissions": "Erhöhe Berechtigungen\u2026", "l_elevating_permissions": "Erhöhe Berechtigungen\u2026",
"s_review_permissions": "Berechtigungen überprüfen", "s_review_permissions": "Berechtigungen überprüfen",
"s_open_windows_settings": null,
"s_admin_privileges_required": null, "s_admin_privileges_required": null,
"p_elevated_permissions_required": "Die Verwaltung dieses Geräts benötigt erhöhte Berechtigungen.", "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.", "p_webauthn_elevated_permissions_required": "WebAuthn-Verwaltung benötigt erhöhte Berechtigungen.",

View File

@ -596,12 +596,14 @@
"@_permissions": {}, "@_permissions": {},
"s_enable_nfc": "Enable NFC", "s_enable_nfc": "Enable NFC",
"s_request_access": "Request access",
"s_permission_denied": "Permission denied", "s_permission_denied": "Permission denied",
"l_elevating_permissions": "Elevating permissions\u2026", "l_elevating_permissions": "Elevating permissions\u2026",
"s_review_permissions": "Review permissions", "s_review_permissions": "Review permissions",
"s_admin_privileges_required": "Admin privileges required", "s_open_windows_settings": "Open Windows settings",
"p_elevated_permissions_required": "Managing this device requires elevated privileges.", "s_admin_privileges_required": "Administrator privileges required",
"p_webauthn_elevated_permissions_required": "WebAuthn management requires elevated privileges.", "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.",
"p_need_camera_permission": "Yubico Authenticator needs Camera permissions for scanning QR codes.", "p_need_camera_permission": "Yubico Authenticator needs Camera permissions for scanning QR codes.",
"@_qr_codes": {}, "@_qr_codes": {},

View File

@ -596,9 +596,11 @@
"@_permissions": {}, "@_permissions": {},
"s_enable_nfc": "Activer le NFC", "s_enable_nfc": "Activer le NFC",
"s_request_access": null,
"s_permission_denied": "Permission refusée", "s_permission_denied": "Permission refusée",
"l_elevating_permissions": "Élevation des permissions\u2026", "l_elevating_permissions": "Élevation des permissions\u2026",
"s_review_permissions": "Révision des permissions", "s_review_permissions": "Révision des permissions",
"s_open_windows_settings": null,
"s_admin_privileges_required": null, "s_admin_privileges_required": null,
"p_elevated_permissions_required": "Gérer cet appareil demande des privilèges plus élevés.", "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.", "p_webauthn_elevated_permissions_required": "La gestion WebAuthn demande des privilèges plus élevés.",

View File

@ -596,9 +596,11 @@
"@_permissions": {}, "@_permissions": {},
"s_enable_nfc": "NFCを有効にする", "s_enable_nfc": "NFCを有効にする",
"s_request_access": null,
"s_permission_denied": "権限がありません", "s_permission_denied": "権限がありません",
"l_elevating_permissions": "権限の昇格\u2026", "l_elevating_permissions": "権限の昇格\u2026",
"s_review_permissions": "権限の確認", "s_review_permissions": "権限の確認",
"s_open_windows_settings": null,
"s_admin_privileges_required": null, "s_admin_privileges_required": null,
"p_elevated_permissions_required": "このデバイスを管理するには権限の昇格が必要です", "p_elevated_permissions_required": "このデバイスを管理するには権限の昇格が必要です",
"p_webauthn_elevated_permissions_required": "WebAuthn管理には権限の昇格が必要です", "p_webauthn_elevated_permissions_required": "WebAuthn管理には権限の昇格が必要です",

View File

@ -596,9 +596,11 @@
"@_permissions": {}, "@_permissions": {},
"s_enable_nfc": "Włącz NFC", "s_enable_nfc": "Włącz NFC",
"s_request_access": null,
"s_permission_denied": "Odmowa dostępu", "s_permission_denied": "Odmowa dostępu",
"l_elevating_permissions": "Podnoszenie uprawnień\u2026", "l_elevating_permissions": "Podnoszenie uprawnień\u2026",
"s_review_permissions": "Przegląd uprawnień", "s_review_permissions": "Przegląd uprawnień",
"s_open_windows_settings": null,
"s_admin_privileges_required": "Wymagane uprawnienia administratora", "s_admin_privileges_required": "Wymagane uprawnienia administratora",
"p_elevated_permissions_required": "Zarządzanie tym urządzeniem wymaga podwyższonych uprawnień.", "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ń.", "p_webauthn_elevated_permissions_required": "Zarządzanie WebAuthn wymaga podwyższonych uprawnień.",