Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix webserver always redirecting to home page if user was not logged in #36833

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions airflow/www/auth.py
Expand Up @@ -116,7 +116,7 @@ def wraps(self, *args, **kwargs):
else:
log.warning(LOGMSG_ERR_SEC_ACCESS_DENIED, permission_str, self.__class__.__name__)
flash(as_unicode(FLAMSG_ERR_SEC_ACCESS_DENIED), "danger")
return redirect(get_auth_manager().get_url_login(next=request.url))
return redirect(get_auth_manager().get_url_login(next_url=request.url))

f._permission_name = permission_str
return functools.update_wrapper(wraps, f)
Expand Down Expand Up @@ -173,7 +173,7 @@ def _has_access(*, is_authorized: bool, func: Callable, args, kwargs):
403,
)
elif not get_auth_manager().is_logged_in():
return redirect(get_auth_manager().get_url_login(next=request.url))
return redirect(get_auth_manager().get_url_login(next_url=request.url))
else:
access_denied = get_access_denied_message()
flash(access_denied, "danger")
Expand Down
4 changes: 3 additions & 1 deletion tests/www/views/test_anonymous_as_admin_role.py
Expand Up @@ -17,6 +17,8 @@
# under the License.
from __future__ import annotations

from urllib.parse import quote_plus

import pytest

from airflow.models import Pool
Expand Down Expand Up @@ -54,7 +56,7 @@ def test_delete_pool_anonymous_user_no_role(anonymous_client, pool_factory):
pool = pool_factory()
resp = anonymous_client.post(f"pool/delete/{pool.id}")
assert 302 == resp.status_code
assert "/login/" == resp.headers["Location"]
assert f"/login/?next={quote_plus(f'http://localhost/pool/delete/{pool.id}')}" == resp.headers["Location"]


def test_delete_pool_anonymous_user_as_admin(anonymous_client_as_admin, pool_factory):
Expand Down