Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
19f95f00
Commit
19f95f00
authored
10 years ago
by
Carlos Andrés Rocha
Browse files
Options
Downloads
Patches
Plain Diff
Return OpenID Connect user name from user profile.
parent
03d9a6fd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/oauth2_handler/handlers.py
+9
-2
9 additions, 2 deletions
lms/djangoapps/oauth2_handler/handlers.py
lms/djangoapps/oauth2_handler/tests.py
+10
-0
10 additions, 0 deletions
lms/djangoapps/oauth2_handler/tests.py
with
19 additions
and
2 deletions
lms/djangoapps/oauth2_handler/handlers.py
+
9
−
2
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
):
"""
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/oauth2_handler/tests.py
+
10
−
0
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment