Skip to content
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

SAML Support #120

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/bundle.js

Large diffs are not rendered by default.

43 changes: 29 additions & 14 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,39 @@ module.exports = function(currentUser, matchingUsers, params, token) {
window.location = domain + 'authorize?' + query;
};

var authorizeSaml = function(domain, qs) {
let clientId = qs["client_id"];
let connection = encodeURIComponent(qs["connection"]);
let link_account_token = encodeURIComponent(qs["link_account_token"]);
window.location = domain + `samlp/${clientId}?connection=${connection}&link_account_token=${link_account_token}&prevent_sign_up=true`;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we send the original RelayState here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Fixed.
image

};

var updateContinueUrl = function(linkEl, domain, state) {
linkEl.href = domain + 'continue?state=' + state;
};

linkEl.addEventListener('click', function(e) {
authorize(token.iss, {
client_id: params.client_id,
redirect_uri: params.redirect_uri,
response_type: params.response_type,
response_mode: params.response_mode,
scope: params.scope,
state: params.original_state,
nonce: params.nonce,
audience: params.audience,
link_account_token: params.child_token,
prevent_sign_up: true,
connection: connections[0]
});
if (params.protocol === 'samlp') {
authorizeSaml(token.iss, {
client_id: params.client_id,
connection: connections[0],
link_account_token: params.child_token
});
} else {
authorize(token.iss, {
client_id: params.client_id,
redirect_uri: params.redirect_uri,
response_type: params.response_type,
response_mode: params.response_mode,
scope: params.scope,
state: params.original_state,
nonce: params.nonce,
audience: params.audience,
link_account_token: params.child_token,
prevent_sign_up: true,
connection: connections[0]
});
}
});

updateContinueUrl(skipEl, token.iss, params.state);
Expand Down Expand Up @@ -123,4 +138,4 @@ module.exports = function(currentUser, matchingUsers, params, token) {

return keys;
}
}
}
3 changes: 2 additions & 1 deletion rules/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,10 @@ module.exports = ({ extensionURL = '', username = 'Unknown', clientID = '', clie
// Consider moving this logic out of the rule and into the extension
function buildRedirectUrl(token, q, errorType) {
var params = {
protocol: context.protocol,
child_token: token,
audience: q.audience,
client_id: q.client_id,
client_id: q.client_id ? q.client_id : context.clientID,
redirect_uri: q.redirect_uri,
scope: q.scope,
response_type: q.response_type,
Expand Down