Api v1.13.0 release (#1347)
* refactor(chalice): configurable documentation
This commit is contained in:
parent
7271eacbdf
commit
84a731c8aa
5 changed files with 28 additions and 8 deletions
|
|
@ -46,8 +46,8 @@ async def lifespan(app: FastAPI):
|
|||
await pg_client.terminate()
|
||||
|
||||
|
||||
app = FastAPI(root_path="/api", docs_url=config("docs_url", default=""), redoc_url=config("redoc_url", default=""),
|
||||
lifespan=lifespan)
|
||||
app = FastAPI(root_path=config("root_path", default="/api"), docs_url=config("docs_url", default=""),
|
||||
redoc_url=config("redoc_url", default=""), lifespan=lifespan)
|
||||
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ async def lifespan(app: FastAPI):
|
|||
await pg_client.terminate()
|
||||
|
||||
|
||||
app = FastAPI(root_path="/alerts", docs_url=config("docs_url", default=""), redoc_url=config("redoc_url", default=""),
|
||||
lifespan=lifespan)
|
||||
app = FastAPI(root_path=config("root_path", default="/alerts"), docs_url=config("docs_url", default=""),
|
||||
redoc_url=config("redoc_url", default=""), lifespan=lifespan)
|
||||
logging.info("============= ALERTS =============")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ async def lifespan(app: FastAPI):
|
|||
await pg_client.terminate()
|
||||
|
||||
|
||||
app = FastAPI(root_path="/api", docs_url=config("docs_url", default=""), redoc_url=config("redoc_url", default=""),
|
||||
lifespan=lifespan)
|
||||
app = FastAPI(root_path=config("root_path", default="/api"), docs_url=config("docs_url", default=""),
|
||||
redoc_url=config("redoc_url", default=""), lifespan=lifespan)
|
||||
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
||||
|
||||
|
||||
|
|
@ -106,4 +106,4 @@ app.include_router(v1_api.app_apikey)
|
|||
app.include_router(v1_api_ee.app_apikey)
|
||||
app.include_router(health.public_app)
|
||||
app.include_router(health.app)
|
||||
app.include_router(health.app_apikey)
|
||||
app.include_router(health.app_apikey)
|
||||
|
|
|
|||
|
|
@ -71,16 +71,35 @@ else:
|
|||
|
||||
def init_saml_auth(req):
|
||||
# auth = OneLogin_Saml2_Auth(req, custom_base_path=environ['SAML_PATH'])
|
||||
print("--------------------")
|
||||
print(dir(req))
|
||||
print("--------------------")
|
||||
if idp is None:
|
||||
raise Exception("No SAML2 config provided")
|
||||
return OneLogin_Saml2_Auth(req, old_settings=SAML2)
|
||||
|
||||
|
||||
async def prepare_request(request: Request):
|
||||
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
|
||||
print(SAML2)
|
||||
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
|
||||
request.args = dict(request.query_params).copy() if request.query_params else {}
|
||||
form: FormData = await request.form()
|
||||
request.form = dict(form)
|
||||
cookie_str = request.headers.get("cookie", "")
|
||||
print(">>>>>>>>>>>>>>>>>>>>>>>>")
|
||||
print(dir(request))
|
||||
print(">>>>>>>>>>>>>>>>>>>>>>>>")
|
||||
print(request.url)
|
||||
print(request.url.port)
|
||||
print(request.url.path)
|
||||
# print(request.base_url)
|
||||
# print(request.base_url.path)
|
||||
# print(request.base_url.port)
|
||||
if request.url.port is None:
|
||||
# request.url.port = 443
|
||||
request.url.__setattr__("port",443)
|
||||
print(">>>>>>>>>>>>>>>>>>>>>>>>")
|
||||
if "session" in cookie_str:
|
||||
cookie = cookies.SimpleCookie()
|
||||
cookie.load(cookie_str)
|
||||
|
|
@ -101,6 +120,7 @@ async def prepare_request(request: Request):
|
|||
url_data = urlparse('%s://%s' % (proto, headers['host']))
|
||||
path = request.url.path
|
||||
site_url = urlparse(config("SITE_URL"))
|
||||
# to support custom port without changing IDP config
|
||||
host_suffix = ""
|
||||
if site_url.port is not None and request.url.port is None:
|
||||
host_suffix = f":{site_url.port}"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ from starlette.responses import RedirectResponse
|
|||
@public_app.get("/sso/saml2/", tags=["saml2"])
|
||||
async def start_sso(request: Request):
|
||||
request.path = ''
|
||||
req = await prepare_request(request=request)
|
||||
req = await prepare_request(request=request, initial=True)
|
||||
auth = init_saml_auth(req)
|
||||
sso_built_url = auth.login()
|
||||
return RedirectResponse(url=sso_built_url)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue