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
8d1053ee
Unverified
Commit
8d1053ee
authored
Nov 22, 2017
by
Matt Drayer
Committed by
GitHub
Nov 22, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16566 from edx/mattdrayer/ENT-686-5
Better handling of data for OData API exception handling
parents
7aa1a346
9b4be936
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
21 deletions
+25
-21
common/djangoapps/third_party_auth/saml.py
+25
-21
No files found.
common/djangoapps/third_party_auth/saml.py
View file @
8d1053ee
...
...
@@ -286,22 +286,22 @@ class SapSuccessFactorsIdentityProvider(EdXSAMLIdentityProvider):
"""
session
=
requests
.
Session
()
transaction_data
=
{
'operation_name'
:
'generate_bizx_oauth_api_saml_assertion'
,
'endpoint_url'
:
self
.
sapsf_idp_url
,
'token_url'
:
self
.
sapsf_token_url
,
'company_id'
:
self
.
odata_company_id
,
'client_id'
:
self
.
odata_client_id
,
'user_id'
:
user_id
,
'private_key'
:
self
.
sapsf_private_key
,
}
try
:
assertion
=
session
.
post
(
transaction_data
[
'endpoint_url'
]
,
self
.
sapsf_idp_url
,
data
=
transaction_data
,
timeout
=
self
.
timeout
,
)
assertion
.
raise_for_status
()
except
requests
.
RequestException
as
err
:
transaction_data
[
'operation_name'
]
=
'generate_bizx_oauth_api_saml_assertion'
transaction_data
[
'endpoint_url'
]
=
self
.
sapsf_idp_url
transaction_data
[
'company_id'
]
=
self
.
odata_company_id
self
.
log_bizx_api_exception
(
transaction_data
,
err
)
return
None
return
assertion
.
text
...
...
@@ -314,8 +314,6 @@ class SapSuccessFactorsIdentityProvider(EdXSAMLIdentityProvider):
"""
session
=
requests
.
Session
()
transaction_data
=
{
'operation_name'
:
'generate_bizx_oauth_api_access_token'
,
'endpoint_url'
:
self
.
sapsf_token_url
,
'client_id'
:
self
.
odata_client_id
,
'company_id'
:
self
.
odata_company_id
,
'grant_type'
:
'urn:ietf:params:oauth:grant-type:saml2-bearer'
,
...
...
@@ -326,12 +324,15 @@ class SapSuccessFactorsIdentityProvider(EdXSAMLIdentityProvider):
try
:
transaction_data
[
'assertion'
]
=
assertion
token_response
=
session
.
post
(
transaction_data
[
'endpoint_url'
]
,
self
.
sapsf_token_url
,
data
=
transaction_data
,
timeout
=
self
.
timeout
,
)
token_response
.
raise_for_status
()
except
requests
.
RequestException
as
err
:
transaction_data
[
'operation_name'
]
=
'generate_bizx_oauth_api_access_token'
transaction_data
[
'endpoint_url'
]
=
self
.
sapsf_token_url
transaction_data
[
'user_id'
]
=
user_id
self
.
log_bizx_api_exception
(
transaction_data
,
err
)
return
None
return
token_response
.
json
()
...
...
@@ -357,29 +358,32 @@ class SapSuccessFactorsIdentityProvider(EdXSAMLIdentityProvider):
return
basic_details
user_id
=
basic_details
[
'username'
]
fields
=
','
.
join
(
self
.
field_mappings
)
transaction_data
=
{
'operation_name'
:
'get_user_details'
,
'user_id'
:
user_id
,
'company_id'
:
self
.
odata_company_id
,
'fields'
:
fields
,
'endpoint_url'
:
'{root_url}User(userId=
\'
{user_id}
\'
)?$select={fields}'
.
format
(
root_url
=
self
.
odata_api_root_url
,
user_id
=
user_id
,
fields
=
fields
,
),
}
client
=
self
.
get_bizx_odata_api_client
(
user_id
=
transaction_data
[
'user_id'
])
endpoint_url
=
'{root_url}User(userId=
\'
{user_id}
\'
)?$select={fields}'
.
format
(
root_url
=
self
.
odata_api_root_url
,
user_id
=
user_id
,
fields
=
fields
,
)
client
=
self
.
get_bizx_odata_api_client
(
user_id
=
user_id
)
if
not
client
:
return
basic_details
transaction_data
=
{
'token_data'
:
client
.
token_data
}
try
:
transaction_data
[
'token_data'
]
=
client
.
token_data
response
=
client
.
get
(
transaction_data
[
'endpoint_url'
]
,
endpoint_url
,
timeout
=
self
.
timeout
,
)
response
.
raise_for_status
()
response
=
response
.
json
()
except
requests
.
RequestException
as
err
:
transaction_data
=
{
'operation_name'
:
'get_user_details'
,
'endpoint_url'
:
endpoint_url
,
'user_id'
:
user_id
,
'company_id'
:
self
.
odata_company_id
,
'token_data'
:
client
.
token_data
,
}
self
.
log_bizx_api_exception
(
transaction_data
,
err
)
return
basic_details
return
self
.
get_registration_fields
(
response
)
...
...
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