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
ba8b0bc3
Commit
ba8b0bc3
authored
Jun 27, 2015
by
Petrus J.v.Rensburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auth & Perms: improve wording.
parent
69547375
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
14 deletions
+24
-14
authorisation_and_permissions.rst
doc/authorisation_and_permissions.rst
+24
-14
No files found.
doc/authorisation_and_permissions.rst
View file @
ba8b0bc3
Authorisation & Permissions
Authorisation & Permissions
=================================
=================================
When setting up an admin interface for your application, one of the first problems
you'll want to solve is how to keep unwanted users out. With Flask-Admin there
are a few different ways of approaching this.
HTTP Basic Auth
HTTP Basic Auth
------------------------
------------------------
...
@@ -14,32 +17,39 @@ easy it is to put your whole application behind HTTP Basic Auth.
...
@@ -14,32 +17,39 @@ easy it is to put your whole application behind HTTP Basic Auth.
Unfortunately, there's no easy way of applying HTTP Basic Auth just to your admin
Unfortunately, there's no easy way of applying HTTP Basic Auth just to your admin
interface.
interface.
Rolling your own
Rolling your own
--------------------------------
--------------------------------
For a more polished access control & permission handling experience, you could
For a finer-grained solution, Flask-Admin lets you define access control rules
write it yourself if you need to have total control over the functionality. Here,
on each of your admin view classes by simply overriding the `is_accessible` method.
a low-level library like
How you implement the logic is up to you, but if you were to use a low-level library like
`Flask-Login <https://flask-login.readthedocs.org/>`_ could make your life
`Flask-Login <https://flask-login.readthedocs.org/>`_, then restricting access to a set of views
a bit easier.
could be as simple as::
class MyModelView(sqla.ModelView):
def is_accessible(self):
return login.current_user.is_authenticated()
However, you would still need to implement all of the relevant login /
registration views yourself.
If you like this approach, have a look at the example at
If you like this approach,
then
have a look at the example at
https://github.com/flask-admin/Flask-Admin/tree/master/examples/auth-flask-login
https://github.com/flask-admin/Flask-Admin/tree/master/examples/auth-flask-login
to get started.
to get started.
Using Flask-Security
Using Flask-Security
--------------------------------
--------------------------------
If you want
a lot of functionality for little effort:
you could
If you want
to get started quicker,
you could
use `Flask-Security <https://pythonhosted.org/Flask-Security/>`_,
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
which is a higher-level library. It comes with lots of builtin views for doing
email addresses, resetting password
s, etc.
common things like registration, login, email address confirmation, password reset
s, etc.
The complicated bit, is making the builtin Flask-Security views work together with the
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 t
o
Flask-Admin templates, to create a consistent experience for your users.
T
o
do this, you will need to override the builtin Flask
Security templates and have them
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
extend the Flask-Admin base template
by adding
the following to the top
of each
templat
e::
of each
fil
e::
{% extends 'admin/master.html' %}
{% extends 'admin/master.html' %}
...
...
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