Skip to content

AIP-38 Fix safari login loop for non ssl - #47859

Merged
pierrejeambrun merged 1 commit into
apache:mainfrom
astronomer:aip-38-fix-safari-login-loop-dev-mode
Mar 17, 2025
Merged

AIP-38 Fix safari login loop for non ssl#47859
pierrejeambrun merged 1 commit into
apache:mainfrom
astronomer:aip-38-fix-safari-login-loop-dev-mode

Conversation

@pierrejeambrun

@pierrejeambrun pierrejeambrun commented Mar 17, 2025

Copy link
Copy Markdown
Member

Safari has a stricter policy when it comes to secure cookies. I will not allow localhost to use such cookies (https is always required), which is not the case for other browser.

This will at least fix the case for the development mode. i.e safari will work in --dev-mode in breeze or by specifying the env variable and running the api_server.

It will still not work in non dev-mode via breeze though.

There is no issue for real development mode as long as people are using https to connect to their instance.

@ashb

ashb commented Mar 17, 2025

Copy link
Copy Markdown
Member

Does this mean that deployments must be using https as well?

response.set_cookie(COOKIE_NAME_JWT_TOKEN, token, secure=True)

secure = os.environ.get("DEV_MODE", True)
response.set_cookie(COOKIE_NAME_JWT_TOKEN, token, secure=secure)

Check warning

Code scanning / CodeQL

Failure to use secure cookies

Cookie is added without the HttpOnly attribute properly set.
@pierrejeambrun

pierrejeambrun commented Mar 17, 2025

Copy link
Copy Markdown
Member Author

If deployment do not use https safari will block such secure cookies and indeed this will not work.

Is that a popular use case ? Do we need to support safari for that ?

@pierrejeambrun

pierrejeambrun commented Mar 17, 2025

Copy link
Copy Markdown
Member Author

Maybe only enable the secure attribute when there is api.ssl_cert in the conf ? Actually that's a better idea I think, let me update that

@pierrejeambrun
pierrejeambrun force-pushed the aip-38-fix-safari-login-loop-dev-mode branch from f80a6dc to ec208e6 Compare March 17, 2025 13:05
@pierrejeambrun pierrejeambrun changed the title AIP-38 Fix safari login loop in dev mode AIP-38 Fix safari login loop for non ssl Mar 17, 2025
@ashb

ashb commented Mar 17, 2025

Copy link
Copy Markdown
Member

Maybe only enable the secure attribute when there is api.ssl_cert in the conf ? Actually that's a better idea I think, let me update that

That alone isn't enough -- it is much more common to use some kind of proxy in front to handle the TLS termination (ALB, Nginx, Kubernetes Ingress etc.) so we'll have to look at something else (at least as well)

Well, this "fails working" which is the right thing we want for now, so lets go ahead and merge this for now, but probably create an issue to come back and revisit this with reverse proxies in mind.

@ashb

ashb commented Mar 17, 2025

Copy link
Copy Markdown
Member

It's possible we can look at the request.secure or something. We have this in our config

    proxy_fix_x_proto:
      description: |
        Number of values to trust for ``X-Forwarded-Proto``.
        See `Werkzeug: X-Forwarded-For Proxy Fix
        <https://werkzeug.palletsprojects.com/en/2.3.x/middleware/proxy_fix/>`__ for more details.
      version_added: 1.10.7
      type: integer
      example: ~
      default: "1"

Which in turn is available as request.is_secure

Comment thread providers/fab/src/airflow/providers/fab/www/views.py
@pierrejeambrun
pierrejeambrun force-pushed the aip-38-fix-safari-login-loop-dev-mode branch from ec208e6 to fcfb934 Compare March 17, 2025 15:55
@pierrejeambrun
pierrejeambrun force-pushed the aip-38-fix-safari-login-loop-dev-mode branch from fcfb934 to ee28852 Compare March 17, 2025 16:03
@pierrejeambrun
pierrejeambrun merged commit bf25c37 into apache:main Mar 17, 2025
@pierrejeambrun
pierrejeambrun deleted the aip-38-fix-safari-login-loop-dev-mode branch March 17, 2025 17:54
@pierrejeambrun

pierrejeambrun commented Mar 17, 2025

Copy link
Copy Markdown
Member Author

Issue here #47878, I marked it for 3.0 bugfix for now, we can take a look after the feature freeze

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants