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:
2026-11-10 01:21:28 +00:00
parent e43f9fa50c
commit 9702d68d2d
30 changed files with 1464 additions and 31 deletions
+12 -3
View File
@@ -3,6 +3,10 @@ import 'dart:io';
import 'login_probe.dart';
/// The web login's session cookie: `__Host-` prefixed over https, plain over
/// http.
const sessionCookieNames = {'pipelines_session', '__Host-pipelines_session'};
/// Posts the password to the web login and returns its session cookie.
Future<({String? cookie, String? error})> postLogin(
Uri login,
@@ -23,7 +27,7 @@ Future<({String? cookie, String? error})> postLogin(
final response = await request.close();
await response.drain<void>();
for (final cookie in response.cookies) {
if (cookie.name == 'pipelines_session' && cookie.value.isNotEmpty) {
if (sessionCookieNames.contains(cookie.name) && cookie.value.isNotEmpty) {
return (cookie: '${cookie.name}=${cookie.value}', error: null);
}
}
@@ -61,7 +65,10 @@ Future<LoginProbe> probeLogin(Uri login, Map<String, String> headers) async {
return LoginProbe(status: response.statusCode);
}
final body = await _head(response, 65536);
return LoginProbe(status: 200, loginPage: LoginProbe.isPipelinesLogin(body));
return LoginProbe(
status: 200,
loginPage: LoginProbe.isPipelinesLogin(body),
);
} on Exception catch (error) {
return LoginProbe(failure: describeFailure(login, error));
} finally {
@@ -71,7 +78,9 @@ Future<LoginProbe> probeLogin(Uri login, Map<String, String> headers) async {
Future<String> _head(HttpClientResponse response, int limit) async {
final buffer = StringBuffer();
await for (final chunk in response.transform(const SystemEncoding().decoder)) {
await for (final chunk in response.transform(
const SystemEncoding().decoder,
)) {
buffer.write(chunk);
if (buffer.length > limit) break;
}