Skip to content
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 admin panel #243

Merged
merged 10 commits into from
Dec 11, 2015
Merged

Add admin panel #243

merged 10 commits into from
Dec 11, 2015

Conversation

toolness
Copy link
Contributor

This PR adds an "Admin Panel" link to the user menu for qualified super-users:

user_menu

Clicking on it takes the administrator to a page where they can list/edit users and export them to CSV:

user_list

It also provides functionality to get some (currently undocumented) statistics:

stats

Implementation Notes

We use flask-admin for this.

We also need a way of tracking which users are admins and which aren't. For now we'll just use the ADMIN_UI_USERS config list for this, where each entry is the email of an admin user.

This PR also adds a is_admin() method to the User model which essentially returns whether the user's email is in ADMIN_UI_USERS.

Note that since we don't actually support email validation at present, admins will have to manually verify that the users associated with the emails in ADMIN_UI_USERS are actually who they claim to be.

To further prevent against malicious attempts to poke at these endpoints, ADMIN_UI_BASIC_AUTH can optionally be set to a string of the form username:password and HTTP Basic Authentication will protect everything under /admin/.


def scaffold_form(self):
form_class = super(UserModelView, self).scaffold_form()
form_class.email = TextField('Email')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More context on this at pallets-eco/flask-admin#1134.

@toolness toolness changed the title [WIP] Add admin panel Add admin panel Dec 11, 2015
toolness added a commit that referenced this pull request Dec 11, 2015
@toolness toolness merged commit 8e91c71 into master Dec 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant