-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat/incommon: specify downstream IDP for shibboleth login #652
Open
rudyardrichter
wants to merge
8
commits into
master
Choose a base branch
from
feat/incommon
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR contains code that is not formatted correctly according to Expand the full diff to see formatting changes--- fence/blueprints/login/__init__.py
+++ blackened
@@ -9,11 +9,14 @@
from cdislogging import get_logger
import flask
import requests
from fence.blueprints.login.fence_login import (
- FenceLogin, FenceCallback, FenceDownstreamIDPs, get_disco_feed
+ FenceLogin,
+ FenceCallback,
+ FenceDownstreamIDPs,
+ get_disco_feed,
)
from fence.blueprints.login.google import GoogleLogin, GoogleCallback
from fence.blueprints.login.shib import ShibbolethLogin, ShibbolethCallback
from fence.blueprints.login.microsoft import MicrosoftLogin, MicrosoftCallback
from fence.blueprints.login.orcid import ORCIDLogin, ORCIDCallback
--- fence/blueprints/login/fence_login.py
+++ blackened
@@ -99,10 +99,11 @@
)
if not content:
raise NotFound("this endpoint is unavailable")
return flask.jsonify(content)
+
def get_disco_feed():
"""
For fence instances which point to a fence instance deployed with shibboleth IDP(s),
we want to list the available downstream IDPs that could be used for shibboleth
login. The `entityID` from the DiscoFeed can be provided to the /login/shib
@@ -132,19 +133,21 @@
if response.status_code != 200:
# if it's 404 that's fine---just no shibboleth. otherwise there could be an
# actual problem
if response.status_code != 404:
logger.error(
- "got weird response ({}) from the IDP fence shibboleth disco feed ({})"
- .format(response.status_code, disco_feed_url)
+ "got weird response ({}) from the IDP fence shibboleth disco feed ({})".format(
+ response.status_code, disco_feed_url
+ )
)
raise EnvironmentError("unexpected response from fence IDP")
return None
try:
return response.json()
except ValueError:
logger.error(
- "didn't get JSON in response from IDP fence shibboleth disco feed ({})"
- .format(disco_feed_url)
+ "didn't get JSON in response from IDP fence shibboleth disco feed ({})".format(
+ disco_feed_url
+ )
)
return None
--- fence/blueprints/login/shib.py
+++ blackened
@@ -33,12 +33,14 @@
actual_redirect = config["BASE_URL"] + "/login/shib/login"
if not entityID or entityID == "urn:mace:incommon:nih.gov":
# default to SSO_URL from the config which should be NIH login
return flask.redirect(config["SSO_URL"] + actual_redirect)
return flask.redirect(
- config["BASE_URL"] + "/Shibboleth.sso/Login?entityID={}&target={}"
- .format(entityID, actual_redirect)
+ config["BASE_URL"]
+ + "/Shibboleth.sso/Login?entityID={}&target={}".format(
+ entityID, actual_redirect
+ )
)
class ShibbolethCallback(Resource):
def get(self):
--- tests/login/test_fence_login.py
+++ blackened
@@ -117,39 +117,36 @@
entityID = "urn:mace:incommon:uchicago.edu"
def mock_get(*args, **kwargs):
mocked_response = mock.MagicMock(requests.Response)
mocked_response.status_code = 200
- mocked_response.json.return_value = [{
- "entityID": entityID,
- "DisplayNames": [
- {
- "value": "University of Chicago",
- "lang": "en"
+ mocked_response.json.return_value = [
+ {
+ "entityID": entityID,
+ "DisplayNames": [{"value": "University of Chicago", "lang": "en"}],
+ "Descriptions": [
+ {
+ "value": "The University of Chicago Web Single Sign-On servce",
+ "lang": "en",
}
],
- "Descriptions": [
- {
- "value": "The University of Chicago Web Single Sign-On servce",
- "lang": "en"
+ "PrivacyStatementURLs": [
+ {
+ "value": "https://its.uchicago.edu/acceptable-use-policy/",
+ "lang": "en",
}
],
- "PrivacyStatementURLs": [
- {
- "value": "https://its.uchicago.edu/acceptable-use-policy/",
- "lang": "en"
+ "Logos": [
+ {
+ "value": "https://shibboleth2.uchicago.edu/idp/shib_img/idplogo.png",
+ "height": "83",
+ "width": "350",
+ "lang": "en",
}
],
- "Logos": [
- {
- "value": "https://shibboleth2.uchicago.edu/idp/shib_img/idplogo.png",
- "height": "83",
- "width": "350",
- "lang": "en"
- }
- ]
- }]
+ }
+ ]
return mocked_response
with mock.patch("fence.blueprints.login.fence_login.requests.get", mock_get):
response = client.get("/login/downstream-idps")
assert len(response.json) == 1 This formatting comment was generated automatically by a script in uc-cdis/wool. |
Pull Request Test Coverage Report for Build 7201
💛 - Coveralls |
6d7b83f
to
d954728
Compare
f4eac46
to
34db8f4
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New Features
?shib_idp
parameter to/login/shib
(and also/oauth2/authorize
when the shibboleth IDP is in use), which allows the client to specify which downstream identity provider to use for login.shib_idp
parameter should be anentityID
corresponding to the IDP in Shibboleth; for example,shib_idp=urn:mace:incommon:uchicago.edu
orshib_idp=urn:mace:incommon:nih.gov
./Shibboleth.sso/DiscoFeed
.