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
b5833775
Commit
b5833775
authored
May 24, 2015
by
Petrus J.v.Rensburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new 'auth' example, using Flask-Security.
parent
15581d05
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
141 additions
and
192 deletions
+141
-192
app.py
examples/auth/app.py
+87
-158
config.py
examples/auth/config.py
+25
-0
requirements.txt
examples/auth/requirements.txt
+1
-1
index.html
examples/auth/templates/admin/index.html
+21
-31
my_master.html
examples/auth/templates/my_master.html
+7
-2
No files found.
examples/auth/app.py
View file @
b5833775
This diff is collapsed.
Click to expand it.
examples/auth/config.py
0 → 100644
View file @
b5833775
# Create dummy secrey key so we can use sessions
SECRET_KEY
=
'123456790'
# Create in-memory database
DATABASE_FILE
=
'sample_db.sqlite'
SQLALCHEMY_DATABASE_URI
=
'sqlite:///'
+
DATABASE_FILE
SQLALCHEMY_ECHO
=
True
# Flask-Security config
SECURITY_URL_PREFIX
=
"/admin"
SECURITY_PASSWORD_HASH
=
"pbkdf2_sha512"
SECURITY_PASSWORD_SALT
=
"ATGUOHAELKiubahiughaerGOJAEGj"
# Flask-Security URLs, overridden because they don't put a / at the end
SECURITY_LOGIN_URL
=
"/login/"
SECURITY_LOGOUT_URL
=
"/logout/"
SECURITY_REGISTER_URL
=
"/register/"
SECURITY_POST_LOGIN_VIEW
=
"/admin/"
SECURITY_POST_LOGOUT_VIEW
=
"/admin/"
SECURITY_POST_REGISTER_VIEW
=
"/admin/"
# Flask-Security features
SECURITY_REGISTERABLE
=
True
SECURITY_SEND_REGISTER_EMAIL
=
False
\ No newline at end of file
examples/auth/requirements.txt
View file @
b5833775
Flask
Flask-Admin
Flask-SQLAlchemy
Flask-
Login
Flask-
Security==1.7.4
\ No newline at end of file
examples/auth/templates/admin/index.html
View file @
b5833775
...
...
@@ -3,37 +3,27 @@
{{ super() }}
<div
class=
"row-fluid"
>
<div>
{% if current_user.is_authenticated() %}
<h1>
Flask-Admin example
</h1>
<p
class=
"lead"
>
Authentication
</p>
<p>
This example shows how you can use Flask-Login for authentication. It is only intended as a basic demonstration.
</p>
{% else %}
<form
method=
"POST"
action=
""
>
{{ form.hidden_tag() if form.hidden_tag }}
{% for f in form if f.type != 'CSRFTokenField' %}
<div>
{{ f.label }}
{{ f }}
{% if f.errors %}
<ul>
{% for e in f.errors %}
<li>
{{ e }}
</li>
{% endfor %}
</ul>
{% endif %}
</div>
{% endfor %}
<button
class=
"btn"
type=
"submit"
>
Submit
</button>
</form>
{{ link | safe }}
{% endif %}
</div>
<div>
<h1>
Flask-Admin example
</h1>
<p
class=
"lead"
>
Authentication
</p>
<p>
This example shows how you can use Flask-Security for authentication.
</p>
{% if not current_user.is_authenticated() %}
<p>
You can register as a regular user, or log in as a superuser with the following credentials:
<ul>
<li>
email:
<b>
admin
</b></li>
<li>
password:
<b>
admin
</b></li>
</ul>
</p>
<p>
<a
class=
"btn btn-default"
href=
"{{ url_for('security.login') }}"
>
login
</a>
<a
class=
"btn btn-default"
href=
"{{ url_for('security.register') }}"
>
register
</a>
</p>
{% endif %}
</div>
<a
class=
"btn btn-primary"
href=
"/"
><i
class=
"icon-arrow-left icon-white"
></i>
Back
</a>
<a
class=
"btn btn-primary"
href=
"/"
><i
class=
"icon-arrow-left icon-white"
></i>
Back
</a>
</div>
{% endblock body %}
\ No newline at end of file
examples/auth/templates/my_master.html
View file @
b5833775
...
...
@@ -4,10 +4,15 @@
{% if current_user.is_authenticated() %}
<div
class=
"btn-group pull-right"
>
<a
class=
"btn dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"icon-user"
></i>
{{ current_user.login }}
<span
class=
"caret"
></span>
<i
class=
"icon-user"
></i>
{% if current_user.first_name -%}
{{ current_user.first_name }}
{% else -%}
{{ current_user.email }}
{%- endif %}
<span
class=
"caret"
></span>
</a>
<ul
class=
"dropdown-menu"
>
<li><a
href=
"{{ url_for('
admin.logout_view
') }}"
>
Log out
</a></li>
<li><a
href=
"{{ url_for('
security.logout
') }}"
>
Log out
</a></li>
</ul>
</div>
{% endif %}
...
...
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