-
Notifications
You must be signed in to change notification settings - Fork 495
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
Implemented passive authentication support for Shibboleth #3762
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
This isPassive script will automatically try to log in a user using the SAML2 | ||
isPassive feature. | ||
In case a user already has an authenticated session at his Identity Provider and | ||
given the Discovery Service can guess the user's Identity Provider, the user will | ||
eventually be on the exact same page this script is embedded in but logged in | ||
(= Shibboleth attributes are available and user has a valid session with the | ||
Service Provider on the same host). | ||
The user page also will be requested with the same GET arguments than the initial request. | ||
|
||
Requirements: | ||
- Only works if a Service Provider 2.x is installed on the same host | ||
- JavaScript must be enabled. Otherwise the script won't have any effect. | ||
- The script must be able to set cookies (required for Shibboleth Service Provider as well) | ||
- In the shibboleth2.xml there must be defined a redirectErrors="#THIS PAGE#" in | ||
the <Errors> element. #THIS PAGE# must be the relative/absolute URL of the page | ||
this script is embedded in. | ||
- It also makes sense to protect #THIS PAGE# with a lazy session in order to use | ||
the Shibboleth attribute that should be available after authentication. | ||
*/ | ||
|
||
// Check for session cookie that contains the initial location | ||
if(document.cookie && document.cookie.search(/_check_is_passive_dv=/) >= 0){ | ||
// If we have the opensaml::FatalProfileException GET arguments | ||
// redirect to initial location because isPassive failed | ||
if ( | ||
window.location.search.search(/errorType/) >= 0 | ||
&& window.location.search.search(/RelayState/) >= 0 | ||
&& window.location.search.search(/requestURL/) >= 0 | ||
) { | ||
var cookieStr = document.cookie + ";"; | ||
var startpos = (cookieStr.indexOf('_check_is_passive_dv=')+21); | ||
var endpos = cookieStr.indexOf(';', startpos); | ||
window.location = cookieStr.substring(startpos,endpos); | ||
} | ||
} else { | ||
// Mark browser as being isPassive checked | ||
document.cookie = "_check_is_passive_dv=" + window.location; | ||
|
||
// Redirect to Shibboleth handler | ||
window.location = "/Shibboleth.sso/Login?isPassive=true&target=" + encodeURIComponent("https://" + window.location.hostname + "/shib.xhtml?redirectPage=" + window.location.pathname); | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, you'd document this new database setting so that it appears (near the bottom) of a future version of http://guides.dataverse.org/en/4.6.1/installation/config.html#database-settings