Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
103cf8e
Switches server import to parse CSV string input
aschumann-virtualcable Mar 13, 2026
e0877c1
Fixes X2GO client path lookup for correct argument type
aschumann-virtualcable Apr 20, 2026
8438541
Ensures WOL uses current MAC for migrated user-services
aschumann-virtualcable May 14, 2026
1dae131
Corrects 'is_avaliable' typo to 'is_available'
aschumann-virtualcable May 27, 2026
9c45862
feat(snapshot): add snapshot creation and recovery for back to cache …
aschumann-virtualcable Jun 12, 2026
b81d291
feat(snapshot): implement snapshot reuse for back to cache operations
aschumann-virtualcable Jun 15, 2026
cee0c13
feat(snapshot): update logout process to support snapshot reuse on re…
aschumann-virtualcable Jun 15, 2026
5a42f89
refactor(snapshot): remove unused snapshot reuse logic from service p…
aschumann-virtualcable Jun 16, 2026
33ff3bf
Fix concurrent logout destroying valid cache elements in release_from…
janpenitent Jul 1, 2026
bf03194
fix(auth): normalize username to dedupe rows polluted by invisible chars
aschumann-virtualcable Jul 13, 2026
c4ca05d
fix(cache): do not mark a machine returning to cache as usable before…
aschumann-virtualcable Jul 13, 2026
299b025
fix(auth): migrate existing user rows and use NFC on username normali…
aschumann-virtualcable Jul 13, 2026
e606d7e
fix(auth): normalize username on every user lookup path
aschumann-virtualcable Jul 14, 2026
a470dba
fix(auth): honor prefix in 'prefix:attr' regex field syntax
aschumann-virtualcable Jul 20, 2026
583d4b1
fix(auth): support attribute extraction with '**' prefix syntax
aschumann-virtualcable Jul 20, 2026
425b195
fix(SimpleLDAP): don't fail the connection test on sizeLimitExceeded
aschumann-virtualcable Jul 22, 2026
eeaf44d
Add OpenShift service implementation and related components
aschumann-virtualcable Jul 27, 2026
de4165c
Merge 'backport-openshift-v4.0' into fixes/v4.0-openshift
aschumann-virtualcable Aug 6, 2026
c97adbf
Merge 'dev/devel/fix-wol-current-mac-for-migrations' into fixes/v4.0-…
aschumann-virtualcable Aug 6, 2026
5898115
Merge 'dev/v4.0-fix-auth-regex-colon-prefix' into fixes/v4.0-auth-reg…
aschumann-virtualcable Aug 6, 2026
f8ae18d
Merge 'dev/v4.0-isavaliable-correction' into fixes/v4.0-isavaliable-typo
aschumann-virtualcable Aug 6, 2026
448997b
Merge 'dev/v4.0-new-feature-back-to-cache-snapshot-recovery' into fix…
aschumann-virtualcable Aug 6, 2026
35de42a
Merge 'dev/v4.0/fix-back-to-cache-timing' into fixes/v4.0-back-to-cac…
aschumann-virtualcable Aug 6, 2026
e9d0915
Merge 'dev/v4.0/fix-duplicate-users' into fixes/v4.0-duplicate-users
aschumann-virtualcable Aug 6, 2026
f5cb258
Merge 'fix-logout-cache-race' into fixes/v4.0-logout-cache-race
aschumann-virtualcable Aug 6, 2026
90cdba3
Merge 'fix/simpleldap-test-sizelimit' into fixes/v4.0-simpleldap-size…
aschumann-virtualcable Aug 6, 2026
b26c8ab
Merge 'dev/andres/v4.0-importcsv' into fixes/v4.0-importcsv
aschumann-virtualcable Aug 6, 2026
b8b1486
Merge 'dev/andres/v4.0-fix-x2go-path-tunnel' into fixes/v4.0-x2go-pat…
aschumann-virtualcable Aug 6, 2026
f5b66a2
chore(mfa): trace TOTP validation to diagnose rejected codes
janpenitent Aug 19, 2026
2db1b5c
fix(tests): do not depend on DNS in physical machines migration test
janpenitent Aug 20, 2026
9922bd2
chore(mfa): log only rejected TOTP codes
janpenitent Aug 20, 2026
a47f053
fix(auth): map authenticator errors to access denied
janpenitent Sep 23, 2026
4fc9019
test(auth): pin that only the base authenticator error is access denied
janpenitent Sep 23, 2026
6687598
fix(auth): redirect to OAuth2 provider logout URL on logout
aschumann-virtualcable Sep 23, 2026
f95e8bd
Proxmox: do not treat lookup errors as a completed deletion
aschumann-virtualcable Sep 25, 2026
c05f6cd
fix(openshift): use ReadWriteMany for cloned DataVolumes when source …
aschumann-virtualcable Sep 29, 2026
824c5d8
fix(deferred-deletion): release the deleting marker when the worker s…
aschumann-virtualcable Oct 1, 2026
b1cd1dc
fix(proxmox): do not delete a publication template while machines sti…
aschumann-virtualcable Oct 1, 2026
5705cb3
Use INFO_STATES to decide if a Proxmox publication still has machines
aschumann-virtualcable Oct 1, 2026
7b90308
Add import CSV for federated authenticators and update admin GUI
aschumann-virtualcable Oct 1, 2026
7476a53
Rebuild admin bundle: show Import CSV button and add template download
aschumann-virtualcable Oct 1, 2026
6e0a2fa
Merge remote-tracking branch 'origin/v4.0' into backport-openshift-v4.0
aschumann-virtualcable Oct 3, 2026
0da1c78
Merge remote-tracking branch 'origin/v4.0' into fixes/v4.0-auth-regex…
aschumann-virtualcable Oct 3, 2026
91b9568
Merge remote-tracking branch 'origin/v4.0' into fixes/v4.0-back-to-ca…
aschumann-virtualcable Oct 3, 2026
be9f143
Merge remote-tracking branch 'origin/v4.0' into fixes/v4.0-duplicate-…
aschumann-virtualcable Oct 3, 2026
b07c9fb
Merge remote-tracking branch 'origin/v4.0' into fixes/v4.0-importcsv
aschumann-virtualcable Oct 3, 2026
d58a7af
Merge remote-tracking branch 'origin/v4.0' into fixes/v4.0-isavaliabl…
aschumann-virtualcable Oct 3, 2026
a4b5063
Merge remote-tracking branch 'origin/v4.0' into fixes/v4.0-logout-cac…
aschumann-virtualcable Oct 3, 2026
d65b4e5
Merge remote-tracking branch 'origin/v4.0' into fixes/v4.0-openshift
aschumann-virtualcable Oct 3, 2026
4a82c7f
Merge remote-tracking branch 'origin/v4.0' into fixes/v4.0-simpleldap…
aschumann-virtualcable Oct 3, 2026
4f56333
Merge remote-tracking branch 'origin/v4.0' into fixes/v4.0-snapshot-r…
aschumann-virtualcable Oct 3, 2026
3886f64
Merge remote-tracking branch 'origin/v4.0' into fixes/v4.0-wol-curren…
aschumann-virtualcable Oct 3, 2026
305fbd3
Merge remote-tracking branch 'origin/v4.0' into fixes/v4.0-x2go-path-…
aschumann-virtualcable Oct 3, 2026
4d6db18
fix(proxmox): wait for the VM disks to disappear before reporting the…
aschumann-virtualcable Oct 4, 2026
e8533e1
Revert the machine check in the Proxmox publication delete
aschumann-virtualcable Oct 4, 2026
9b96895
fix(proxmox): do not let a recorded disk list outlive the vm it belon…
janpenitent Oct 5, 2026
8e02028
fix(proxmox): check the disks of a deleted vm without filtering by it…
janpenitent Oct 6, 2026
99398ff
fix(proxmox): encode volume slashes when deleting disks and protect p…
aschumann-virtualcable Oct 6, 2026
5b29bff
fix(proxmox): log warning when pre-delete disk inspection fails
aschumann-virtualcable Oct 6, 2026
26c068c
Merge remote-tracking branch 'origin/fixes/v4.0-auth-exception-error-…
aschumann-virtualcable Oct 9, 2026
8a60435
Merge remote-tracking branch 'origin/fixes/v4.0-auth-regex-colon-pref…
aschumann-virtualcable Oct 9, 2026
84ffb77
Merge remote-tracking branch 'origin/fixes/v4.0-back-to-cache-timing'…
aschumann-virtualcable Oct 9, 2026
8bdea5d
Merge remote-tracking branch 'origin/fixes/v4.0-duplicate-users' into…
aschumann-virtualcable Oct 9, 2026
9216110
Merge remote-tracking branch 'origin/fixes/v4.0-importcsv' into v4.0-…
aschumann-virtualcable Oct 9, 2026
26d215e
Merge remote-tracking branch 'origin/fixes/v4.0-importcsv-federated' …
aschumann-virtualcable Oct 9, 2026
bbe46dc
Merge remote-tracking branch 'origin/fixes/v4.0-isavaliable-typo' int…
aschumann-virtualcable Oct 9, 2026
bb0d73a
Merge remote-tracking branch 'origin/fixes/v4.0-logout-cache-race' in…
aschumann-virtualcable Oct 9, 2026
9432db8
Merge remote-tracking branch 'origin/fixes/v4.0-migration-test-withou…
aschumann-virtualcable Oct 9, 2026
0a58a1d
Merge remote-tracking branch 'origin/fixes/v4.0-oauth2-logout-redirec…
aschumann-virtualcable Oct 9, 2026
613b800
Merge remote-tracking branch 'origin/fixes/v4.0-openshift' into v4.0-…
aschumann-virtualcable Oct 9, 2026
f77b6e4
Merge remote-tracking branch 'origin/backport-openshift-v4.0' into v4…
aschumann-virtualcable Oct 9, 2026
68e706e
Merge remote-tracking branch 'origin/fixes/v4.0-proxmox-is-deleted-fa…
aschumann-virtualcable Oct 9, 2026
4c2c097
Merge remote-tracking branch 'origin/fixes/v4.0-proxmox-publication-d…
aschumann-virtualcable Oct 9, 2026
55416fe
Merge remote-tracking branch 'origin/fixes/v4.0-simpleldap-sizelimit'…
aschumann-virtualcable Oct 9, 2026
c8eda4d
Merge remote-tracking branch 'origin/fixes/v4.0-snapshot-recovery' in…
aschumann-virtualcable Oct 9, 2026
0af45b0
Merge remote-tracking branch 'origin/fixes/v4.0-totp-validation-loggi…
aschumann-virtualcable Oct 9, 2026
7703063
Merge remote-tracking branch 'origin/fixes/v4.0-wol-current-mac' into…
aschumann-virtualcable Oct 9, 2026
cfb5349
Merge remote-tracking branch 'origin/fixes/v4.0-x2go-path-tunnel' int…
aschumann-virtualcable Oct 9, 2026
ba4289a
fix(proxmox): rename is_avaliable overrides missed by the typo fix
aschumann-virtualcable Oct 9, 2026
15eafbd
test(userservice): seed the instance with the recorded unique_id befo…
aschumann-virtualcable Oct 9, 2026
dcfa519
Merge remote-tracking branch 'origin/v4.0' into dev/v4.0-fixes
aschumann-virtualcable Oct 16, 2026
5680b45
Revert "fix(proxmox): rename is_avaliable overrides missed by the typ…
aschumann-virtualcable Oct 16, 2026
16f3b4c
Revert "Corrects 'is_avaliable' typo to 'is_available'"
aschumann-virtualcable Oct 16, 2026
7d26644
fix(openshift): keep the v4.0 is_avaliable name for the service avail…
aschumann-virtualcable Oct 16, 2026
9b4cff3
Revert "Merge remote-tracking branch 'origin/backport-openshift-v4.0'…
aschumann-virtualcable Oct 16, 2026
da2a8da
Revert "Merge remote-tracking branch 'origin/fixes/v4.0-openshift' in…
aschumann-virtualcable Oct 16, 2026
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
77 changes: 77 additions & 0 deletions server/samples/uds_dedupe_users.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
-- -*- coding: utf-8 -*-
--
-- DIAGNOSTIC ONLY. Lists the users duplicated by invisible characters
-- (BOM U+FEFF, ZWSP U+200B, ZWNJ U+200C, ZWJ U+200D, soft hyphen U+00AD, ...)
-- in the uds_user.name column.
--
-- This script does NOT modify anything. The actual cleanup (merging the
-- duplicates and keeping their groups, permissions, assigned services,
-- properties and logs) is done by the data migration
-- `uds/migrations/0048_dedupe_user_names.py`, which runs on upgrade.
-- Doing it by hand in SQL would silently drop the assigned user services of
-- the merged rows (FK CASCADE), so it is deliberately not offered here.
--
-- mysql ... < samples/uds_dedupe_users.sql
--
-- MySQL 8.0+ (CTE + REGEXP_REPLACE).
--
-- The invisible-char list below is only used to *report*, and covers what we
-- have seen in production. The migration does not need such a list: it uses the
-- Unicode category of every code point.

WITH cleaned AS (
SELECT
manager_id,
TRIM(REGEXP_REPLACE(REGEXP_REPLACE(REGEXP_REPLACE(REGEXP_REPLACE(REGEXP_REPLACE(
name,
_utf8mb4'', ''), -- BOM U+FEFF
_utf8mb4'​', ''), -- ZWSP U+200B
_utf8mb4'‌', ''), -- ZWNJ U+200C
_utf8mb4'‍', ''), -- ZWJ U+200D
_utf8mb4'­', '') -- soft hyp U+00AD
) AS clean_name
FROM uds_user
),
groups_ AS (
SELECT manager_id, clean_name, COUNT(*) AS n
FROM cleaned
GROUP BY manager_id, clean_name
HAVING COUNT(*) > 1
)
SELECT
g.manager_id,
a.name AS authenticator,
g.clean_name,
g.n AS duplicates
FROM groups_ g
JOIN uds_authenticator a ON a.id = g.manager_id
ORDER BY g.n DESC, a.name, g.clean_name;


-- ------------------------------------------------------------------------
-- PostgreSQL variant of the same query.
-- psql ... -f samples/uds_dedupe_users.sql
--
-- WITH cleaned AS (
-- SELECT
-- manager_id,
-- TRIM(
-- REGEXP_REPLACE(
-- REGEXP_REPLACE(
-- REGEXP_REPLACE(
-- REGEXP_REPLACE(
-- REGEXP_REPLACE(name, E'', '', 'g'),
-- E'​', '', 'g'),
-- E'‌', '', 'g'),
-- E'‍', '', 'g'),
-- E'­', '', 'g')
-- ) AS clean_name
-- FROM uds_user
-- ),
-- groups_ AS (
-- SELECT manager_id, clean_name, COUNT(*) AS n
-- FROM cleaned GROUP BY manager_id, clean_name HAVING COUNT(*) > 1
-- )
-- SELECT g.manager_id, a.name AS authenticator, g.clean_name, g.n AS duplicates
-- FROM groups_ g JOIN uds_authenticator a ON a.id = g.manager_id
-- ORDER BY g.n DESC, a.name, g.clean_name;
5 changes: 4 additions & 1 deletion server/src/uds/REST/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from uds.core.util.config import GlobalConfig
from uds.core.auths.auth import root_user
from uds.core.util import net
from uds.core.util.auth import normalize_username
from uds.models import Authenticator, User
from uds.core.managers.crypto import CryptoManager

Expand Down Expand Up @@ -373,7 +374,9 @@ def get_user(self) -> 'User':
):
return root_user()

return Authenticator.objects.get(pk=auth_id).users.get(name=username)
# Normalized as in Authenticator.get_or_create_user: the stored row is clean, so
# a session username carrying invisible chars would not match it
return Authenticator.objects.get(pk=auth_id).users.get(name=normalize_username(username))

def get_param(self, *names: str) -> str:
"""
Expand Down
18 changes: 12 additions & 6 deletions server/src/uds/REST/methods/servers_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"""
import logging
import typing
import io
import csv

from django.utils.translation import gettext
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -345,11 +347,11 @@ def maintenance(self, parent: 'Model', id: str) -> typing.Any:

def importcsv(self, parent: 'Model') -> typing.Any:
"""
We receive a json with string[][] format with the data.
We receive a csv string with the data.
Has no header, only the data.
"""
parent = ensure.is_instance(parent, models.ServerGroup)
data: list[list[str]] = self._params.get('data', [])
data: typing.Any = self._params.get('data', '')
logger.debug('Data received: %s', data)
# String lines can have 1, 2 or 3 fields.
# if 1, it's a IP
Expand All @@ -358,16 +360,20 @@ def importcsv(self, parent: 'Model') -> typing.Any:
# if ip is empty and has a hostname, it will be kept, but if it has no hostname, it will be skipped
# If the IP is invalid and has no hostname, it will be skipped
import_errors: list[str] = []
for line_number, row in enumerate(data, 1):

f = io.StringIO('\n'.join(','.join(row) for row in data))
reader: typing.Iterable[list[str]] = csv.reader(f)

for line_number, row in enumerate(reader, 1):
if len(row) == 0:
continue
hostname = row[0].strip()
hostname = row[0]
ip = ''
mac = consts.MAC_UNKNOWN
if len(row) > 1:
ip = row[1].strip()
ip = row[1]
if len(row) > 2:
mac = row[2].strip().upper().strip() or consts.MAC_UNKNOWN
mac = row[2].upper() or consts.MAC_UNKNOWN
if mac and not net.is_valid_mac(mac):
import_errors.append(f'Line {line_number}: MAC {mac} is invalid, skipping')
continue # skip invalid macs
Expand Down
78 changes: 78 additions & 0 deletions server/src/uds/REST/methods/users_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@

"""
Author: Adolfo Gómez, dkmaster at dkmon dot com
Author: Andres Schumann, aschumann at virtualcable dot es
"""
import logging
import typing
import collections.abc
import io
import csv

from django.utils.translation import gettext as _
from django.forms.models import model_to_dict
Expand All @@ -42,6 +45,7 @@

from uds.core.auths.user import User as AUser
from uds.core.util import log, ensure
from uds.core.util.auth import normalize_username
from uds.core.util.model import process_uuid, sql_stamp_seconds
from uds.models import Authenticator, User, Group, ServicePool
from uds.core.managers.crypto import CryptoManager
Expand Down Expand Up @@ -84,6 +88,8 @@ class Users(DetailHandler):
'clean_related',
'add_to_group',
'enable_client_logging',
'importcsv',
'import',
]

def get_items(self, parent: 'Model', item: typing.Optional[str]) -> typing.Any:
Expand Down Expand Up @@ -210,6 +216,12 @@ def save_item(self, parent: 'Model', item: typing.Optional[str]) -> typing.Any:
'staff_member',
'is_admin',
]
# Normalized as on login, or a name pasted with invisible chars (BOM, zero-width, ...)
# would create a row that no authenticated user could ever match.
# Note this also turns an all-invisible name into an empty one, rejected right below.
if 'name' in self._params:
self._params['name'] = normalize_username(self._params['name'])

if self._params.get('name', '').strip() == '':
raise exceptions.rest.RequestError(_('Username cannot be empty'))

Expand Down Expand Up @@ -360,6 +372,72 @@ def enable_client_logging(self, parent: 'Model', item: str) -> dict[str, str]:

return {'status': 'ok'}

def importcsv(self, parent: 'Model') -> typing.Any:
auth = ensure.is_instance(parent, Authenticator)
if not auth.get_instance().external_source:
raise exceptions.rest.RequestError(
_('User import is only supported for external/federated authenticators')
)

data: typing.Any = self._params.get('data', '')
has_header: bool = bool(self._params.get('has_header', False))
separator: str = str(self._params.get('separator', ','))

if isinstance(data, list):
rows: list[list[str]] = [
[str(cell).strip() for cell in row]
for row in data
if isinstance(row, (list, tuple))
]
else:
if separator == 'tab':
separator = '\t'
f = io.StringIO(str(data))
reader = csv.reader(f, delimiter=separator)
rows = [[cell.strip() for cell in row] for row in reader]

if has_header and rows:
rows = rows[1:]

existing_usernames: set[str] = set(auth.users.values_list('name', flat=True))
errors: list[str] = []

for line_num, row in enumerate(rows, 1):
if not row or not any(row):
continue
username = row[0].strip()
if not username:
errors.append(_('Line {}: username is required').format(line_num))
continue
if username in existing_usernames:
errors.append(_('Line {}: user {} already exists').format(line_num, username))
continue

comments = ''
if len(row) > 1 and row[1].strip():
comments = f'{row[1].strip()} (import)'

try:
auth.users.create(
name=username,
real_name=username,
comments=comments,
state=State.ACTIVE,
staff_member=False,
is_admin=False,
mfa_data='',
password='',
)
existing_usernames.add(username)
except Exception as e:
logger.error('Error importing user %s: %s', username, e)
errors.append(_('Line {}: error creating user {}: {}').format(line_num, username, e))

return errors


setattr(Users, 'import', Users.importcsv)


class Groups(DetailHandler):
custom_methods = ['services_pools', 'users']
Expand Down
2 changes: 1 addition & 1 deletion server/src/uds/auths/OAuth2/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def logout(
return types.auth.SUCCESS_AUTH

return types.auth.AuthenticationResult(
types.auth.AuthenticationState.SUCCESS,
types.auth.AuthenticationState.REDIRECT,
url=self.logout_url.value.replace('{token}', urllib.parse.quote(token)),
)

Expand Down
5 changes: 5 additions & 0 deletions server/src/uds/auths/SimpleLDAP/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ def ensure_at_least_one(filter: str, error_msg: str) -> None:
scope=ldaputil.SCOPE_SUBTREE, # pyright: ignore reportGeneralTypeIssues
filterstr=f'(&(objectClass={self.group_class.as_str()})({self.group_id_attr.as_str()}=*))',
attrlist=[self.member_attr.as_str()],
sizelimit=LDAP_RESULT_LIMIT,
)
)
if not res:
Expand All @@ -548,6 +549,10 @@ def ensure_at_least_one(filter: str, error_msg: str) -> None:
break
if ok is False:
raise Exception(_('Can\'t locate any group with the membership attribute specified'))
except ldap.SIZELIMIT_EXCEEDED: # type: ignore
# Server reports the limit as an error and drops the partial results,
# but reaching it already proves that matching groups exist
return types.core.TestResult(True)
except Exception as e:
return types.core.TestResult(False, str(e))

Expand Down
5 changes: 4 additions & 1 deletion server/src/uds/core/managers/servers_api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

from uds import models
from uds.core import consts, osmanagers, types
from uds.core.managers.userservice import UserServiceManager
from uds.core.util import log
from uds.core.util.model import sql_now
from uds.REST.utils import rest_result
Expand Down Expand Up @@ -146,7 +147,9 @@ def process_logout(server: 'models.Server', data: dict[str, typing.Any]) -> typi
osmanager: typing.Optional[osmanagers.OSManager] = userservice.get_osmanager_instance()
if not osmanager or osmanager.is_removable_on_logout(userservice):
logger.debug('Removable on logout: %s', osmanager)
userservice.release()
# Use release_from_logout (same as actor logout) so pools that allow putting
# back to cache (e.g. snapshot reuse) return the machine instead of destroying it
UserServiceManager.manager().release_from_logout(userservice)

return rest_result(consts.OK)

Expand Down
Loading
Loading