Validate service key name on server side
All requests to post or update service key name are enforced to match: ^[\s a-zA-Z0-9\-_:/]*$
This commit is contained in:
parent
689c26659a
commit
2a1d226684
2 changed files with 17 additions and 4 deletions
|
@ -15,6 +15,7 @@ MAX_USERNAME_LENGTH = 255
|
|||
|
||||
VALID_LABEL_KEY_REGEX = r'^[a-z0-9](([a-z0-9]|[-.](?![.-]))*[a-z0-9])?$'
|
||||
VALID_USERNAME_REGEX = r'^([a-z0-9]+(?:[._-][a-z0-9]+)*)$'
|
||||
VALID_SERVICE_KEY_NAME_REGEX = r'^[\s a-zA-Z0-9\-_:/]*$'
|
||||
|
||||
INVALID_USERNAME_CHARACTERS = r'[^a-z0-9_]'
|
||||
|
||||
|
@ -99,3 +100,7 @@ def validate_postgres_precondition(driver):
|
|||
"pg_trgm" extension does not exists in the database.
|
||||
Please run `CREATE EXTENSION IF NOT EXISTS pg_trgm;` as superuser on this database.
|
||||
""")
|
||||
|
||||
|
||||
def validate_service_key_name(name):
|
||||
return name is None or bool(re.match(VALID_SERVICE_KEY_NAME_REGEX, name))
|
||||
|
|
Reference in a new issue