We would like to edit Main Login Page for Jira to have a link for users to SSO login

rod.osborne
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 22, 2019

What we would like is to have 2 login options on the main login page.
We need to keep the existing login for the non-SAML login users.
We also need a button or link to the SAML login for all the SSO users.

I found this link 

https://confluence.atlassian.com/jirakb/how-to-customize-the-login-gadget-225122084.html

But the details in this link I don't see the files the should be modify. 

 

2 answers

0 votes
rangunim
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 15, 2024
I wrote workaround by using internal Atlassian rest api, which can be UNSTABLE!.
If your Anouncement Banner is public, then you can put below script:
{code:javascript}
<script type="text/javascript">
function _clearLoginFormAndAuthorize(authorizeUrl) {
document.getElementById("loginform").reset();
window.open(authorizeUrl, '_self');
}
function addAdditionalAuthenthicationsToLoginGadget() {
const elementLoginForm = document.getElementById('loginform');
if (elementLoginForm == null) {
return; //login form on loaded page does not exists, so do nothing
}
$.ajax({
type: 'GET',
url: AJS.contextPath() + '/rest/authconfig/1.0/login-options',
success: function(data){
const filteredData = data.results.filter(currentData => currentData.type.toUpperCase() !== 'LOGIN_FORM');
if (filteredData.length === 0) {
return; 
}
let additionalAuthenticationSection = document.createElement('div');
additionalAuthenticationSection.setAttribute('id', 'additional-authentication-section');
for (const currentData of filteredData) {
const elementButton = document.createElement('button');
elementButton.innerHTML = currentData['button-text'];
elementButton.setAttribute('data-authentication-method', currentData.type.toLowerCase()); //this attribute is in html DOM login page
elementButton.setAttribute('onclick', '_clearLoginFormAndAuthorize("' + currentData['login-link'] + '")');
elementButton.setAttribute('type', 'button');
elementButton.setAttribute('class', 'aui-button aui-button-primary');
elementButton.setAttribute('style', 'margin-top:10px; margin-right:10px; display:block');
additionalAuthenticationSection.append(elementButton);
additionalAuthenticationSection.append(document.createElement('br'));
}
const elementLoginForm = document.getElementById('loginform');
if (elementLoginForm != null) {
document.getElementById('login').parentElement.append(additionalAuthenticationSection);
elementLoginForm.parentElement.parentElement.style.height = 'auto'; //resize login gadget
}
}
});
}
window.onload = function(){
addAdditionalAuthenthicationsToLoginGadget();
}
</script>
{code}
If your annoucement banner is private then you need modify login.soy by follow with instruction [https://confluence.atlassian.com/jirakb/customize-jira-login-page-225122084.html].
You can adding above script, but you need adjust this by adding {literal} soy element or just replace all open brackets ({) to {lb} and closed brackets ({) to {rb}.
Moreover, you need change section window.onload to direct invoke addAdditionalAuthenthicationsToLoginGadget();
0 votes
B_G
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 14, 2020

This question is relevant for Jira 8.7.1 still in April 2020. Our admins cannot configure SAML auth as primary auth, because the method it Solved: How to disable SAML 2.0 in Jira Data Center 8.2 when we can't log in for manually setting SAML back to secondary does not work.

My interim solution for adding to the login page a link for the SAML authentication is to modify the announcement banner.

<script>
if(window.location.href.indexOf("login.jsp") != -1)
{
document.write("<div class='aui-message info'><p>");
document.write("<a href='/plugins/servlet/external-login'>Click here to log in with SSO</a>");
document.write("</p></div>");
}
</script>

 The javascript logic for determining if we are on the login page is courtesy of one of my fellow admins who probably found it somewhere in this community site.

Suggest an answer

Log in or Sign up to answer