8000 Add {secure:} opt to protocol.registerStandardSchemes by pfrazee · Pull Request #7947 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add {secure:} opt to protocol.registerStandardSchemes #7947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

pfrazee
Copy link
Contributor
@pfrazee pfrazee commented Nov 11, 2016

This PR replaces #7671. It will:

  • Add a second arg to registerStandardSchemes, which is an optional object where you can specify { secure: true } to enable secure registration. Update protocol.registerStandardSchemes to register a scheme as secure on the browser side, and to propagate that registration to renderers.
  • Add deprecation notices to webFrame.registerURLSchemeAsSecure and webFrame.registerURLSchemeAsPrivileged

Still in progress. I'm opening this PR to discuss the changes while I work.

@pfrazee
Copy link
Contributor Author
pfrazee commented Nov 11, 2016

I'll need some help on this -

I was having difficulty writing the tests, so I decided to run a demo app and just check the DevTools. I looked at the Security tab and got:

screen shot 2016-11-11 at 1 13 38 pm

So, for reference, I went back to my custom build of electron (in which I do have #7671 merged) and added webFrame.registerURLSchemeAsPrivileged to the demo. However, the devtools security tab still shows Insecure.

So, I'm wondering if even the current master, and my custom build, are missing a step for correctly registering a protocol as secure. Any thoughts?

@deepak1556
Copy link
Member
deepak1556 commented Nov 12, 2016

The devtools panel security info is not standard, currently only valid HTTPS schemes are considered secure https://cs.chromium.org/chromium/src/components/security_state/security_state_model.h?l=38-66 .

You can test if origin is registered as secure by trying to use cachestorage api, the renderer will terminate throw error if the origin is not secure.

@pfrazee
Copy link
Contributor Author
pfrazee commented Nov 12, 2016

Ah, very good, thank you

@pfrazee
Copy link
Contributor Author
pfrazee commented Nov 14, 2016

How should the deprecations be handled? Do I remove the code and put a deprecation notice on the docs?

@MarshallOfSound
Copy link
Member

@pfrazee Someone can confirm this ( @kevinsawicki ) but I believe the way we currently do it is leave the deprecated method in. Add a console warning that it is deprecated. Remove it from the docs. And add a // TODO in the code to remove it entirely in the next major bump.

@pfrazee
Copy link
Contributor Author
pfrazee commented Nov 14, 2016

Ok, this is RFR

@pfrazee pfrazee changed the title Add {secure:} opt to protocol.registerStandardSchemes (WIP) Add {secure:} opt to protocol.registerStandardSchemes Nov 14, 2016
// Register scheme to secure list (https, wss, data).
blink::WebSecurityPolicy::registerURLSchemeAsSecure(
blink::WebString::fromUTF8(scheme));
std::cout << "webFrame.registerURLSchemeAsSecure is deprecated. Use protocol.registerStandardSchemes with {secure:true}" << std::endl;
Copy link
Member
@deepak1556 deepak1556 Nov 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can move the deprecations to lib/renderer/api/web-frame.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, wrap the methods there so that they log?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pfrazee can this be removed and just documented in the planned breaking changes doc?

// Deprecated
webFrame.registerURLSchemeAsSecure('app')
// Replace with
protocol.registerStandardSchemes('app', {secure: true})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protocol.registerStandardSchemes accepts only array of scheme(s).

@kevinsawicki
Copy link
Contributor

Add deprecation notices to

We haven't really formally deprecated (meaning adding logged messages) any 2.0 APIs yet.

I think it is okay for now to just add a TODO comment like this one and add an entry to planned-breaking-changes.md.

Then when we are closer to having a 2.0 API plan, we can add deprecation logging to all the needed areas.

@pfrazee
Copy link
Contributor Author
pfrazee commented Nov 16, 2016

Ok, I fixed the documentation. That should cover it.

@pfrazee
Copy link
Contributor Author
pfrazee commented Dec 1, 2016 via email

@pfrazee
Copy link
Contributor Author
pfrazee commented Dec 11, 2016

Ok, just had a moment to make the requested change. Done

@kevinsawicki kevinsawicki self-assigned this Dec 12, 2016
@@ -31,6 +31,9 @@ class AtomContentClient : public brightray::ContentClient {
std::vector<content::PepperPluginInfo>* plugins) override;
void AddServiceWorkerSchemes(
std::set<std::string>* service_worker_schemes) override;
void AddSecureSchemesAndOrigins(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still used? I'm not seeing references to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's called by chromium or brightray code. I confirmed by removing it and running tests, which then failed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't see the override 👍

@@ -4,6 +4,8 @@

#include "atom/renderer/api/atom_api_web_frame.h"

E7F5 #include <iostream>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

std::vector<std::string> ParseSchemesCLISwitch(const char* switch_name) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
std::string custom_schemes = command_line->GetSwitchValueASCII(switch_name);
if (!custom_schemes.empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base::SplitString should handle empty strings so I don't think we need this check here.

std::vector<std::string> schemes;
ConvertStringWithSeparatorToVector(&schemes, ",",
switches::kSecureSchemes);
if (!schemes.empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this check would be okay to remove since the for loop should handle an empty schemes vector fine.

@kevinsawicki kevinsawicki force-pushed the register-standard-secure-schemes branch from fe15477 to cac85d2 Compare December 12, 2016 20:52
@kevinsawicki
Copy link
Contributor

Fixed a few linter warnings and rebased to resolve the planned-breaking-changes.md conflict.

Thanks @pfrazee for this 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0