mirror of
https://github.com/ansible/awx.git
synced 2026-01-27 16:41:29 -03:30
* release_2.4.0: (70 commits) Disallow changing a users password for social auth bump django-radius to include new license Change Jenkins server references from IP to DNS name Social auth and SSO updates: allow multi-org expired licenses to delete orgs Add social log messages to tower's log on error Update default scopes requested for github social auth. Switch to matburt's fork for python social auth Emit a warning for unmapped SAML paramters Fix up some SAML issues Remove `environment` play stmt Use correct aw_repo_url when building packer Add missing libxmlsec1 openssl dependency for ubuntu adds socket tests added git pre commit hook to run flake8 fixes remove_instance error null pointer exception Resolve issue on precise keeping old debs around Attach handlers to django_auth_ldap Attach handlers to django_auth_ldap ...
111 lines
4.3 KiB
JavaScript
111 lines
4.3 KiB
JavaScript
/*************************************************
|
|
* Copyright (c) 2015 Ansible, Inc.
|
|
*
|
|
* All Rights Reserved
|
|
*************************************************/
|
|
|
|
/**
|
|
* @ngdoc function
|
|
* @name helpers.function:Permissions
|
|
* @description
|
|
* Gets the configured auth types based on the configurations set in the server
|
|
*
|
|
*/
|
|
|
|
export default
|
|
['$http', 'ProcessErrors', function($http, ProcessErrors) {
|
|
return function (params) {
|
|
var scope = params.scope,
|
|
url = params.url;
|
|
|
|
return $http({
|
|
method: 'GET',
|
|
url: url,
|
|
}).then(function (data) {
|
|
var options = [],
|
|
error = "";
|
|
|
|
function parseGoogle(option) {
|
|
var newOption = {};
|
|
|
|
newOption.type = "google";
|
|
newOption.icon = "ThirdPartySignOn-icon--fontCustom icon-google";
|
|
newOption.link = option.login_url;
|
|
newOption.tooltip = "Sign in with Google";
|
|
|
|
return newOption;
|
|
}
|
|
|
|
function parseGithub(option, key) {
|
|
var newOption = {};
|
|
|
|
newOption.type = "github";
|
|
newOption.icon = "fa-github ThirdPartySignOn-icon--gitHub";
|
|
newOption.link = option.login_url;
|
|
newOption.tooltip = "Sign in with GitHub";
|
|
|
|
// if this is a GitHub team or org, add that to
|
|
// the tooltip
|
|
if (key.split("-")[1]){
|
|
if (key.split("-")[1] === "team") {
|
|
newOption.tooltip += " Teams";
|
|
} else if (key.split("-")[1] === "org") {
|
|
newOption.tooltip += " Organizations";
|
|
}
|
|
}
|
|
|
|
return newOption;
|
|
}
|
|
|
|
function parseSaml(option, key) {
|
|
var newOption = {};
|
|
|
|
newOption.type = "saml";
|
|
newOption.icon = "ThirdPartySignOn-icon--fontCustom icon-saml-02";
|
|
newOption.link = option.login_url;
|
|
newOption.tooltip = "Sign in with SAML";
|
|
|
|
// add the idp of the saml type to the tooltip
|
|
if (key.split(":")[1]){
|
|
newOption.tooltip += " (" + key.split(":")[1] + ")";
|
|
}
|
|
|
|
return newOption;
|
|
}
|
|
|
|
function parseLoginOption(option, key) {
|
|
var finalOption;
|
|
|
|
// set up the particular tooltip, icon, etc.
|
|
// needed by the login type
|
|
if (key.split("-")[0] === "google") {
|
|
finalOption = parseGoogle(option, key);
|
|
} else if (key.split("-")[0] === "github") {
|
|
finalOption = parseGithub(option, key);
|
|
} else if (key.split(":")[0] === "saml") {
|
|
finalOption = parseSaml(option, key);
|
|
}
|
|
|
|
// set the button to error red and set the error message to be passed to the login modal.
|
|
if (option.error) {
|
|
finalOption.button = "ThirdPartySignOn-button--error";
|
|
error = option.error;
|
|
}
|
|
|
|
options.push(finalOption);
|
|
}
|
|
|
|
// iterate over each login option passed from the API
|
|
_.forEach(data.data, parseLoginOption);
|
|
|
|
// return the options and the error to be utilized
|
|
// by the loginModal
|
|
return {"options": options, "error": error};
|
|
})
|
|
.catch(function (data) {
|
|
ProcessErrors(scope, data.data, data.status, null, { hdr: 'Error!',
|
|
msg: 'Failed to get third-party login types. Returned status: ' + data.status });
|
|
});
|
|
};
|
|
}];
|