providers/oauth2: fix blank redirect_uri not working with TokenView

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-07-26 11:29:16 +02:00
parent 28f970c795
commit e7b7bfddd6
1 changed files with 9 additions and 1 deletions

View File

@ -126,7 +126,15 @@ class TokenParams:
LOGGER.warning("Missing authorization code") LOGGER.warning("Missing authorization code")
raise TokenError("invalid_grant") raise TokenError("invalid_grant")
if self.redirect_uri not in self.provider.redirect_uris.split(): allowed_redirect_urls = self.provider.redirect_uris.split()
if len(allowed_redirect_urls) < 1:
LOGGER.warning(
"Provider has no allowed redirect_uri set, allowing all.",
allow=self.redirect_uri.lower(),
)
elif self.redirect_uri.lower() not in [
x.lower() for x in allowed_redirect_urls
]:
LOGGER.warning( LOGGER.warning(
"Invalid redirect uri", "Invalid redirect uri",
uri=self.redirect_uri, uri=self.redirect_uri,