SSO Auto login and template cleanup
This commit is contained in:
@@ -27,4 +27,9 @@ public class EEAppConfig {
|
|||||||
public boolean runningEnterpriseEdition() {
|
public boolean runningEnterpriseEdition() {
|
||||||
return licenseKeyChecker.getEnterpriseEnabledResult();
|
return licenseKeyChecker.getEnterpriseEnabledResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean(name = "SSOAutoLogin")
|
||||||
|
public boolean ssoAutoLogin() {
|
||||||
|
return applicationProperties.getEnterpriseEdition().isSsoAutoLogin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class KeygenLicenseVerifier {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||||
log.info(" validateLicenseResponse body: " + response.body());
|
log.debug(" validateLicenseResponse body: " + response.body());
|
||||||
JsonNode jsonResponse = objectMapper.readTree(response.body());
|
JsonNode jsonResponse = objectMapper.readTree(response.body());
|
||||||
if (response.statusCode() == 200) {
|
if (response.statusCode() == 200) {
|
||||||
|
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ public class ApplicationProperties {
|
|||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
@ToString.Exclude private String key;
|
@ToString.Exclude private String key;
|
||||||
private int maxUsers;
|
private int maxUsers;
|
||||||
|
private boolean ssoAutoLogin;
|
||||||
private CustomMetadata customMetadata = new CustomMetadata();
|
private CustomMetadata customMetadata = new CustomMetadata();
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ security:
|
|||||||
enterpriseEdition:
|
enterpriseEdition:
|
||||||
enabled: false # set to 'true' to enable enterprise edition
|
enabled: false # set to 'true' to enable enterprise edition
|
||||||
key: 00000000-0000-0000-0000-000000000000
|
key: 00000000-0000-0000-0000-000000000000
|
||||||
|
SSOAutoLogin: false # Enable to auto login to first provided SSO
|
||||||
CustomMetadata:
|
CustomMetadata:
|
||||||
autoUpdateMetadata: false # set to 'true' to automatically update metadata with below values
|
autoUpdateMetadata: false # set to 'true' to automatically update metadata with below values
|
||||||
author: username # supports text such as 'John Doe' or types such as username to autopopulate with user's username
|
author: username # supports text such as 'John Doe' or types such as username to autopopulate with user's username
|
||||||
@@ -86,8 +87,8 @@ system:
|
|||||||
tessdataDir: /usr/share/tessdata # path to the directory containing the Tessdata files. This setting is relevant for Windows systems. For Windows users, this path should be adjusted to point to the appropriate directory where the Tessdata files are stored.
|
tessdataDir: /usr/share/tessdata # path to the directory containing the Tessdata files. This setting is relevant for Windows systems. For Windows users, this path should be adjusted to point to the appropriate directory where the Tessdata files are stored.
|
||||||
enableAnalytics: 'true' # set to 'true' to enable analytics, set to 'false' to disable analytics; for enterprise users, this is set to true
|
enableAnalytics: 'true' # set to 'true' to enable analytics, set to 'false' to disable analytics; for enterprise users, this is set to true
|
||||||
datasource:
|
datasource:
|
||||||
enableCustomDatabase: false # set this property to 'true' if you would like to use your own custom database configuration
|
enableCustomDatabase: false # Enterprise users ONLY, set this property to 'true' if you would like to use your own custom database configuration
|
||||||
customDatabaseUrl: jdbc:postgresql://localhost:5432/postgres # set the url for your own custom database connection. If provided, the type, hostName, port and name are not necessary and will not be used
|
customDatabaseUrl: '' # eg jdbc:postgresql://localhost:5432/postgres, set the url for your own custom database connection. If provided, the type, hostName, port and name are not necessary and will not be used
|
||||||
username: postgres # set the database username
|
username: postgres # set the database username
|
||||||
password: postgres # set the database password
|
password: postgres # set the database password
|
||||||
type: postgresql # the type of the database to set (e.g. 'h2', 'postgresql')
|
type: postgresql # the type of the database to set (e.g. 'h2', 'postgresql')
|
||||||
|
|||||||
@@ -11,48 +11,88 @@
|
|||||||
<div class="your-container-class"></div>
|
<div class="your-container-class"></div>
|
||||||
<div class="container-flex">
|
<div class="container-flex">
|
||||||
<main class="form-signin">
|
<main class="form-signin">
|
||||||
<script>
|
<script th:inline="javascript">
|
||||||
document.addEventListener('modeChanged', function(e) {
|
const redirectAttempts = parseInt(localStorage.getItem('ssoRedirectAttempts') || '0');
|
||||||
var mode = e.detail;
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const hasRedirectError = urlParams.has('error');
|
||||||
document.body.classList.remove("light-mode", "dark-mode", "rainbow-mode"); // remove all mode classes first
|
const hasLogout = urlParams.has('logout');
|
||||||
|
const hasMessage = urlParams.has('message');
|
||||||
switch (mode) {
|
const MAX_REDIRECT_ATTEMPTS = 3;
|
||||||
case "on":
|
|
||||||
document.body.classList.add("dark-mode");
|
document.addEventListener('modeChanged', function(e) {
|
||||||
break;
|
var mode = e.detail;
|
||||||
case "off":
|
|
||||||
document.body.classList.add("light-mode");
|
document.body.classList.remove("light-mode", "dark-mode", "rainbow-mode"); // remove all mode classes first
|
||||||
break;
|
|
||||||
case "rainbow":
|
switch (mode) {
|
||||||
document.body.classList.add("rainbow-mode");
|
case "on":
|
||||||
break;
|
document.body.classList.add("dark-mode");
|
||||||
}
|
break;
|
||||||
});
|
case "off":
|
||||||
|
document.body.classList.add("light-mode");
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
break;
|
||||||
const defaultLocale = getStoredOrDefaultLocale();
|
case "rainbow":
|
||||||
checkUserLanguage(defaultLocale);
|
document.body.classList.add("rainbow-mode");
|
||||||
|
break;
|
||||||
const dropdownItems = document.querySelectorAll('.lang_dropdown-item');
|
}
|
||||||
let activeItem;
|
});
|
||||||
|
|
||||||
for (let i = 0; i < dropdownItems.length; i++) {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const item = dropdownItems[i];
|
|
||||||
item.classList.remove('active');
|
const runningEE = [[${@runningEE}]];
|
||||||
if (item.dataset.bsLanguageCode === defaultLocale) {
|
const SSOAutoLogin = [[${@SSOAutoLogin}]];
|
||||||
item.classList.add('active');
|
const loginMethod = [[${loginMethod}]];
|
||||||
activeItem = item;
|
const providerList = [[${providerlist}]];
|
||||||
}
|
const shouldAutoRedirect = !hasRedirectError &&
|
||||||
item.addEventListener('click', handleDropdownItemClick);
|
!hasLogout &&
|
||||||
}
|
!hasMessage &&
|
||||||
|
redirectAttempts < MAX_REDIRECT_ATTEMPTS &&
|
||||||
const dropdown = document.getElementById('languageDropdown');
|
loginMethod !== 'normal' && runningEE && SSOAutoLogin;
|
||||||
|
|
||||||
if (activeItem) {
|
console.log('Should redirect:', shouldAutoRedirect, {
|
||||||
dropdown.innerHTML = activeItem.innerHTML; // This will set the dropdown button's content to the active language's flag and name
|
'No error': !hasRedirectError,
|
||||||
}
|
'No logout': !hasLogout,
|
||||||
});
|
'No message': !hasMessage,
|
||||||
|
'Under max attempts': redirectAttempts < MAX_REDIRECT_ATTEMPTS,
|
||||||
|
'Is OAuth2': loginMethod === 'oauth2'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (shouldAutoRedirect && providerList && Object.keys(providerList).length > 0) {
|
||||||
|
localStorage.setItem('ssoRedirectAttempts', redirectAttempts + 1);
|
||||||
|
const firstProvider = Object.keys(providerList)[0];
|
||||||
|
window.location.href = firstProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset redirect attempts if successful login or after 1 hour
|
||||||
|
const lastAttemptTime = parseInt(localStorage.getItem('lastRedirectAttempt') || '0');
|
||||||
|
if (Date.now() - lastAttemptTime > 3600000) { // 1 hour
|
||||||
|
localStorage.setItem('ssoRedirectAttempts', '0');
|
||||||
|
}
|
||||||
|
localStorage.setItem('lastRedirectAttempt', Date.now().toString());
|
||||||
|
|
||||||
|
|
||||||
|
const defaultLocale = getStoredOrDefaultLocale();
|
||||||
|
checkUserLanguage(defaultLocale);
|
||||||
|
|
||||||
|
const dropdownItems = document.querySelectorAll('.lang_dropdown-item');
|
||||||
|
let activeItem;
|
||||||
|
|
||||||
|
for (let i = 0; i < dropdownItems.length; i++) {
|
||||||
|
const item = dropdownItems[i];
|
||||||
|
item.classList.remove('active');
|
||||||
|
if (item.dataset.bsLanguageCode === defaultLocale) {
|
||||||
|
item.classList.add('active');
|
||||||
|
activeItem = item;
|
||||||
|
}
|
||||||
|
item.addEventListener('click', handleDropdownItemClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
const dropdown = document.getElementById('languageDropdown');
|
||||||
|
|
||||||
|
if (activeItem) {
|
||||||
|
dropdown.innerHTML = activeItem.innerHTML; // This will set the dropdown button's content to the active language's flag and name
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<img class="my-4" th:src="@{'/favicon.svg'}" alt="favicon" width="144" height="144">
|
<img class="my-4" th:src="@{'/favicon.svg'}" alt="favicon" width="144" height="144">
|
||||||
|
|||||||
Reference in New Issue
Block a user