Skip to content

Commit 5ec9bfc

Browse files
committed
Fix MSC2966 compliance around redirect_uri validity
Fixes #4528
1 parent 2297f8e commit 5ec9bfc

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

policies/client_registration/client_registration.rego

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ allow if {
1313

1414
parse_uri(url) := obj if {
1515
is_string(url)
16-
url_regex := `^(?P<scheme>[a-z][a-z0-9+.-]*):(?://(?P<host>((?:(?:[a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])\.)*(?:[a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])|127.0.0.1|0.0.0.0|\[::1\])(?::(?P<port>[0-9]+))?))?(?P<path>/[A-Za-z0-9/.-]*)$`
16+
url_regex := `^(?P<scheme>[a-z][a-z0-9+.-]*):(?://(?P<host>((?:(?:[a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])\.)*(?:[a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])|127.0.0.1|0.0.0.0|\[::1\])(?::(?P<port>[0-9]+))?))?(?P<path>/[A-Za-z0-9/.-]*)?(?P<query>\?[A-Za-z0-9/.-=]*)?$`
1717
[matches] := regex.find_all_string_submatch_n(url_regex, url, 1)
1818
obj := {"scheme": matches[1], "authority": matches[2], "host": matches[3], "port": matches[4], "path": matches[5]}
1919
}

policies/client_registration/client_registration_test.rego

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ test_web_redirect_uri if {
212212
client_registration.allow with input.client_metadata as {
213213
"application_type": "web",
214214
"client_uri": "https://example.com/",
215-
"redirect_uris": ["https://example.com/second/callback", "https://example.com/callback"],
215+
"redirect_uris": ["https://example.com/second/callback", "https://example.com/callback", "https://example.com/callback?query=value"],
216216
}
217217
}
218218

@@ -289,6 +289,14 @@ test_web_redirect_uri_localhost_not_allowed if {
289289
}
290290
}
291291

292+
test_web_redirect_uri_with_query if {
293+
client_registration.allow with input.client_metadata as {
294+
"application_type": "web",
295+
"client_uri": "https://example.com/",
296+
"redirect_uris": ["https://example.com/callback?query=value", "https://example.com?query=value"],
297+
}
298+
}
299+
292300
test_native_redirect_uri_allowed if {
293301
# This has all the redirect URIs types we're supporting for native apps
294302
client_registration.allow with input.client_metadata as {
@@ -387,4 +395,4 @@ test_reverse_dns_match if {
387395
client_registration.reverse_dns_match("example.com", "com.example.app")
388396
not client_registration.reverse_dns_match("example.com", "org.example")
389397
not client_registration.reverse_dns_match("test.com", "com.example")
390-
}
398+
}

0 commit comments

Comments
 (0)