Improve Gateway authentication and static HTTP fidelity
This commit is contained in:
1 parent
42561bfa34
commit
4ab9411aca
8 files changed
+167
-58
No files matched your search
+18
-6
@@ -2,19 +2,31 @@
|
||||
const form = document.getElementById('login-form');
|
||||
const button = document.getElementById('nsg-x1-logon-button');
|
||||
const message = document.getElementById('message');
|
||||
async function authenticate(path, body) {
|
||||
const response = await fetch(path, {
|
||||
method: 'POST', body, credentials: 'same-origin', redirect: 'error',
|
||||
headers: { Accept: 'application/vnd.citrix.authenticateresponse-1+xml' },
|
||||
signal: AbortSignal.timeout(10000)
|
||||
});
|
||||
if (!response.ok) throw new Error('Request failed');
|
||||
const result = rdx.utils.authentication(await response.text());
|
||||
form.elements.StateContext.value = result.state;
|
||||
// Only the local authentication endpoint can receive form credentials.
|
||||
if (result.postback === '/nf/auth/doAuthentication.do') form.action = result.postback;
|
||||
return result;
|
||||
}
|
||||
const ready = authenticate('/nf/auth/getAuthenticationRequirements.do', new URLSearchParams())
|
||||
.catch(() => null);
|
||||
form.addEventListener('submit', async event => {
|
||||
event.preventDefault();
|
||||
button.disabled = true;
|
||||
message.textContent = '';
|
||||
try {
|
||||
await ready;
|
||||
const body = new URLSearchParams(new FormData(form));
|
||||
body.set('nsg-x1-logon-button', 'Log On');
|
||||
const response = await fetch('/nf/auth/doAuthentication.do', {
|
||||
method: 'POST', body, credentials: 'same-origin', redirect: 'error',
|
||||
signal: AbortSignal.timeout(10000)
|
||||
});
|
||||
if (!response.ok) throw new Error('Request failed');
|
||||
message.textContent = 'Anmeldung fehlgeschlagen. Überprüfen Sie Ihre Zugangsdaten.';
|
||||
const result = await authenticate('/nf/auth/doAuthentication.do', body);
|
||||
message.textContent = result.errors.join(' ') || 'Anmeldung fehlgeschlagen. Überprüfen Sie Ihre Zugangsdaten.';
|
||||
} catch {
|
||||
message.textContent = 'Die Anmeldung ist derzeit nicht möglich. Versuchen Sie es erneut.';
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user