Skip to content

CSRF token to expire with session when config file exists #36869

Closed

Description

@NickiForte

Apache Airflow version

2.8.0

If "Other Airflow 2 version" selected, which one?

No response

What happened?

Despite #28730, I encounter the message that the CSRF token has expired, although I checked that the session has not ended:

image

The reason why this still happens is because I have defined a custom webserver config, where the argument WTF_CSRF_TIME_LIMIT is not specified at all.

What you think should happen instead?

As is discussed in #28730, it is completely unnecessary for the CSRF token to expire before the end of a session, as it does not provide any extra security.

The default value of WTF_CSRF_TIME_LIMIT should be the same regardless of if there is a webserver config file or not, unless explicitly overridden.

How to reproduce

Define a custom webserver config where the argument WTF_CSRF_TIME_LIMIT is not specified at all. Then just wait until the CSRF token expires.

And as is seen clearly in this function,
https://github.com/apache/airflow/blob/681859c7bffabce0c294060d811db2fb16851816/airflow/configuration.py#L2059C1-L2066C96,
if you have specified a custom webserver config, the values in the default webserver config are ignored. Thus the CSRF expiry time will take on the flask default, i.e. 3600 seconds, instead of the airflow default which is None.

Operating System

MacOS

Versions of Apache Airflow Providers

No response

Deployment

Amazon (AWS) MWAA

Deployment details

No response

Anything else?

It is of course possible to specify the argument WTF_CSRF_TIME_LIMIT = None in the custom webserver config. However, this CSRF expiry issue can be a real headache and it took quite some time to figure out the fix, so it would be nice to solve this once and for all.

One could also argue that if one creates a custom webserver config, one should copy the default values first. In my case, however, this was done before #28730, so even if we now use a new airflow version, we still used the same config. I suspect this is the case for many others as well.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. boring-cyborg commented on Jan 18, 2024

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

  2. locked and limited conversation to collaborators on Jan 20, 2024
  3. converted this issue into a discussion #36924 on Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corekind:bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yet

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions