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
19f95f00
Commit
19f95f00
authored
Sep 22, 2014
by
Carlos Andrés Rocha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return OpenID Connect user name from user profile.
parent
03d9a6fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
lms/djangoapps/oauth2_handler/handlers.py
+9
-2
lms/djangoapps/oauth2_handler/tests.py
+10
-0
No files found.
lms/djangoapps/oauth2_handler/handlers.py
View file @
19f95f00
...
...
@@ -3,6 +3,7 @@
import
branding
from
courseware.access
import
has_access
from
student.models
import
anonymous_id_for_user
from
student.models
import
UserProfile
from
user_api.models
import
UserPreference
from
lang_pref
import
LANGUAGE_KEY
...
...
@@ -33,8 +34,14 @@ class ProfileHandler(object):
""" Basic OpenID Connect `profile` scope handler with `locale` claim. """
def
scope_profile
(
self
,
_data
):
""" Add the locale claim. """
return
[
'locale'
]
""" Add specialized claims. """
return
[
'name'
,
'locale'
]
def
claim_name
(
self
,
data
):
""" User displayable full name. """
user
=
data
[
'user'
]
profile
=
UserProfile
.
objects
.
get
(
user
=
user
)
return
profile
.
name
def
claim_locale
(
self
,
data
):
"""
...
...
lms/djangoapps/oauth2_handler/tests.py
View file @
19f95f00
...
...
@@ -6,6 +6,7 @@ from courseware.tests.tests import TEST_DATA_MIXED_MODULESTORE
from
lang_pref
import
LANGUAGE_KEY
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
student.models
import
anonymous_id_for_user
from
student.models
import
UserProfile
from
student.roles
import
CourseStaffRole
,
CourseInstructorRole
from
student.tests.factories
import
UserFactory
,
UserProfileFactory
from
user_api.models
import
UserPreference
...
...
@@ -42,6 +43,15 @@ class IDTokenTest(BaseTestMixin, IDTokenTestCase):
expected_sub
=
anonymous_id_for_user
(
self
.
user
,
None
)
self
.
assertEqual
(
sub
,
expected_sub
)
def
test_user_name_claim
(
self
):
_scopes
,
claims
=
self
.
get_new_id_token_values
(
'openid profile'
)
claim_name
=
claims
[
'name'
]
user_profile
=
UserProfile
.
objects
.
get
(
user
=
self
.
user
)
user_name
=
user_profile
.
name
self
.
assertEqual
(
claim_name
,
user_name
)
def
test_user_without_locale_claim
(
self
):
scopes
,
claims
=
self
.
get_new_id_token_values
(
'openid profile'
)
self
.
assertIn
(
'profile'
,
scopes
)
...
...
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