Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow-core/docs/core-concepts/auth-manager/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ delete the cookie.

response = RedirectResponse(url="/")

secure = conf.has_option("api", "ssl_cert")
secure = bool(conf.get("api", "ssl_cert", fallack=""))
response.set_cookie(COOKIE_NAME_JWT_TOKEN, token, secure=secure)
return response

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from __future__ import annotations

from fastapi import status
from fastapi import Request, status
from starlette.responses import RedirectResponse

from airflow.api_fastapi.auth.managers.base_auth_manager import COOKIE_NAME_JWT_TOKEN
Expand Down Expand Up @@ -57,10 +57,14 @@ def create_token_all_admins() -> LoginResponse:
status_code=status.HTTP_307_TEMPORARY_REDIRECT,
responses=create_openapi_http_exception_doc([status.HTTP_403_FORBIDDEN]),
)
def login_all_admins() -> RedirectResponse:
def login_all_admins(request: Request) -> RedirectResponse:
"""Login the user with no credentials."""
response = RedirectResponse(url=conf.get("api", "base_url", fallback="/"))
secure = conf.has_option("api", "ssl_cert")

# The default config has this as an empty string, so we can't use `has_option`.
# And look at the request info (needs `--proxy-headers` flag to api-server)
secure = request.base_url.scheme == "https" or bool(conf.get("api", "ssl_cert", fallback=""))

response.set_cookie(
COOKIE_NAME_JWT_TOKEN,
SimpleAuthManagerLogin.create_token_all_admins(),
Expand Down