-
Notifications
You must be signed in to change notification settings - Fork 237
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
Add feature to manage plugins without using the command line #1824
Add feature to manage plugins without using the command line #1824
Conversation
c005231
to
e92dec7
Compare
5d12e9d
to
4d2e991
Compare
f6e861a
to
7d3d2d8
Compare
2b4e38d
to
74b1297
Compare
2fbfeac
to
019079b
Compare
@BenSurgisonGDS thanks for the demo earlier, this is coming along well. I've been thinking a bit more about the security of this. I'm thinking about the fact that this feature lets the user install code onto their machine, and could be used by third parties to install code on to the users' machine. At the moment, a user could click a link on an external website, and the kit would immediately start installing the plugin. The user may not necessarily know or expect that based on the text of the link, and would have no way to cancel the action if they weren't expecting or didn't want the change. I know that at the moment we have some protection because we only install packages from our list, but that might not stay the case in future, and it's generally better to be prudent now. I’d like to see this feature to have the following restriction: if someone clicks a link to install a plugin from outside the kit, or types a URL into the browser, they will see an ‘are you sure?’ page to confirm (I think we can keep it so that if they click the existing button from the kit website they don’t see that page). I think we can do this by a) requiring that a POST is made before the JavaScript kicks in and b) use some kind of CSRF mitigation to ensure the POST request is coming from the kit website (preferably the synchronizer token pattern) [1]. We should also have tests that check we can't install a plugin with a link without first getting user authorization. |
We just met about this, I think the outcome was it was easier to show everyone the page with the button on it, regardless of how they got there. I've added to the Figma: |
d1e9362
to
98ee821
Compare
found a tutorial to do csrf by hand, might be helpful: |
We've decided to go with the csurf package for our CSRF token middleware. Although it is deprecated [1], we could not find any well-supported alternative or single fork that has been chosen by the community (a large number of projects, including new projects, still rely on Because the code is stable and has been for 3 years, and there are no known vulnerabilities that would affect our use case, the risk of using the deprecated library is in my opinion lower than the risk of picking an alternative or a fork that is more liable to change. There is possibly a greater risk of hijacking of the An alternative would be to create our own fork of Note: there is a known vulnerability in the implementation of the double submit cookie pattern implementation in |
All the above now implemented. |
791b32e
to
9885dbe
Compare
da05e0b
to
9885dbe
Compare
bcea70e
to
5c6e56c
Compare
const show = (id) => document.getElementById(id) | ||
.classList.remove('govuk-!-display-none') | ||
|
||
const hide = (id) => document.getElementById(id) | ||
.classList.add('govuk-!-display-none') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be preferable to use the hidden
attribute instead of a CSS class, that way the page is more likely to look correct if the stylesheets haven't loaded or have been overridden for some reason.
Currently without stylesheets the page to install a plugin will read:
Install Step By Step from GOV.UK Prototype Kit
In terminal, press ctrl + c to stop your prototype, then run:
npm install @govuk-prototype-kit/step-by-step
When you've installed the plugin, restart your prototype in the terminal by typing:
npm run dev
Install
Installing ...
Install complete
There was a problem installing
[Please contact support](https://prototype-kit.service.gov.uk/docs/support)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this page would work without CSS (in fact it does, if you click the button! You just can't tell from the browser...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hidden attribute works when it ia done on a div so I have wrapped the confirmation button in a div to make it work with only the hidden attribute. Css is now unnecessary for this functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed using the hidden attribute and some small markup changes
8365654
to
e7f9fcf
Compare
lib/nunjucks/govuk-prototype-kit/internal/views/manage-prototype/plugins.njk
Outdated
Show resolved
Hide resolved
eea8a38
to
4dbe57f
Compare
Seems to be a problem in Safari on Mac, the process does not start automatically but instead shows the install button. Thats not a blocking issue so happy to raise it separately if you prefer. |
...nunjucks/govuk-prototype-kit/internal/views/manage-prototype/plugin-install-or-uninstall.njk
Outdated
Show resolved
Hide resolved
Yes, please raise separately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome! Great work all round
Handle user pressing refresh in plugin confirmation page Add CSRF protection Added warning when plugin action button is shown Replace css with the hidden attribute Convert button markup to use nunjucks macros Add some console logging for plugin install status
0a68f92
to
432cb46
Compare
See: Design and build a means to automatically install, upgrade, and uninstall a plugin with a push of a button