Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
insights
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
insights
Commits
609796ae
Commit
609796ae
authored
Jul 29, 2013
by
Felix Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The DJA_AUTH setting now accepts strings that represent auth decorators,
in addition to the actual auth decorator functions.
parent
507b403a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
src/edinsights/core/auth.py
+7
-3
No files found.
src/edinsights/core/auth.py
View file @
609796ae
...
...
@@ -8,8 +8,7 @@ DJA_AUTH setting maps function names to authentication decorators. For
example, to require all edinsights URLs to have a login, add the
following to settings.py:
import django.contrib.auth.decorators
DJA_AUTH = { '.*' : django.contrib.auth.decorators.login_required }
DJA_AUTH = { '.*' : 'django.contrib.auth.decorators.login_required' }
The goal of this is to, for example, be able to add login_required for
views, but some kind of secret key authentication for queries, and
...
...
@@ -19,6 +18,7 @@ likely to be by the time you read this).
'''
from
django.conf
import
settings
from
django.core.urlresolvers
import
get_callable
import
re
def
auth
(
f
):
...
...
@@ -37,6 +37,10 @@ def auth(f):
for
key
in
dja
:
if
re
.
match
(
key
,
f
.
func_name
):
return
dja
[
key
](
f
)
if
type
(
dja
[
key
])
==
str
:
wrapper
=
get_callable
(
dja
[
key
])
else
:
wrapper
=
dja
[
key
]
return
wrapper
(
f
)
return
f
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