mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-13 10:30:16 +00:00
bepasty: Require at least one permission on a password
- Since a password without any permissions is not useful. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
parent
8194628eb3
commit
028137a4e4
@ -44,7 +44,7 @@ def parse_arguments():
|
|||||||
|
|
||||||
setup = subparsers.add_parser(
|
setup = subparsers.add_parser(
|
||||||
'setup', help='Perform post-installation operations for bepasty')
|
'setup', help='Perform post-installation operations for bepasty')
|
||||||
setup.add_argument('--domain-name',
|
setup.add_argument('--domain-name', required=True,
|
||||||
help='The domain name that will be used by bepasty')
|
help='The domain name that will be used by bepasty')
|
||||||
|
|
||||||
subparsers.add_parser(
|
subparsers.add_parser(
|
||||||
@ -54,7 +54,7 @@ def parse_arguments():
|
|||||||
add_password = subparsers.add_parser(
|
add_password = subparsers.add_parser(
|
||||||
'add-password', help='Generate a password with given permissions')
|
'add-password', help='Generate a password with given permissions')
|
||||||
add_password.add_argument(
|
add_password.add_argument(
|
||||||
'--permissions', nargs='*',
|
'--permissions', nargs='+',
|
||||||
help='Any number of permissions from the set: {}'.format(', '.join(
|
help='Any number of permissions from the set: {}'.format(', '.join(
|
||||||
bepasty.PERMISSIONS.keys())))
|
bepasty.PERMISSIONS.keys())))
|
||||||
add_password.add_argument(
|
add_password.add_argument(
|
||||||
|
|||||||
@ -106,12 +106,9 @@ def list_passwords():
|
|||||||
return json.loads(output)
|
return json.loads(output)
|
||||||
|
|
||||||
|
|
||||||
def add_password(permissions=None, comment=None):
|
def add_password(permissions, comment=None):
|
||||||
"""Generate a password with given permissions"""
|
"""Generate a password with given permissions."""
|
||||||
command = ['add-password']
|
command = ['add-password', '--permissions'] + permissions
|
||||||
if permissions:
|
|
||||||
command += ['--permissions'] + permissions
|
|
||||||
|
|
||||||
if comment:
|
if comment:
|
||||||
command += ['--comment', comment]
|
command += ['--comment', comment]
|
||||||
|
|
||||||
|
|||||||
@ -24,8 +24,8 @@ class AddPasswordForm(forms.Form):
|
|||||||
|
|
||||||
permissions = forms.MultipleChoiceField(
|
permissions = forms.MultipleChoiceField(
|
||||||
choices=bepasty.PERMISSIONS.items(),
|
choices=bepasty.PERMISSIONS.items(),
|
||||||
widget=forms.CheckboxSelectMultiple, required=False,
|
widget=forms.CheckboxSelectMultiple, label=_('Permissions'),
|
||||||
label=_('Permissions'), help_text=_(
|
help_text=_(
|
||||||
'Users that log in with this password will have the selected '
|
'Users that log in with this password will have the selected '
|
||||||
'permissions.'))
|
'permissions.'))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user