Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-notes-api
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-notes-api
Commits
c475d4f0
Commit
c475d4f0
authored
Nov 19, 2014
by
Tim Babych
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Permission class for checking OAuth token
parent
693a9283
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
1 deletions
+38
-1
notesapi/v1/permissions.py
+14
-0
notesserver/settings/common.py
+21
-0
requirements/base.txt
+3
-1
No files found.
notesapi/v1/permissions.py
0 → 100644
View file @
c475d4f0
from
rest_framework.permissions
import
BasePermission
from
provider.oauth2.models
import
AccessToken
class
HasAccessToken
(
BasePermission
):
"""
Allow requests having valid AccessToken.
"""
def
has_permission
(
self
,
request
,
view
):
try
:
# expected HTTP Header "Authorization: Bearer TOKEN"
AccessToken
.
objects
.
get_token
(
request
.
META
[
"HTTP_AUTHORIZATION"
]
.
split
()[
1
])
return
True
except
AccessToken
.
DoesNotExist
:
return
False
notesserver/settings/common.py
View file @
c475d4f0
import
os
,
json
DEBUG
=
False
DEBUG
=
False
TEMPLATE_DEBUG
=
False
TEMPLATE_DEBUG
=
False
USE_TZ
=
True
USE_TZ
=
True
...
@@ -32,3 +34,21 @@ REST_FRAMEWORK = {
...
@@ -32,3 +34,21 @@ REST_FRAMEWORK = {
}
}
CORS_ORIGIN_ALLOW_ALL
=
True
CORS_ORIGIN_ALLOW_ALL
=
True
# SERVICE_VARIANT specifies name of the variant used, which decides what JSON
# configuration files are read during startup.
SERVICE_VARIANT
=
os
.
environ
.
get
(
'SERVICE_VARIANT'
,
'lms'
)
# CONFIG_ROOT specifies the directory where the JSON configuration
# files are expected to be found.
CONFIG_ROOT
=
os
.
environ
.
get
(
'CONFIG_ROOT'
,
"/edx/app/edxapp"
)
# CONFIG_PREFIX specifies the prefix of the JSON configuration files,
# based on the service variant. If no variant is use, don't use a
# prefix.
CONFIG_PREFIX
=
SERVICE_VARIANT
+
"."
if
SERVICE_VARIANT
else
""
with
open
(
os
.
path
.
join
(
CONFIG_ROOT
,
CONFIG_PREFIX
+
"auth.json"
))
as
auth_file
:
AUTH_TOKENS
=
json
.
load
(
auth_file
)
DATABASES
=
AUTH_TOKENS
[
'DATABASES'
]
\ No newline at end of file
requirements/base.txt
View file @
c475d4f0
Django==1.7.1
Django==1.7.1
requests==2.4.3
djangorestframework==2.4.4
djangorestframework==2.4.4
django-rest-swagger==0.2.0
django-rest-swagger==0.2.0
elasticsearch==1.2.0
elasticsearch==1.2.0
annotator==0.12.0
annotator==0.12.0
django-cors-headers==0.13
django-cors-headers==0.13
path.py==7.0
path.py==7.0
MySQL-python==1.2.4
-e git+https://github.com/edx/django-oauth2-provider.git@0.2.7-fork-edx-2#egg=django-oauth2-provider
# Testing
# Testing
django_nose==1.2
django_nose==1.2
...
...
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