未验证 提交 0a2869e5 编写于 作者: B Ben Konyi 提交者: GitHub

Added support for authentication codes for the VM service (#8527)

上级 36d2135a
......@@ -31,7 +31,7 @@ vars = {
# Dart is: https://github.com/dart-lang/sdk/blob/master/DEPS.
# You can use //tools/dart/create_updated_flutter_deps.py to produce
# updated revision list of existing dependencies.
'dart_revision': '1490a90bc1c4cbbf13470af3408584e57d135fb2',
'dart_revision': '15b11b018364ce032eae50d78fc8a52b541e2bce',
# WARNING: DO NOT EDIT MANUALLY
# The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py
......
Signature: 1ab2f2e559e655ad5cfe1e759d241b54
Signature: 866085660a05bb407caffc09636cbd32
UNUSED LICENSES:
......@@ -86,6 +86,10 @@ struct Settings {
uint32_t observatory_port = 0;
bool ipv6 = false;
// Determines whether an authentication code is required to communicate with
// the VM service.
bool disable_service_auth_codes = true;
// Font settings
bool use_test_fonts = false;
......
......@@ -579,7 +579,8 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate(
settings.observatory_port, // server observatory port
tonic::DartState::HandleLibraryTag, // embedder library tag handler
false, // disable websocket origin check
error // error (out)
settings.disable_service_auth_codes, // disable VM service auth codes
error // error (out)
)) {
// Error is populated by call to startup.
FML_DLOG(ERROR) << *error;
......
......@@ -134,6 +134,7 @@ bool DartServiceIsolate::Startup(std::string server_ip,
intptr_t server_port,
Dart_LibraryTagHandler embedder_tag_handler,
bool disable_origin_check,
bool disable_service_auth_codes,
char** error) {
Dart_Isolate isolate = Dart_CurrentIsolate();
FML_CHECK(isolate);
......@@ -196,6 +197,10 @@ bool DartServiceIsolate::Startup(std::string server_ip,
Dart_SetField(library, Dart_NewStringFromCString("_originCheckDisabled"),
Dart_NewBoolean(disable_origin_check));
SHUTDOWN_ON_ERROR(result);
result =
Dart_SetField(library, Dart_NewStringFromCString("_authCodesDisabled"),
Dart_NewBoolean(disable_service_auth_codes));
SHUTDOWN_ON_ERROR(result);
return true;
}
......
......@@ -26,6 +26,7 @@ class DartServiceIsolate {
intptr_t server_port,
Dart_LibraryTagHandler embedder_tag_handler,
bool disable_origin_check,
bool disable_service_auth_codes,
char** error);
static std::string GetObservatoryUri();
......
......@@ -84,6 +84,10 @@ static const char* kDartStartPausedArgs[]{
"--pause_isolates_on_start",
};
static const char* kDartDisableServiceAuthCodesArgs[]{
"--disable-service-auth-codes",
};
static const char* kDartTraceStartupArgs[]{
"--timeline_streams=Compiler,Dart,Debugger,Embedder,GC,Isolate,VM",
};
......@@ -325,6 +329,11 @@ DartVM::DartVM(std::shared_ptr<const DartVMData> vm_data,
PushBackAll(&args, kDartStartPausedArgs, arraysize(kDartStartPausedArgs));
}
if (settings_.disable_service_auth_codes) {
PushBackAll(&args, kDartDisableServiceAuthCodesArgs,
arraysize(kDartDisableServiceAuthCodesArgs));
}
if (settings_.endless_trace_buffer || settings_.trace_startup) {
// If we are tracing startup, make sure the trace buffer is endless so we
// don't lose early traces.
......
......@@ -166,6 +166,13 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
}
}
// Enable need for authentication codes for VM service communication, if
// specified.
// TODO(bkonyi): when authentication codes are enabled by default, change
// to 'DisableServiceAuthCodes' and un-negate.
settings.disable_service_auth_codes =
!command_line.HasOption(FlagForSwitch(Switch::EnableServiceAuthCodes));
// Checked mode overrides.
settings.disable_dart_asserts =
command_line.HasOption(FlagForSwitch(Switch::DisableDartAsserts));
......
......@@ -96,6 +96,12 @@ DEF_SWITCH(FlutterAssetsDir,
"Path to the Flutter assets directory.")
DEF_SWITCH(Help, "help", "Display this help text.")
DEF_SWITCH(LogTag, "log-tag", "Tag associated with log messages.")
// TODO(bkonyi): when authentication codes are enabled by default, change
// to 'disable-service-auth-codes' instead of 'enable-service-auth-codes'.
DEF_SWITCH(EnableServiceAuthCodes,
"enable-service-auth-codes",
"Enable the requirement for authentication codes for communicating"
" with the VM service.")
DEF_SWITCH(StartPaused,
"start-paused",
"Start the application paused in the Dart debugger.")
......
......@@ -297,6 +297,9 @@ public final class FlutterActivityDelegate
if (intent.getBooleanExtra("start-paused", false)) {
args.add("--start-paused");
}
if (intent.getBooleanExtra("enable-service-auth-codes", false)) {
args.add("--enable-service-auth-codes");
}
if (intent.getBooleanExtra("use-test-fonts", false)) {
args.add("--use-test-fonts");
}
......
......@@ -27,6 +27,8 @@ public class FlutterShellArgs {
public static final String ARG_TRACE_STARTUP = "--trace-startup";
public static final String ARG_KEY_START_PAUSED = "start-paused";
public static final String ARG_START_PAUSED = "--start-paused";
public static final String ARG_KEY_ENABLE_SERVICE_AUTH_CODES = "enable-service-auth-codes";
public static final String ARG_ENABLE_SERVICE_AUTH_CODES = "--enable-service-auth-codes";
public static final String ARG_KEY_USE_TEST_FONTS = "use-test-fonts";
public static final String ARG_USE_TEST_FONTS = "--use-test-fonts";
public static final String ARG_KEY_ENABLE_DART_PROFILING = "enable-dart-profiling";
......@@ -56,6 +58,11 @@ public class FlutterShellArgs {
if (intent.getBooleanExtra(ARG_KEY_START_PAUSED, false)) {
args.add(ARG_START_PAUSED);
}
// TODO(bkonyi): when authentication codes are enabled by default, change
// to 'disable-service-auth-codes' instead of 'enable-service-auth-codes'.
if (intent.getBooleanExtra(ARG_KEY_ENABLE_SERVICE_AUTH_CODES, false)) {
args.add(ARG_ENABLE_SERVICE_AUTH_CODES);
}
if (intent.getBooleanExtra(ARG_KEY_USE_TEST_FONTS, false)) {
args.add(ARG_USE_TEST_FONTS);
}
......@@ -133,4 +140,4 @@ public class FlutterShellArgs {
String[] argsArray = new String[args.size()];
return args.toArray(argsArray);
}
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册