Open lb- opened 10 months ago
If we're going to include a password generator, we should make sure it works and is secure. window.crypto
tends to only work in secure contexts (eg HTTPS and localhost
), which might be an issue for some. Also, it would need to interact with Django's password validator framework, which is going to be quite complex.
Alternatively, we could link out to a password generator: https://bitwarden.com/password-generator/, at least in the first instance.
Or, final option, we do "Leave blank to generate a secure password", and defer the generation to the backend instead.
We could make a server side call if needed.
However I suggested the getRandomValues
intentionally as it doesn't require secure context.
https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
As for the interaction with the password validation, I think we would just have to disable the generator if that feature is used.
Is your proposal related to a problem?
This is part of a set of improvements to help improve the way that the Private access (shared password method) works. See https://github.com/wagtail/wagtail/issues/10588
We want to make it easier for users to choose more secure values for this shared password, making it harder to guess and also gain access to easily with over the shoulder viewing of editors.
Describe the solution you'd like
Add the ability to generate a randomized string and also copy the value to the clipboard easily. Example screenshot below.
This would involve;
client/src/controllers/ActionController.ts
(ActionController) with the ability to create a random value.ActionController
to support it's actions targeting a specific element with a custom selector value.ClipboardController
for this field to support easy copy to clipboard behaviour. You can see how this is used in https://github.com/wagtail/wagtail/pull/11317 & https://github.com/wagtail/wagtail/issues/3683 & the code snippet below.https://github.com/wagtail/wagtail/blob/54802abcc4a264fc62f1ddaa846f679521850be2/wagtail/images/templates/wagtailimages/images/url_generator.html#L34-L48
Important: It may make more sense to add this behaviour to the
SlugController
and rename that controller to something likeCleanController
(for cleaning/modifying field input values). Generally the change will be the same, have a read and provide thoughts in the comments.ActionController
- adding a new valueThis controller is a bit of a toolkit controller, it let's us perform some kind of simple action on a button or input with Stimulus easily.
We will want to abstract the ability to get the most suitable target element. Read up on Stimulus values and actions if you are not sure what's happening here.
From there, we should really update all other methods to use this. e.g.
The other methods will be a bit more complex but not too much more.
ActionController
- Add aunique
method.This would be very similar to
reset
on the ActionController but use a way to generate a set of unique values and output them as a string.We would want to dispatch a change event also.
Describe alternatives you've considered
Multiple discussions have been had on https://github.com/wagtail/wagtail/issues/10588
Additional context
Working on this