providers/oauth2: add migration from "*" to ".*"
closes #2970 Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
3a994ab2a4
commit
1b3aacfa1d
|
@ -84,7 +84,7 @@ class TestAuthorize(OAuthTestCase):
|
||||||
name="test",
|
name="test",
|
||||||
client_id="test",
|
client_id="test",
|
||||||
authorization_flow=create_test_flow(),
|
authorization_flow=create_test_flow(),
|
||||||
redirect_uris="*",
|
redirect_uris="+",
|
||||||
)
|
)
|
||||||
with self.assertRaises(RedirectUriError):
|
with self.assertRaises(RedirectUriError):
|
||||||
request = self.factory.get("/", data={"response_type": "code", "client_id": "test"})
|
request = self.factory.get("/", data={"response_type": "code", "client_id": "test"})
|
||||||
|
|
|
@ -185,6 +185,12 @@ class OAuthAuthorizationParams:
|
||||||
self.provider.save()
|
self.provider.save()
|
||||||
allowed_redirect_urls = self.provider.redirect_uris.split()
|
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:
|
try:
|
||||||
if not any(fullmatch(x, self.redirect_uri) for x in allowed_redirect_urls):
|
if not any(fullmatch(x, self.redirect_uri) for x in allowed_redirect_urls):
|
||||||
LOGGER.warning(
|
LOGGER.warning(
|
||||||
|
|
Reference in New Issue