feat: log error message when JWT secret is less than 32 characters long

breaking change: PostgREST now fails to start or reload the config when the JWT secret is less than 32 characters long.
This commit is contained in:
Laurence Isla
2024-07-04 12:06:24 -05:00
parent d9385a4523
commit e0baf7e78e
7 changed files with 55 additions and 31 deletions
+13
View File
@@ -66,6 +66,19 @@ def test_read_secret_from_stdin_dbconfig(defaultenv):
assert response.status_code == 200
def test_secret_min_length(defaultenv):
"Should log error and not load the config when the secret is shorter than the minimum admitted length"
env = {**defaultenv, "PGRST_JWT_SECRET": "short_secret"}
with run(env=env, no_startup_stdout=False, wait_for_readiness=False) as postgrest:
exitCode = wait_until_exit(postgrest)
assert exitCode == 1
output = postgrest.read_stdout(nlines=1)
assert "The JWT secret must be at least 32 characters long." in output[0]
def test_jwt_errors(defaultenv):
"invalid JWT should throw error"