providers/oauth2: add migration from "*" to ".*"

closes #2970

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-05-27 10:18:27 +02:00
parent acf1ded1d4
commit 2b68363452
2 changed files with 7 additions and 1 deletions

View File

@ -84,7 +84,7 @@ class TestAuthorize(OAuthTestCase):
name="test",
client_id="test",
authorization_flow=create_test_flow(),
redirect_uris="*",
redirect_uris="+",
)
with self.assertRaises(RedirectUriError):
request = self.factory.get("/", data={"response_type": "code", "client_id": "test"})

View File

@ -185,6 +185,12 @@ class OAuthAuthorizationParams:
self.provider.save()
allowed_redirect_urls = self.provider.redirect_uris.split()
if self.provider.redirect_uris == "*":
LOGGER.info("Converting redirect_uris to regex", redirect=self.redirect_uri)
self.provider.redirect_uris = ".*"
self.provider.save()
allowed_redirect_urls = self.provider.redirect_uris.split()
try:
if not any(fullmatch(x, self.redirect_uri) for x in allowed_redirect_urls):
LOGGER.warning(