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

#401 Extend CSSO timeout check to main client #402

Merged
merged 3 commits into from
Jul 24, 2023
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
2 changes: 1 addition & 1 deletion src/css/mmgisUI.css
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@ input::-webkit-inner-spin-button {
cursor: default;
}
.mmgisToast.failure {
background-color: #a11717;
background-color: var(--color-r1);
}

/*spinner1*/
Expand Down
18 changes: 17 additions & 1 deletion src/essence/Ancillary/Login/Login.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to top, rgba(29, 31, 32, 0.95), rgba(29, 31, 32, 0.9));
background: linear-gradient(
to top,
rgba(29, 31, 32, 0.95),
rgba(29, 31, 32, 0.9)
);
z-index: 999999;
opacity: 0;
pointer-events: none !important;
Expand Down Expand Up @@ -156,3 +160,15 @@
#forceSignupButton:hover {
color: var(--color-mmgis);
}
#loginDiv #loginUser.attention {
animation: 0.8s attention ease infinite alternate;
}

@keyframes attention {
0% {
background: var(--color-r1);
}
100% {
background: var(--color-red);
}
}
26 changes: 25 additions & 1 deletion src/essence/Ancillary/Login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as d3 from 'd3'
import F_ from '../../Basics/Formulae_/Formulae_'
import L_ from '../../Basics/Layers_/Layers_'
import ToolController_ from '../../Basics/ToolController_/ToolController_'
import tippy from 'tippy.js'

import calls from '../../../pre/calls'

Expand Down Expand Up @@ -90,7 +91,6 @@ var Login = {
Login.loginBar
.append('div')
.attr('id', 'loginUser')
.attr('title', Login.loggedIn ? Login.username : '')
.style('text-align', 'center')
.style('font-size', '12px')
.style('font-weight', 'bold')
Expand All @@ -110,6 +110,18 @@ var Login = {
.style('transition', 'opacity 0.2s ease-out')
.html(Login.loggedIn ? Login.username[0] : '')

if (Login.loggedIn) {
if (window._tippyLoginUser && window._tippyLoginUser[0])
window._tippyLoginUser[0].setContent(Login.username)
else
window._tippyLoginUser = tippy('#loginUser', {
content: Login.username,
placement: 'bottom-end',
theme: 'blue',
allowHTML: true,
})
}

//Show signup for admins
if (
window.mmgisglobal.AUTH === 'local' &&
Expand Down Expand Up @@ -541,6 +553,18 @@ function loginSuccess(data, ignoreError) {
background: Login.loggedIn ? 'var(--color-a)' : 'transparent',
})
.html(Login.username[0])

if (Login.loggedIn) {
if (window._tippyLoginUser && window._tippyLoginUser[0])
window._tippyLoginUser[0].setContent(Login.username)
else
window._tippyLoginUser = tippy('#loginUser', {
content: Login.username,
placement: 'bottom-end',
theme: 'blue',
allowHTML: true,
})
}
} else {
document.cookie = 'MMGISUser=;expires=Thu, 01 Jan 1970 00:00:01 GMT;'

Expand Down
2 changes: 1 addition & 1 deletion src/essence/Basics/UserInterface_/LayerUpdatedControl.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
color: var(--color-a) !important;
}
.DISCONNECTED {
background: var(--color-red) !important;
background: var(--color-r1) !important;
color: var(--color-f) !important;
}
.leaflet-control-update-layer-icon > .mdi-reload-alert,
Expand Down
35 changes: 16 additions & 19 deletions src/pre/RefreshAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (mmgisglobal.SERVER == 'node' && mmgisglobal.AUTH == 'csso') {

mmgisglobal.lastInteraction = Math.floor(Date.now() / 1000)
var _refreshAuth_checkEvery = 60000 * 10 //milliseconds
var _refreshAuth_expiringLessThan = 60 * 11 //seconds
var _refreshAuth_expiringLessThan = 60 * 20 //seconds
var _refreshAuth_interactedPast = 60000 * 30 //milliseconds

function ssorefresh() {
Expand All @@ -49,26 +49,23 @@ if (mmgisglobal.SERVER == 'node' && mmgisglobal.AUTH == 'csso') {

var now = Math.floor(Date.now() / 1000)

if (mmgisglobal.SHOW_AUTH_TIMEOUT) {
var append = false

var elm = document.getElementById('AUTH_TIMEOUT')
if (elm == null) {
elm = document.createElement('div')
append = true
if (result.authenticated) {
const content = `${
result.sub
}<br />Authentication expiring in ${(result.exp - now)
.toString()
.toHHMMSS()}`
if (window._tippyLoginUser && window._tippyLoginUser[0])
window._tippyLoginUser[0].setContent(content)
if (
result.exp - now <= _refreshAuth_expiringLessThan &&
document.getElementById('loginUser') != null
) {
document
.getElementById('loginUser')
.classList.add('attention')
}
elm.id = 'AUTH_TIMEOUT'
elm.style.cssText =
'position:fixed;left:225px;bottom:0px;z-index:11000;font-family:monospace;font-size:11px;color:#121626;'
elm.innerHTML =
'Authentication expiring in ' +
(result.exp - now).toString().toHHMMSS() +
'<div onclick="ssologin()" style="cursor:pointer;">Login again to renew</div>'

if (append) document.body.appendChild(elm)
}

if (result.authenticated) {
if (
mmgisglobal.lastInteraction +
_refreshAuth_interactedPast <=
Expand Down