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
c0479fb7
Commit
c0479fb7
authored
Dec 10, 2015
by
muhammad-ammar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use users anonymous id for subject field in JWT
parent
3603ede5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
openedx/core/lib/tests/test_token_utils.py
+2
-1
openedx/core/lib/token_utils.py
+2
-2
No files found.
openedx/core/lib/tests/test_token_utils.py
View file @
c0479fb7
...
@@ -12,6 +12,7 @@ from oauth2_provider.tests.factories import ClientFactory
...
@@ -12,6 +12,7 @@ from oauth2_provider.tests.factories import ClientFactory
from
provider.constants
import
CONFIDENTIAL
from
provider.constants
import
CONFIDENTIAL
from
openedx.core.lib.token_utils
import
get_id_token
from
openedx.core.lib.token_utils
import
get_id_token
from
student.models
import
anonymous_id_for_user
from
student.tests.factories
import
UserFactory
,
UserProfileFactory
from
student.tests.factories
import
UserFactory
,
UserProfileFactory
...
@@ -53,7 +54,7 @@ class TestIdTokenGeneration(TestCase):
...
@@ -53,7 +54,7 @@ class TestIdTokenGeneration(TestCase):
'exp'
:
calendar
.
timegm
(
expiration
.
utctimetuple
()),
'exp'
:
calendar
.
timegm
(
expiration
.
utctimetuple
()),
'iat'
:
calendar
.
timegm
(
now
.
utctimetuple
()),
'iat'
:
calendar
.
timegm
(
now
.
utctimetuple
()),
'aud'
:
self
.
oauth2_client
.
client_id
,
'aud'
:
self
.
oauth2_client
.
client_id
,
'sub'
:
self
.
user
.
id
,
# pylint: disable=no-member
'sub'
:
anonymous_id_for_user
(
self
.
user
,
None
),
}
}
self
.
assertEqual
(
payload
,
expected_payload
)
self
.
assertEqual
(
payload
,
expected_payload
)
...
...
openedx/core/lib/token_utils.py
View file @
c0479fb7
...
@@ -6,7 +6,7 @@ from django.core.exceptions import ImproperlyConfigured
...
@@ -6,7 +6,7 @@ from django.core.exceptions import ImproperlyConfigured
import
jwt
import
jwt
from
provider.oauth2.models
import
Client
from
provider.oauth2.models
import
Client
from
student.models
import
UserProfile
from
student.models
import
UserProfile
,
anonymous_id_for_user
def
get_id_token
(
user
,
client_name
):
def
get_id_token
(
user
,
client_name
):
...
@@ -54,7 +54,7 @@ def get_id_token(user, client_name):
...
@@ -54,7 +54,7 @@ def get_id_token(user, client_name):
'exp'
:
now
+
datetime
.
timedelta
(
seconds
=
expires_in
),
'exp'
:
now
+
datetime
.
timedelta
(
seconds
=
expires_in
),
'iat'
:
now
,
'iat'
:
now
,
'aud'
:
client
.
client_id
,
'aud'
:
client
.
client_id
,
'sub'
:
user
.
id
,
'sub'
:
anonymous_id_for_user
(
user
,
None
)
,
}
}
return
jwt
.
encode
(
payload
,
client
.
client_secret
)
return
jwt
.
encode
(
payload
,
client
.
client_secret
)
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