fix: jwt-aud config not failing when set to invalid URI (#4140)
The `jwt-aud` config was not validated when containing ':' character according to RFC 3986. This fix validates it and fails at startup if it is invalid.
This commit is contained in:
@@ -41,12 +41,11 @@ cli:
|
||||
use_defaultenv: true
|
||||
env:
|
||||
PGRST_SERVER_UNIX_SOCKET_MODE: '778'
|
||||
# TODO: Bug needs to be fixed
|
||||
# - name: invalid jwt-aud
|
||||
# expect: error
|
||||
# use_defaultenv: true
|
||||
# env:
|
||||
# PGRST_JWT_AUD: 'htp:/@@localhorst.invalid'
|
||||
- name: invalid jwt-aud
|
||||
expect: error
|
||||
use_defaultenv: true
|
||||
env:
|
||||
PGRST_JWT_AUD: 'http://%%localhorst.invalid'
|
||||
- name: invalid log-level
|
||||
expect: error
|
||||
use_defaultenv: true
|
||||
|
||||
@@ -277,3 +277,15 @@ def test_schema_cache_snapshot(baseenv, key, snapshot_yaml):
|
||||
Dumper=yaml.SafeDumper if key == "dbTimezones" else ExtraNewLinesDumper,
|
||||
)
|
||||
assert formatted == snapshot_yaml
|
||||
|
||||
|
||||
def test_jwt_aud_config_set_to_invalid_uri(defaultenv):
|
||||
"PostgREST should exit with an error message in output if jwt-aud config is set to an invalid URI"
|
||||
env = {
|
||||
**defaultenv,
|
||||
"PGRST_JWT_AUD": "foo://%%$$^^.com",
|
||||
}
|
||||
|
||||
with pytest.raises(PostgrestError):
|
||||
dump = cli(["--dump-config"], env=env).split("\n")
|
||||
assert "jwt-aud should be a string or a valid URI" in dump
|
||||
|
||||
Reference in New Issue
Block a user