Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
e1eb23df
Commit
e1eb23df
authored
Oct 28, 2016
by
Edward Fagin
Committed by
GitHub
Oct 28, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13774 from edx/efagin/auth-logging
Add logging when header permissions in use.
parents
cd62fc39
dc4150ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
openedx/core/lib/api/permissions.py
+13
-4
No files found.
openedx/core/lib/api/permissions.py
View file @
e1eb23df
...
...
@@ -10,6 +10,8 @@ from opaque_keys import InvalidKeyError
from
opaque_keys.edx.keys
import
CourseKey
from
student.roles
import
CourseStaffRole
,
CourseInstructorRole
from
openedx.core.lib.log_utils
import
audit_log
class
ApiKeyHeaderPermission
(
permissions
.
BasePermission
):
"""
...
...
@@ -26,10 +28,17 @@ class ApiKeyHeaderPermission(permissions.BasePermission):
present in the request and matches the setting.
"""
api_key
=
getattr
(
settings
,
"EDX_API_KEY"
,
None
)
return
(
(
settings
.
DEBUG
and
api_key
is
None
)
or
(
api_key
is
not
None
and
request
.
META
.
get
(
"HTTP_X_EDX_API_KEY"
)
==
api_key
)
)
if
settings
.
DEBUG
and
api_key
is
None
:
return
True
elif
api_key
is
not
None
and
request
.
META
.
get
(
"HTTP_X_EDX_API_KEY"
)
==
api_key
:
audit_log
(
"ApiKeyHeaderPermission used"
,
path
=
request
.
path
,
ip
=
request
.
META
.
get
(
"REMOTE_ADDR"
))
return
True
return
False
class
ApiKeyHeaderPermissionIsAuthenticated
(
ApiKeyHeaderPermission
,
permissions
.
IsAuthenticated
):
...
...
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