Add Admin Reset Password Capability
Administrators should be able to reset users' passwords
You should be able to do that from the fabmanager cli.
OK - administrators should be able to reset users' passwords in Superset's UI
Shouldn't users be able to reset that on their own?
If a user forgets their password, an admin should be able to reset it via the UI
Would be great to be able to change user's passwords via the UI. Admins can create users with new passwords via the UI and it would make sense to allow creating a new password as well.
The best place for these features would be in Flask App Builder itself, we regularly update our dependencies to use the latest FAB.
currently available in the menu below. "Security > List Users > Show record > Reset Password"
OR customizing if you want to edit on page "Edit record"
-
views.py
from werkzeug.datastructures import ImmutableMultiDict from werkzeug.security import generate_password_hash from flask_appbuilder.security.views import UserDBModelView from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget from wtforms.validators import EqualTo from wtforms import PasswordField from flask_babel import lazy_gettext class MyUserDBModelView(UserDBModelView): __class__ = UserDBModelView edit_form_extra_fields = {'password': PasswordField(lazy_gettext('Password'), description=lazy_gettext( 'Please use a good password policy, this application does not check this for you'), #validators=[validators.DataRequired()], widget=BS3PasswordFieldWidget()), 'conf_password': PasswordField(lazy_gettext('Confirm Password'), description=lazy_gettext( 'Please rewrite the user\'s password to confirm'), validators=[EqualTo('password', message=lazy_gettext( 'Passwords must match'))], widget=BS3PasswordFieldWidget())} edit_columns = ['first_name', 'last_name', 'username', 'active', 'email', 'roles', 'password', 'conf_password'] stat = type('', (object,), { 'none': 0, 'use': 1, 'notuse': 2 })() def __init__(self, **kwargs): super(MyUserDBModelView, self).__init__(**kwargs) self.edit_form.refresh = MyUserDBModelView.wrap_refresh(self, self.edit_form.refresh) @staticmethod def wrap_refresh(self, wfunc): wfunc = wfunc.__func__ def _w(*args, **kwargs): pw = None s = self.stat.none obj = args[1] if len(args) >= 2 else None if isinstance(obj, ImmutableMultiDict): pw = obj.get('password', None) cpw = obj.get('conf_password', None) if pw and cpw: pw = pw.strip() cpw = cpw.strip() if pw and cpw and pw == cpw: s = self.stat.use pw = generate_password_hash(pw) else: s = self.stat.notuse form = wfunc(*args, **kwargs) if s == self.stat.use: form._fields.get('password').process_data(pw) form._fields.get('conf_password').process_data(pw) elif s == self.stat.notuse: form._fields.pop('password') form._fields.pop('conf_password') return form return classmethod(_w) -
security.py
from superset.security import SupersetSecurityManager from .views import MyUserDBModelView class MySecurityManager(SupersetSecurityManager): userdbmodelview = MyUserDBModelView -
config.py
CUSTOM_SECURITY_MANAGER = MySecurityManager