1
0
mirror of https://github.com/dkmstr/openuds-gui.git synced 2024-10-26 08:55:23 +03:00

Merge remote-tracking branch 'origin/v3.5'

This commit is contained in:
Adolfo Gómez García 2022-05-20 09:02:27 +02:00
commit 577217288d
7 changed files with 33 additions and 16 deletions

View File

@ -1,7 +1,7 @@
<ng-container *ngIf="api.config.urls.launch == ''">
<ng-container *ngIf="api.config.urls.launch === ''">
<!-- Lang change form -->
<form id="form_language" action="{{ api.config.urls.changeLang }}" method="post">
<input type="hidden" name="{{ api.config.csrf_field }}" value="{{ api.config.csrf }}">
<input type="hidden" name="{{ api.csrfField }}" value="{{ api.csrfToken }}">
<input id="id_language" type="hidden" name="language" value="{{ lang.id }}" />
</form>

View File

@ -28,8 +28,8 @@ export class LoginComponent implements OnInit {
const form = document.getElementById('loginform') as HTMLFormElement;
form.action = this.api.config.urls.login;
const input = document.getElementById('token') as HTMLInputElement;
input.name = this.api.config.csrf_field;
input.value = this.api.config.csrf;
input.name = this.api.csrfField;
input.value = this.api.csrfToken;
this.auth = document.getElementById('authenticator') as HTMLInputElement;
if (this.auths.length > 0) {

View File

@ -44,8 +44,6 @@ export interface UDSConfig {
readonly available_languages: Lang[];
readonly authenticators: Authenticator[];
readonly os: string;
readonly csrf_field: string;
readonly csrf: string;
readonly reload_time: number;
readonly site_name: string;
readonly site_copyright_info: string;

View File

@ -18,6 +18,7 @@ import { UDSApiServiceType } from './uds-api.service-type';
import { environment } from '../environments/environment';
declare const udsData: any;
declare const csrf: any;
const DARK_THEME = 'dark-theme';
const LIGHT_THEME = 'light-theme';
@ -45,6 +46,14 @@ export class UDSApiService implements UDSApiServiceType {
return udsData.config;
}
get csrfField(): string {
return csrf.csrfField;
}
get csrfToken(): string {
return csrf.csrfToken;
}
/**
* Gets staff information
*/

View File

@ -80,6 +80,12 @@
return s;
}
};
// CSRF
var csrf = {
csrfToken: 'cuZKC1fLfSXmiSO4UiIho0tr7nzPbagTVHWQFIKNhiOg2olryXcMvAYXHUUMzuBs',
csrfField: 'csrfmiddlewaretoken'
};
// ENDCSRF
if (window.top !== window.self) {
window.location.href = 'https://www.udsenterprise.com';

View File

@ -50,9 +50,7 @@ var udsData = {
"user": "172.27.0.8"
},
"config": {
"csrf_field": "csrfmiddlewaretoken",
"version_stamp": "20180831-DEVEL",
"csrf": "cuZKC1fLfSXmiSO4UiIho0tr7nzPbagTVHWQFIKNhiOg2olryXcMvAYXHUUMzuBs",
"available_languages": [{
"name": "Spanish",
"id": "es"

View File

@ -31,6 +31,7 @@ import os
import shutil
import glob
import re
import typing
DIST = 'dist'
SRC = 'src'
@ -39,7 +40,7 @@ STATIC = 'static/modern'
TEMPLATE = 'templates/uds/modern'
def mkPath(path):
def mkPath(path) -> None:
folder = ''
for p in path.split(os.path.sep):
folder = os.path.join(folder, p)
@ -49,7 +50,7 @@ def mkPath(path):
pass # Already exits, ignore
def locateFiles(files, folder, extension):
def locateFiles(files: typing.List[str], folder: str, extension: str) -> None:
for f in glob.glob(folder+"/*"):
if os.path.isdir(f):
# Recurse
@ -59,23 +60,25 @@ def locateFiles(files, folder, extension):
files.append(f)
def locateHtmlFiles():
files = []
def locateHtmlFiles() -> typing.List[str]:
files: typing.List[str] = []
locateFiles(files, SRC, 'html')
return files
def locateTypeScriptFiles():
files = []
def locateTypeScriptFiles() -> typing.List[str]:
files: typing.List[str] = []
locateFiles(files, SRC, 'ts')
return files
def fixIndex():
def fixIndex() -> None:
print('Fixing index.html...')
translations = '<script type="text/javascript" src="{% url \'utility.jsCatalog\' LANGUAGE_CODE %}"></script>'
jsdata = '<script type="text/javascript" src="{% url \'utility.js\' %}"></script>'
# Change index.html, to include django required staff
csrfData = "var csrf = { csrfToken: '{{ csrf_token }}', csrfField: '{{ csrf_field }}' };"
csrfRE = re.compile(r'// CSRF.*// ENDCSRF', re.MULTILINE | re.DOTALL)
# Change index.html, to include django required stuff
translatePattern = re.compile(
'<!-- DYNAMIC_DATA -->.*<!-- ENDDYNAMIC_DATA -->', re.MULTILINE | re.DOTALL)
with open(os.path.join(DIST, 'index.html'), 'r', encoding='utf8') as f:
@ -88,6 +91,9 @@ def fixIndex():
# Add link rel style.. to our theme stylesheet AFTER all index styles
html = re.sub('</head>',
'<link rel="stylesheet" href="{% url \'custom\' \'styles.css\' %}"></head>', html)
html = csrfRE.sub(csrfData, html)
html = translatePattern.sub(translations + jsdata, html)
with open(os.path.join(os.path.join(UDS, TEMPLATE), 'index.html'), 'w', encoding='utf8') as f:
f.write(translatePattern.sub(translations + jsdata, html))