aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2021-12-15 15:52:23 -0500
committerSawyer Bergeron <sbergeron@iol.unh.edu>2021-12-15 15:52:23 -0500
commit7982defa396392fc3df1afb55f4b0e3f3a38b2e7 (patch)
tree713c208637228cfe3396126669989363ce1cc767
parent2a1c893e5e698f14a844751a2e522d094a0c88b5 (diff)
Only pass alphanumeric usernames
Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu> Change-Id: I005557eca3925677f458c7a2a767a103dcc692fd
-rw-r--r--src/api/models.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/api/models.py b/src/api/models.py
index 8cce5d5..93168f5 100644
--- a/src/api/models.py
+++ b/src/api/models.py
@@ -20,6 +20,7 @@ from django.utils import timezone
import json
import uuid
import yaml
+import re
from booking.models import Booking
from resource_inventory.models import (
@@ -362,7 +363,8 @@ class GeneratedCloudConfig(models.Model):
def _normalize_username(self, username: str) -> str:
# TODO: make usernames posix compliant
- return username
+ s = re.sub(r'\W+', '', username)
+ return s
def _get_ssh_string(self, username: str) -> str:
user = User.objects.get(username=username)