<p dir="auto"><strong>Apache Airflow version</strong>:<br>
1.10.9</p>
<p dir="auto"><strong>Environment</strong>:<br>
Google Cloud Compute Instance</p>
<ul dir="auto">
<li><strong>OS</strong> (e.g. from /etc/os-release):<br>
Red Hat Enterprise Linux Server<br>
Version 7.7</li>
<li><strong>Kernel</strong> (e.g. <code class="notranslate">uname -a</code>):</li>
<li><strong>Install tools</strong>:</li>
<li><strong>Others</strong>:</li>
</ul>
<p dir="auto"><strong>What happened</strong>:</p>
<p dir="auto">After rebuilding an Airflow environment I started experiencing that DAGS could not be toggled on/off via the UI. It appears the CSRF token is not being included in the request.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/29924655/80514478-775ebe00-8978-11ea-8b1b-95349c15db70.png"><img src="https://user-images.githubusercontent.com/29924655/80514478-775ebe00-8978-11ea-8b1b-95349c15db70.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>What you expected to happen</strong>:</p>
<p dir="auto">CSRF token to be included in the header request</p>
<p dir="auto"><strong>What I think went wrong</strong>:</p>
<p dir="auto">Underlying package has been updated. If I rollback my image Airflow is working. Comparing the images I can see that some underlying packages have been updated.</p>
<p dir="auto">Pip3 output from working Airflow image vs broken Airflow image shows that some dependencies have been updated.</p>
<p dir="auto">These are:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cattrs 0.9.0 --&gt; cattrs 0.9.2
cryptography 2.9 --&gt; 2.9.2
Flask-AppBuilder 2.3.2 --&gt; Flask-AppBuilder 2.3.3
google-api-python-client 1.8.0 --&gt; google-api-python-client 1.8.2
googl-auth 1.14.0 --&gt; googl-auth 1.14.1
google-cloud-storage 1.27.0 --&gt; google-cloud-storage 1.27.1
graphviz 0.13.2 --&gt; graphviz 0.14
grpc-google-iam-v1 0.11.4 --&gt; grpc-google-iam-v1 0.12.3
httplib2 0.17.2 --&gt; httplib2 0.17.3
marshmallow-sqlalchemy 0.22.3 --&gt; marshmallow-sqlalchemy 0.23.0
numpy 1.18.2 --&gt; numpy 1.18.3
pydata-googl-auth 0.3.0 --&gt; 1.1.0
urllib3 1.25.8 --&gt; urllib3 1.25.9
WTForms 2.2.1 --&gt; WTForms 2.3.1"><pre class="notranslate"><code class="notranslate">cattrs 0.9.0 --&gt; cattrs 0.9.2
cryptography 2.9 --&gt; 2.9.2
Flask-AppBuilder 2.3.2 --&gt; Flask-AppBuilder 2.3.3
google-api-python-client 1.8.0 --&gt; google-api-python-client 1.8.2
googl-auth 1.14.0 --&gt; googl-auth 1.14.1
google-cloud-storage 1.27.0 --&gt; google-cloud-storage 1.27.1
graphviz 0.13.2 --&gt; graphviz 0.14
grpc-google-iam-v1 0.11.4 --&gt; grpc-google-iam-v1 0.12.3
httplib2 0.17.2 --&gt; httplib2 0.17.3
marshmallow-sqlalchemy 0.22.3 --&gt; marshmallow-sqlalchemy 0.23.0
numpy 1.18.2 --&gt; numpy 1.18.3
pydata-googl-auth 0.3.0 --&gt; 1.1.0
urllib3 1.25.8 --&gt; urllib3 1.25.9
WTForms 2.2.1 --&gt; WTForms 2.3.1
</code></pre></div>
<p dir="auto">Full pip3 list output for not working Airflow instance:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Package                        Version
------------------------------ ----------
alembic                        1.4.2
amqp                           2.5.2
apache-airflow                 1.10.9
apispec                        1.3.3
argcomplete                    1.11.1
attrs                          19.3.0
Babel                          2.8.0
bcrypt                         3.1.7
billiard                       3.6.3.0
cached-property                1.5.1
cachetools                     4.1.0
cattrs                         0.9.2
celery                         4.4.2
certifi                        2020.4.5.1
cffi                           1.14.0
chardet                        3.0.4
click                          7.1.1
colorama                       0.4.3
colorlog                       4.0.2
configparser                   3.5.3
croniter                       0.3.31
cryptography                   2.9.2
defusedxml                     0.6.0
dill                           0.3.1.1
dnspython                      1.16.0
docutils                       0.16
email-validator                1.0.5
Flask                          1.1.2
Flask-Admin                    1.5.4
Flask-AppBuilder               2.3.3
Flask-Babel                    1.0.0
Flask-Bcrypt                   0.7.1
Flask-Caching                  1.3.3
Flask-JWT-Extended             3.24.1
Flask-Login                    0.4.1
Flask-OpenID                   1.2.5
Flask-SQLAlchemy               2.4.1
flask-swagger                  0.2.13
Flask-WTF                      0.14.3
flower                         0.9.4
funcsigs                       1.0.2
future                         0.16.0
google-api-core                1.17.0
google-api-python-client       1.8.2
google-auth                    1.14.1
google-auth-httplib2           0.0.3
google-auth-oauthlib           0.4.1
google-cloud-bigquery          1.24.0
google-cloud-bigtable          0.33.0
google-cloud-container         0.5.0
google-cloud-core              1.3.0
google-cloud-dlp               0.14.0
google-cloud-language          1.3.0
google-cloud-spanner           1.9.0
google-cloud-speech            1.3.2
google-cloud-storage           1.28.0
google-cloud-texttospeech      1.0.1
google-cloud-translate         2.0.1
google-cloud-videointelligence 1.14.0
google-cloud-vision            1.0.0
google-resumable-media         0.5.0
googleapis-common-protos       1.51.0
graphviz                       0.14
grpc-google-iam-v1             0.12.3
grpcio                         1.28.1
grpcio-gcp                     0.2.2
gunicorn                       19.10.0
httplib2                       0.17.3
humanize                       0.5.1
idna                           2.9
importlib-metadata             1.6.0
iso8601                        0.1.12
itsdangerous                   1.1.0
Jinja2                         2.10.3
json-merge-patch               0.2
jsonschema                     3.2.0
kombu                          4.6.8
lazy-object-proxy              1.4.3
lockfile                       0.12.2
Mako                           1.1.2
Markdown                       2.6.11
MarkupSafe                     1.1.1
marshmallow                    2.21.0
marshmallow-enum               1.5.1
marshmallow-sqlalchemy         0.23.0
numpy                          1.18.3
oauthlib                       3.1.0
pandas                         0.25.3
pandas-gbq                     0.13.1
paramiko                       1.10.5
pendulum                       1.4.4
pip                            19.0.3
prison                         0.1.3
protobuf                       3.11.3
psutil                         5.7.0
psycopg2-binary                2.8.5
pyasn1                         0.4.8
pyasn1-modules                 0.2.8
pycparser                      2.20
pycrypto                       2.6.1
pydata-google-auth             1.1.0
Pygments                       2.6.1
PyJWT                          1.7.1
pyOpenSSL                      19.1.0
pyrsistent                     0.16.0
python-daemon                  2.1.2
python-dateutil                2.8.1
python-editor                  1.0.4
python3-openid                 3.1.0
pytz                           2019.3
pytzdata                       2019.3
PyYAML                         5.3.1
redis                          3.4.1
requests                       2.23.0
requests-oauthlib              1.3.0
rsa                            4.0
setproctitle                   1.1.10
setuptools                     40.8.0
six                            1.14.0
slackclient                    1.3.2
SQLAlchemy                     1.3.16
SQLAlchemy-JSONField           0.9.0
SQLAlchemy-Utils               0.36.3
tabulate                       0.8.7
tenacity                       4.12.0
termcolor                      1.1.0
text-unidecode                 1.2
thrift                         0.13.0
tornado                        5.1.1
typing-extensions              3.7.4.2
tzlocal                        1.5.1
unicodecsv                     0.14.1
uritemplate                    3.0.1
urllib3                        1.25.9
vine                           1.3.0
websocket-client               0.54.0
Werkzeug                       0.16.0
WTForms                        2.3.1
zipp                           3.1.0
zope.deprecation               4.4.0
-----------------------------------------"><pre class="notranslate"><code class="notranslate">Package                        Version
------------------------------ ----------
alembic                        1.4.2
amqp                           2.5.2
apache-airflow                 1.10.9
apispec                        1.3.3
argcomplete                    1.11.1
attrs                          19.3.0
Babel                          2.8.0
bcrypt                         3.1.7
billiard                       3.6.3.0
cached-property                1.5.1
cachetools                     4.1.0
cattrs                         0.9.2
celery                         4.4.2
certifi                        2020.4.5.1
cffi                           1.14.0
chardet                        3.0.4
click                          7.1.1
colorama                       0.4.3
colorlog                       4.0.2
configparser                   3.5.3
croniter                       0.3.31
cryptography                   2.9.2
defusedxml                     0.6.0
dill                           0.3.1.1
dnspython                      1.16.0
docutils                       0.16
email-validator                1.0.5
Flask                          1.1.2
Flask-Admin                    1.5.4
Flask-AppBuilder               2.3.3
Flask-Babel                    1.0.0
Flask-Bcrypt                   0.7.1
Flask-Caching                  1.3.3
Flask-JWT-Extended             3.24.1
Flask-Login                    0.4.1
Flask-OpenID                   1.2.5
Flask-SQLAlchemy               2.4.1
flask-swagger                  0.2.13
Flask-WTF                      0.14.3
flower                         0.9.4
funcsigs                       1.0.2
future                         0.16.0
google-api-core                1.17.0
google-api-python-client       1.8.2
google-auth                    1.14.1
google-auth-httplib2           0.0.3
google-auth-oauthlib           0.4.1
google-cloud-bigquery          1.24.0
google-cloud-bigtable          0.33.0
google-cloud-container         0.5.0
google-cloud-core              1.3.0
google-cloud-dlp               0.14.0
google-cloud-language          1.3.0
google-cloud-spanner           1.9.0
google-cloud-speech            1.3.2
google-cloud-storage           1.28.0
google-cloud-texttospeech      1.0.1
google-cloud-translate         2.0.1
google-cloud-videointelligence 1.14.0
google-cloud-vision            1.0.0
google-resumable-media         0.5.0
googleapis-common-protos       1.51.0
graphviz                       0.14
grpc-google-iam-v1             0.12.3
grpcio                         1.28.1
grpcio-gcp                     0.2.2
gunicorn                       19.10.0
httplib2                       0.17.3
humanize                       0.5.1
idna                           2.9
importlib-metadata             1.6.0
iso8601                        0.1.12
itsdangerous                   1.1.0
Jinja2                         2.10.3
json-merge-patch               0.2
jsonschema                     3.2.0
kombu                          4.6.8
lazy-object-proxy              1.4.3
lockfile                       0.12.2
Mako                           1.1.2
Markdown                       2.6.11
MarkupSafe                     1.1.1
marshmallow                    2.21.0
marshmallow-enum               1.5.1
marshmallow-sqlalchemy         0.23.0
numpy                          1.18.3
oauthlib                       3.1.0
pandas                         0.25.3
pandas-gbq                     0.13.1
paramiko                       1.10.5
pendulum                       1.4.4
pip                            19.0.3
prison                         0.1.3
protobuf                       3.11.3
psutil                         5.7.0
psycopg2-binary                2.8.5
pyasn1                         0.4.8
pyasn1-modules                 0.2.8
pycparser                      2.20
pycrypto                       2.6.1
pydata-google-auth             1.1.0
Pygments                       2.6.1
PyJWT                          1.7.1
pyOpenSSL                      19.1.0
pyrsistent                     0.16.0
python-daemon                  2.1.2
python-dateutil                2.8.1
python-editor                  1.0.4
python3-openid                 3.1.0
pytz                           2019.3
pytzdata                       2019.3
PyYAML                         5.3.1
redis                          3.4.1
requests                       2.23.0
requests-oauthlib              1.3.0
rsa                            4.0
setproctitle                   1.1.10
setuptools                     40.8.0
six                            1.14.0
slackclient                    1.3.2
SQLAlchemy                     1.3.16
SQLAlchemy-JSONField           0.9.0
SQLAlchemy-Utils               0.36.3
tabulate                       0.8.7
tenacity                       4.12.0
termcolor                      1.1.0
text-unidecode                 1.2
thrift                         0.13.0
tornado                        5.1.1
typing-extensions              3.7.4.2
tzlocal                        1.5.1
unicodecsv                     0.14.1
uritemplate                    3.0.1
urllib3                        1.25.9
vine                           1.3.0
websocket-client               0.54.0
Werkzeug                       0.16.0
WTForms                        2.3.1
zipp                           3.1.0
zope.deprecation               4.4.0
-----------------------------------------
</code></pre></div>
<p dir="auto">I am using an AWS ec2 instance and installed apache-airflow there. Following steps, I am doing in that instance,</p>
<ol dir="auto">
<li>After initiating airflow with 'airflow initdb', I created a user with <strong>Admin</strong> role using 'airflow create_user' option and  in airflow.cfg changed rbac = True.</li>
<li>Again ran 'airflow initdb' and 'airflow webserver'. It initiated the webserver.</li>
<li>In another tab,  run 'airflow scheduler'</li>
<li>Then using port-forwarding to port forward the 8080 port from the ec2 instance to my local machine</li>
<li>In my local browser, I am just opening localhost:8080/</li>
<li>On Airflow login page, putting credentials of the Admin user, I logged in into Airflow</li>
<li>After toggling ON a dag from UI, when I am refreshing the page or clicking on some other option, the DAG toggling button is automatically turning OFF. and hence I am not able to run any DAG</li>
</ol>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/13828878/80454358-8bd69280-8947-11ea-9fbf-e63b20e09d9b.png"><img src="https://user-images.githubusercontent.com/13828878/80454358-8bd69280-8947-11ea-9fbf-e63b20e09d9b.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">The button I am talking about is on the left side of the DAG name.</p>
<p dir="auto">Please help anyone</p>