Use urljoin() to compose OAuth URLs instead of string concatenation

String concatenation is bound to mess up; in this case it was producing
double slashes instead of single ones when `BLENDER_ID_ENDPOINT` ends in
a slash. Since URLs generally end in a slash, this should be supported.
This commit is contained in:
2018-08-29 14:17:17 +02:00
parent e8123b7839
commit 2c40665271
3 changed files with 6 additions and 5 deletions

View File

@@ -129,6 +129,7 @@ class BlenderIdSignIn(OAuthSignIn):
provider_name = 'blender-id'
def __init__(self):
from urllib.parse import urljoin
super().__init__()
base_url = current_app.config['BLENDER_ID_ENDPOINT']
@@ -137,8 +138,8 @@ class BlenderIdSignIn(OAuthSignIn):
name='blender-id',
client_id=self.consumer_id,
client_secret=self.consumer_secret,
authorize_url='%s/oauth/authorize' % base_url,
access_token_url='%s/oauth/token' % base_url,
authorize_url=urljoin(base_url, 'oauth/authorize'),
access_token_url=urljoin(base_url, 'oauth/token'),
base_url='%s/api/' % base_url
)