Skip to content
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

Adds custom proxy access dialog #382

Merged
merged 13 commits into from
Feb 19, 2018

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented Feb 13, 2018

  • window.confirm is not supported when called from a background script in Firefox
  • We need a mechanism to grant allow/deny to all permissions for a given origin

screen shot 2018-02-13 at 15 55 25

screen shot 2018-02-13 at 15 53 25

resolves #377

<p class="sans-serif f6 lh-copy charcoal-muted">
<label>
<input type="checkbox" checked=${state.remember} onclick=${onRememberToggle} class="mr1" />
Apply to all permissions for ${origin}
Copy link
Member

Choose a reason for hiding this comment

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

Does Apply to all IPFS API permissions for sound better or worse?
(It is more clear to me, but I am non-native speaker, so.. 🙃 )

@@ -72,7 +72,7 @@
"sinon": "4.1.2",
"sinon-chrome": "2.2.1",
"standard": "10.0.3",
"uglifyify": "^4.0.5",
"uglifyify": "4.0.5",
Copy link
Member

Choose a reason for hiding this comment

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

@alanshaw I think you forgot to update yarn.lock. If I run npm run yarn-build it modifies it:

--- a/yarn.lock
+++ b/yarn.lock
@@ -4374,7 +4374,7 @@ ipfs-block@^0.6.1, ipfs-block@~0.6.1:
   dependencies:
     cids "^0.5.2"
 
-ipfs-css@^0.1.0:
+ipfs-css@0.1.0:
   version "0.1.0"
   resolved "https://registry.yarnpkg.com/ipfs-css/-/ipfs-css-0.1.0.tgz#0337e7e3aeddf391bbd1b7b7fb427f98b6ec5ca3"
 
@@ -9315,7 +9315,7 @@ uglify-to-browserify@~1.0.0:
   version "1.0.2"
   resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"
 
-uglifyify@^4.0.5:
+uglifyify@4.0.5:
   version "4.0.5"
   resolved "https://registry.yarnpkg.com/uglifyify/-/uglifyify-4.0.5.tgz#49c1fca9828c10a5a8e8d70f191a95f7ab475911"
   dependencies:

This is why Jenkins failed:

@lidel lidel added this to the 2018-Q1 milestone Feb 13, 2018
@lidel lidel added the UX label Feb 13, 2018
@alanshaw
Copy link
Member Author

When you check the checkbox I'm implementing something like this:

{
  origin: { '*': true }
}

Usually it would look like:

{
  origin: { 'files.add': true, 'object.new': false /* ... */ }
}

There's some nuances to * that I'd like to discuss before continuing:

  1. What happens when we set access to *?

    • Does it remove any existing permissions that have been granted? e.g. if I've already approved files.add and then I am asked about another permission for which I check the checkbox and click allow, does my permission object then look like { 'files.add': true, '*': true } or { '*': true }?

    • If it removes all existing permissions, what happens if I try to set a specific grant? e.g. if I have { '*': true } and then set granted access to files.add to false should that fail or add the new grant? This is sort of hypothetical, because there's no way in the UI you can do this currently.

  2. What happens when we get granted access to a permission when * exists?

    • If a * grant exists is that the granted permission that the user gets or if there is a more specific permission, should that be returned instead? e.g. { '*': true, 'files.add': false } - what happens when I try to get granted access to files.add - do I get true or false?

Right now I'm leaning towards when you set * it removes all existing access grants and if you try to set a more specific access grant it fails - you can't set files.add: false if *: true (incidentally set files.add: true if *: true is a noop). Since this most closely matches the UX i.e. the fail will never happen as there is no UI for the user to add a more specific grant if * is already granted.

@olizilla
Copy link
Member

Setting "allow all", I think it should remove more specific permissions, and just store { '*': true }.

If you hypothetically try to set a more specific permission, when { '*': true } is set, then I'd be fine with that being a no-op, in as much as, the the existing permissions already allow what you're asking for, so change nothing in the acl and say ok to the user.

If it should never be possible to set a more specific permission when a wildcard is already set, then an error would be appropriate. Right now that feels like an implicit rule just because of the way the ui is structured, but I don't think it's a rule we really care about.

@alanshaw
Copy link
Member Author

alanshaw commented Feb 15, 2018

@lidel @olizilla @victorbjelkholm fonts from ipfs-css are not yet working but the main body of work here is done and I'd like to get some eyes on it so we can get it merged. Could you please take a look?

I'll send a separate PR for getting the fonts working.

EDIT: fonts are in and working

@alanshaw alanshaw changed the title [WIP] Adds custom proxy access dialog Adds custom proxy access dialog Feb 15, 2018
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Thank you @alanshaw, it is 👌 Awesome work! Works beautifully under Firefox 🚀

Is it ready to merge on your end? If so, see my 2 bikeshedding comments below.

ps. While testing this I noticed (unrelated) CSP warning and fixed it – just fetch my commits.

.gitignore Outdated
@@ -11,3 +11,5 @@ crowdin.yml
add-on/dist
coverage
.nyc_output
add-on/fonts/*
add-on/*.css
Copy link
Member

Choose a reason for hiding this comment

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

Let's move 3rd-party stuff copied from ipfs-css and tachyons (fonts, css) into separate namespace, eg. add-on/ui-kit/ or something like that.

Copy link
Member Author

Choose a reason for hiding this comment

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

👌

Copy link
Member

Choose a reason for hiding this comment

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

Note to self: our landing page (#324, #326) will re-use styles and fonts, eventually

const { allow } = await requestAccess(origin, permission)
access = await accessControl.setAccess(origin, permission, allow)
const { allow, remember } = await requestAccess(origin, permission)
access = await accessControl.setAccess(origin, remember ? '*' : permission, allow)
Copy link
Member

Choose a reason for hiding this comment

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

Took me a moment to get it.. remember does not seem to be a good description for what is happening here :)
Perhaps wildcard would be a more intuitive name than remember?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@alanshaw
Copy link
Member Author

@lidel good to merge?

@lidel lidel merged commit 88eebce into ipfs:master Feb 19, 2018
@alanshaw alanshaw deleted the feat/custom-proxy-access-dialog branch February 19, 2018 15:05
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.

Custom dialog for window.ipfs ACLs (make it work under Firefox)
3 participants