Ask for the password once and retry when a machine requires elevation
Carry the protocol error code, wrap each machine's gateway so an elevation_required refusal shows one native password dialog, elevates that connection and retries; send the upload token with file uploads; add a Settings sign-in security section with the weak-password warning and sign out everywhere; accept the __Host- session cookie.
This commit is contained in:
@@ -3,6 +3,8 @@ import 'dart:async';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../core/api_gateway.dart';
|
||||
import '../core/servers/elevation/elevating_gateway.dart';
|
||||
import '../core/servers/elevation/machine_elevation.dart';
|
||||
import '../core/transport/pipelines_client.dart';
|
||||
|
||||
/// Whether this connection's send-only `subscribe` was accepted.
|
||||
@@ -32,8 +34,17 @@ class AppSession extends ChangeNotifier {
|
||||
_everConnected = knownServer {
|
||||
_states = _client.states.listen(_onState);
|
||||
_frames = _client.frames.listen(_onFrame);
|
||||
_elevation = MachineElevation(
|
||||
name: endpoint?.host.isNotEmpty == true ? endpoint!.host : 'this server',
|
||||
gateway: _client,
|
||||
states: _client.states,
|
||||
);
|
||||
_gateway = ElevatingGateway(_client, _elevation);
|
||||
}
|
||||
|
||||
late final MachineElevation _elevation;
|
||||
late final ElevatingGateway _gateway;
|
||||
|
||||
final Uri? _initialEndpoint;
|
||||
final List<Uri>? _initialAddresses;
|
||||
final PipelinesClient _client;
|
||||
@@ -47,7 +58,8 @@ class AppSession extends ChangeNotifier {
|
||||
String _subscriptionError = '';
|
||||
String? _subscribeRequest;
|
||||
|
||||
ApiGateway get gateway => _client;
|
||||
/// Feature requests; a step-up refusal asks for the password and retries.
|
||||
ApiGateway get gateway => _gateway;
|
||||
|
||||
/// Settings controls the same transport; it must never create another socket.
|
||||
PipelinesClient get client => _client;
|
||||
@@ -180,6 +192,7 @@ class AppSession extends ChangeNotifier {
|
||||
_disposed = true;
|
||||
_sendUnsubscribe();
|
||||
unawaited(_states.cancel());
|
||||
unawaited(_elevation.dispose());
|
||||
unawaited(_frames.cancel());
|
||||
unawaited(_client.dispose());
|
||||
super.dispose();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import '../core/servers/chat/chat_server_pool.dart';
|
||||
import '../core/servers/server_context.dart';
|
||||
import '../core/servers/elevation/elevation_dialog.dart';
|
||||
import '../core/servers/elevation/machine_elevation.dart';
|
||||
import '../ui/adaptive/platform.dart';
|
||||
import 'dart:async';
|
||||
|
||||
@@ -125,6 +127,9 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
with WidgetsBindingObserver {
|
||||
late final AppSession _session;
|
||||
late final AppRouterDelegate _delegate;
|
||||
late final ElevationPrompt _elevationPrompt = elevationDialogPrompt(
|
||||
() => _delegate.navigatorContext,
|
||||
);
|
||||
late final RouteInformationProvider _provider;
|
||||
late final bool _ownsProvider;
|
||||
late final RouterConfig<AppRoute> _config;
|
||||
@@ -221,6 +226,7 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
serverId: widget.serverId,
|
||||
);
|
||||
bindServerIdentity(_session.gateway, widget.serverId);
|
||||
bindServerIdentity(_session.client, widget.serverId);
|
||||
_terminals = AppTerminals(
|
||||
pool: widget.chatPool,
|
||||
connection: _session,
|
||||
@@ -294,6 +300,7 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
_session.addListener(_attentionSessionChanged);
|
||||
_session.addListener(_updateEndpointChanged);
|
||||
_attention.addListener(_attentionChanged);
|
||||
MachineElevation.defaultPrompt = _elevationPrompt;
|
||||
_delegate = AppRouterDelegate(
|
||||
initial: initial,
|
||||
cupertino: _cupertino,
|
||||
@@ -436,6 +443,9 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
_notifications.dispose();
|
||||
_deliveryController.dispose();
|
||||
_chatQuestionNotices?.dispose();
|
||||
if (identical(MachineElevation.defaultPrompt, _elevationPrompt)) {
|
||||
MachineElevation.defaultPrompt = null;
|
||||
}
|
||||
_delegate.removeListener(_routeChanged);
|
||||
_delegate.dispose();
|
||||
if (_ownsProvider) {
|
||||
|
||||
Reference in New Issue
Block a user