Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
69547375
Commit
69547375
authored
Jun 27, 2015
by
Petrus J.v.Rensburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auth & Perms: Rollong your own. Using Flask Security.
parent
4dd02a96
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
1 deletion
+43
-1
authorisation_and_permissions.rst
doc/authorisation_and_permissions.rst
+43
-1
No files found.
doc/authorisation_and_permissions.rst
View file @
69547375
...
@@ -6,7 +6,7 @@ HTTP Basic Auth
...
@@ -6,7 +6,7 @@ HTTP Basic Auth
The simplest form of authentication is HTTP Basic Auth. It doesn't interfere
The simplest form of authentication is HTTP Basic Auth. It doesn't interfere
with your database models, and it doesn't require you to write any new view logic or
with your database models, and it doesn't require you to write any new view logic or
template code. So it's great for when you're deploying something that's still
template code. So it's great for when you're deploying something that's still
under development,
when you don't want the whole world to see it just ye
t.
under development,
before you want the whole world to see i
t.
Have a look at `Flask-BasicAuth <http://flask-basicauth.readthedocs.org/>`_ to see how
Have a look at `Flask-BasicAuth <http://flask-basicauth.readthedocs.org/>`_ to see how
easy it is to put your whole application behind HTTP Basic Auth.
easy it is to put your whole application behind HTTP Basic Auth.
...
@@ -15,7 +15,49 @@ Unfortunately, there's no easy way of applying HTTP Basic Auth just to your admi
...
@@ -15,7 +15,49 @@ Unfortunately, there's no easy way of applying HTTP Basic Auth just to your admi
interface.
interface.
Rolling your own
--------------------------------
For a more polished access control & permission handling experience, you could
write it yourself if you need to have total control over the functionality. Here,
a low-level library like
`Flask-Login <https://flask-login.readthedocs.org/>`_ could make your life
a bit easier.
If you like this approach, have a look at the example at
https://github.com/flask-admin/Flask-Admin/tree/master/examples/auth-flask-login
to get started.
Using Flask-Security
Using Flask-Security
--------------------------------
--------------------------------
If you want a lot of functionality for little effort: you could
use `Flask-Security <https://pythonhosted.org/Flask-Security/>`_,
which is a higher-level library. It comes with lots of builtin views for doing common things like confirming
email addresses, resetting passwords, etc.
The complicated bit, is making the builtin Flask-Security views work together with the
Flask-Admin templates, to create a consistent experience for your users. In order to
do this, you will need to override the builtin Flask Security templates and have them
extend the Flask-Admin base template. To do this, just add the following to the top
of each template::
{% extends 'admin/master.html' %}
Now, you'll need to manually pass in some context variables for the Flask Admin
templates to render correctly when they're being called from the Flask-Security views.
This could look something like::
def security_context_processor():
return dict(
admin_base_template=admin.base_template,
admin_view=admin.index_view,
h=admin_helpers,
)
For a working example of using Flask-Security with Flask-Admin, have a look at
https://github.com/flask-admin/Flask-Admin/tree/master/examples/auth.
The example only uses the builtin `register` and `login` views, but you could follow the same
approach for including the other views, like `forgot_password`, `send_confirmation`, etc.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment