mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 00:07:22 +00:00
Make Swagger Auth URLs https #107
This commit is contained in:
parent
78f1d99548
commit
1104bde5b4
@ -6,14 +6,23 @@ from project.services.event import upsert_event_category
|
||||
from project.models import Location
|
||||
from flask import url_for
|
||||
from apispec.exceptions import DuplicateComponentNameError
|
||||
import os
|
||||
|
||||
|
||||
@app.before_first_request
|
||||
def add_oauth2_scheme():
|
||||
# At some sites the https scheme is not set yet
|
||||
if os.getenv("AUTHLIB_INSECURE_TRANSPORT", "False").lower() in ["true", "1"]:
|
||||
authorizationUrl = url_for("authorize", _external=True)
|
||||
tokenUrl = url_for("issue_token", _external=True)
|
||||
else:
|
||||
authorizationUrl = url_for("authorize", _external=True, _scheme="https")
|
||||
tokenUrl = url_for("issue_token", _external=True, _scheme="https")
|
||||
|
||||
oauth2_scheme = {
|
||||
"type": "oauth2",
|
||||
"authorizationUrl": url_for("authorize", _external=True),
|
||||
"tokenUrl": url_for("issue_token", _external=True),
|
||||
"authorizationUrl": authorizationUrl,
|
||||
"tokenUrl": tokenUrl,
|
||||
"flow": "accessCode",
|
||||
"scopes": scopes,
|
||||
}
|
||||
|
||||
14
tests/test_init_data.py
Normal file
14
tests/test_init_data.py
Normal file
@ -0,0 +1,14 @@
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize("insecure", [None, "0", "1"])
|
||||
def test_add_oauth2_scheme(app, utils, insecure):
|
||||
import os
|
||||
|
||||
if insecure:
|
||||
os.environ["AUTHLIB_INSECURE_TRANSPORT"] = insecure
|
||||
else:
|
||||
del os.environ["AUTHLIB_INSECURE_TRANSPORT"]
|
||||
|
||||
url = utils.get_url("home")
|
||||
utils.get_ok(url)
|
||||
Loading…
x
Reference in New Issue
Block a user