diff --git a/yubiadmin/apps/auth.py b/yubiadmin/apps/auth.py index 77bb105..7aa53a7 100644 --- a/yubiadmin/apps/auth.py +++ b/yubiadmin/apps/auth.py @@ -71,6 +71,7 @@ auth_config = FileConfig( ('hsm_device', python_handler('YHSM_DEVICE', 'yhsm://localhost:5348')), ('db_config', python_handler('DATABASE_CONFIGURATION', 'sqlite:///:memory:')), + ('user_registration', python_handler('ENABLE_USER_REGISTRATION', True)) ] ) @@ -99,7 +100,14 @@ class SecurityForm(ConfigForm): 'Allow Empty Passwords', description=""" Allow users with no password to log in without providing a password. - When set to False, a user with no password will be unable to log in. + When not checked, a user with no password will be unable to log in. + """ + ) + user_registration = BooleanField( + 'Enable User Registration', + description=""" + Allow users to register themselves using the YubiAuth client interface. + When checked, accounts can be created Here. """ ) security_level = SelectField( @@ -326,9 +334,10 @@ class YubiAuthUsers(CollectionApp): 'YubiKeys': ', '.join(user.yubikeys.keys()) }, users) - def _select(self, ids): - return self.auth.session.query(self.User.name, self.User.id) \ + def _labels(self, ids): + users = self.auth.session.query(self.User.name) \ .filter(self.User.id.in_(map(int, ids))).all() + return map(lambda x: x[0], users) def _delete(self, ids): self.auth.session.query(self.User) \ diff --git a/yubiadmin/templates/table_delete.html b/yubiadmin/templates/table_delete.html index 904d109..d051c73 100644 --- a/yubiadmin/templates/table_delete.html +++ b/yubiadmin/templates/table_delete.html @@ -1,8 +1,8 @@ Confirm deletion

Are you sure you wish to delete the following {{ item_name | lower }}?

diff --git a/yubiadmin/util/app.py b/yubiadmin/util/app.py index 90650d0..4927eb7 100644 --- a/yubiadmin/util/app.py +++ b/yubiadmin/util/app.py @@ -136,8 +136,8 @@ class CollectionApp(App): def _get(self, offset=0, limit=None): return [{}] - def _select(self, ids): - return [x for x in self._get() if x['id'] in ids] + def _labels(self, ids): + return [x['label'] for x in self._get() if x['id'] in ids] def _delete(self, ids): raise Exception('Not implemented!') @@ -181,8 +181,8 @@ class CollectionApp(App): def delete(self, request): ids = [x[5:] for x in request.params if request.params[x] == 'on'] - items = self._select(ids) - return render('table_delete', ids=','.join(ids), items=items, + labels = self._labels(ids) + return render('table_delete', ids=','.join(ids), labels=labels, item_name=self.item_name, base_url=self.base_url) def delete_confirm(self, request):