Fix absolute urls for swagger-ui oauth settings

This commit is contained in:
Cristi Vîjdea
2018-12-21 12:40:31 +02:00
parent 9d933a9745
commit de950461c7
7 changed files with 15 additions and 22 deletions
+4 -4
View File
@@ -3,7 +3,7 @@ import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
from django.urls import reverse_lazy
from testproj.util import full_url_lazy, static_lazy
from testproj.util import static_lazy
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@@ -100,9 +100,9 @@ OAUTH2_CLIENT_SECRET = '5FvYALo7W4uNnWE2ySw7Yzpkxh9PSf5GuY37RvOys00ydEyph64dbl1E
'AKoz0JpiVQtq0DUnsxNhU3ubrJgZ9YbtiXymbLGJq8L7n4fiER7gXbXaNSbze3BN'
OAUTH2_APP_NAME = 'drf-yasg OAuth2 provider'
OAUTH2_REDIRECT_URL = full_url_lazy(static_lazy('drf-yasg/swagger-ui-dist/oauth2-redirect.html'))
OAUTH2_AUTHORIZE_URL = full_url_lazy(reverse_lazy('oauth2_provider:authorize'))
OAUTH2_TOKEN_URL = full_url_lazy(reverse_lazy('oauth2_provider:token'))
OAUTH2_REDIRECT_URL = static_lazy('drf-yasg/swagger-ui-dist/oauth2-redirect.html')
OAUTH2_AUTHORIZE_URL = reverse_lazy('oauth2_provider:authorize')
OAUTH2_TOKEN_URL = reverse_lazy('oauth2_provider:token')
# drf-yasg
SWAGGER_SETTINGS = {
-10
View File
@@ -4,14 +4,4 @@ from django.utils.encoding import force_text
from django.utils.functional import lazy
def full_url(absolute_path):
try:
return "http://test.local:8002" + force_text(absolute_path)
except NoReverseMatch:
# if absolute_path is a resolve_lazy, it might point to an invalid name
# just ignore it if it does
return "http://test.local:8002/no-reverse-match/"
full_url_lazy = lazy(full_url, str)
static_lazy = lazy(static, str)
@@ -1,9 +1,6 @@
# Generated by Django 2.1.3 on 2018-12-19 07:57
from django.conf import settings
from django.contrib.staticfiles.templatetags.staticfiles import static
from django.db import migrations, IntegrityError
from testproj.util import full_url_lazy
from django.db import migrations
def add_oauth_apps(apps, schema_editor):