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

Update Sign On Panel to collapse local login if SSO is enabled #701

Merged
merged 6 commits into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions configuration/portal_settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ singlejobviewer = "off"
; set to 'off' in Open XDMoD until support has been added.
multiple_service_providers = "off"

[sso]
; Set to "on" to enable the local user option in login modal.
show_local_login = "off"

[internal]
dw_desc_cache = "off"

Expand Down
89 changes: 61 additions & 28 deletions html/gui/js/CCR.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,9 @@ CCR.xdmod.ui.actionLogin = function (config, animateTarget) {

if (success) {
decodedResponse = CCR.checkDecodedJSONResponseSuccess(data);
if (Ext.isGecko) {
plessbd marked this conversation as resolved.
Show resolved Hide resolved
Ext.getCmp('local_login_submit').fireEvent('click');
}
}

if (decodedResponse) {
Expand All @@ -1004,42 +1007,63 @@ CCR.xdmod.ui.actionLogin = function (config, animateTarget) {
});
};

var localLoginItems = [txtLoginUsername, txtLoginPassword, {
xtype: 'tbtext',
id: 'login_response'
}, new Ext.Container({
anchor: 'form',
autoWidth: true,
autoHeight: true,
layout: {
type: 'hbox'
var localLoginItems = [
txtLoginUsername,
txtLoginPassword,
{
xtype: 'tbtext',
id: 'login_response'
},
items: [new Ext.Button({
width: 75,
height: 22,
text: 'Sign in',
id: 'btn_sign_in',
handler: signInWithLocalAccount
}), new Ext.Container({
autoEl: 'div',
{
xtype: 'field',
id: 'local_login_submit',
autoCreate: {
tag: 'input',
type: 'submit'
},
hidden: true
},
{
xtype: 'container',
anchor: 'form',
autoWidth: true,
autoHeight: true,
id: 'assistancePrompt',
height: 38,
layout: {
type: 'hbox'
},
items: [{
xtype: 'tbtext',
html: '<a href="javascript:CCR.xdmod.ui.forgot_password()">Forgot your password?</a>',
id: 'forgot_password_link'
}, {
xtype: 'tbtext',
html: '<a href="javascript:presentSignUpViaLoginPrompt()">Don\'t have an account?</a>',
id: 'sign_up_link'
xtype: 'button',
width: 75,
height: 22,
text: 'Sign in',
id: 'btn_sign_in',
handler: signInWithLocalAccount
},
{
xtype: 'container',
autoEl: 'div',
autoWidth: true,
flex: 2,
height: 38,
id: 'assistancePrompt',
items: [{
xtype: 'tbtext',
html: '<a href="javascript:CCR.xdmod.ui.forgot_password()">Forgot your password?</a>',
id: 'forgot_password_link'
},
{
xtype: 'tbtext',
html: '<a href="javascript:presentSignUpViaLoginPrompt()">Don\'t have an account?</a>',
id: 'sign_up_link'
}]
}]
})]
})];
}
];

var SSOLoginFrm = CCR.xdmod.isSSOConfigured ? new Ext.form.FormPanel({
id: 'sso_login_form',
title: 'Sign in with ' + accountName + ':',
width: 321,
items: [{
xtype: 'button',
text: '<img src="' + CCR.xdmod.SSOLoginLink.icon + '" alt="Login here."></img>',
Expand Down Expand Up @@ -1090,6 +1114,15 @@ CCR.xdmod.ui.actionLogin = function (config, animateTarget) {

if (CCR.xdmod.isSSOConfigured) {
loginItems.push(SSOLoginFrm);
if (!CCR.xdmod.SSOShowLocalLogin) {
localLoginFrm.collapsible = true;
plessbd marked this conversation as resolved.
Show resolved Hide resolved
localLoginFrm.collapsed = true;
localLoginFrm.titleCollapse = true;
/**
* the span is added to the title because without it the cursor does not show as clickable.
*/
localLoginFrm.title = '<span style="cursor:pointer;">' + localLoginFrm.title + '</span>';
}
loginItems.push(localLoginFrm);
} else {
loginItems.push(localLoginFrm);
Expand Down
14 changes: 12 additions & 2 deletions html/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ function isReferrer($referrer)
}
} catch (exception $ex) {
}
print "CCR.xdmod.captcha_sitekey = '" . $captchaSiteKey . "';";
print "CCR.xdmod.captcha_sitekey = '" . $captchaSiteKey . "';\n";
if (!$userLoggedIn) {
$auth = null;
try {
Expand All @@ -317,10 +317,20 @@ function isReferrer($referrer)
// This will catch when a configuration directory does not exist if it is set in the environment level
}
if ($auth && $auth->isSamlConfigured()) {
$ssoShowLocalLogin = false;
try {
$ssoShowLocalLogin = filter_var(
xd_utilities\getConfiguration('sso', 'show_local_login'),
FILTER_VALIDATE_BOOLEAN
);
} catch (exception $ex) {
}

print "CCR.xdmod.isSSOConfigured = true;\n";
print "CCR.xdmod.SSOLoginLink = " . json_encode($auth->getLoginLink()) . ";\n";
print "CCR.xdmod.SSOShowLocalLogin = " . json_encode($ssoShowLocalLogin) . "\n";
} else {
print "CCR.xdmod.isSSOConfigured = false;";
print "CCR.xdmod.isSSOConfigured = false;\n";
}
}
if ($userLoggedIn) {
Expand Down
4 changes: 4 additions & 0 deletions templates/portal_settings.template
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ singlejobviewer = "off"
; set to 'off' in Open XDMoD until support has been added.
multiple_service_providers = "off"

[sso]
; Set to "on" to enable the local user option in login modal.
show_local_login = "off"

[internal]
dw_desc_cache = "off"

Expand Down