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: flask>=3.1, changed variable #346

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions invenio_oauthclient/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This file is part of Invenio.
# Copyright (C) 2015-2023 CERN.
# Copyright (C) 2024 Graz University of Technology.
# Copyright (C) 2024-2025 Graz University of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -103,7 +103,7 @@ def get_safe_redirect_target(arg="next"):
:param arg: URL argument.
:returns: The redirect target or ``None``.
"""
allowed_hosts = current_app.config.get("APP_ALLOWED_HOSTS") or []
allowed_hosts = current_app.config.get("TRUSTED_HOSTS") or []
for target in request.args.get(arg), request.referrer:
if target:
redirect_uri = urisplit(target)
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
# Copyright (C) 2018 University of Chicago.
# Copyright (C) 2023-2024 Graz University of Technology.
# Copyright (C) 2023-2025 Graz University of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -139,7 +139,7 @@ def base_app(request):
SECURITY_PASSWORD_HASH="plaintext",
SECURITY_PASSWORD_SCHEMES=["plaintext"],
SECURITY_PASSWORD_SINGLE_HASH=None,
APP_ALLOWED_HOSTS=["localhost"],
TRUSTED_HOSTS=["localhost"],
APP_THEME=["semantic-ui"],
THEME_ICONS={"semantic-ui": dict(link="linkify icon")},
OAUTHCLIENT_SETTINGS_TEMPLATE="invenio_oauthclient/settings/base.html",
Expand Down
6 changes: 3 additions & 3 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
# Copyright (C) 2024 Graz University of Technology.
# Copyright (C) 2024-2025 Graz University of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -79,7 +79,7 @@
check_response_redirect_url(resp, url)

# Assert that absolute redirects are allowed only if
# `APP_ALLOWED_HOSTS` is set and includes them. Otherwise, the relative
# `TRUSTED_HOSTS` is set and includes them. Otherwise, the relative
# path of the url is extracted and returned. Note if you need to
# redirect to index page you should pass '/' as next parameter.

Expand All @@ -91,13 +91,13 @@

check_response_redirect_url(resp, urlparse(test_url).path)

app.config.update({"APP_ALLOWED_HOSTS": ["inveniosoftware.org"]})
app.config.update({"TRUSTED_HOSTS": ["inveniosoftware.org"]})

resp = client.get(
url_for("invenio_oauthclient.login", remote_app="test", next=test_url)
)

check_response_redirect_url(resp, test_url)

Check failure on line 100 in tests/test_views.py

View workflow job for this annotation

GitHub Actions / Tests / Tests (3.9, postgresql14, opensearch2)

test_redirect_uri AssertionError

Check failure on line 100 in tests/test_views.py

View workflow job for this annotation

GitHub Actions / Tests / Tests (3.12, postgresql14, opensearch2)

test_redirect_uri AssertionError


def test_login(views_fixture):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_views_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
# Copyright (C) 2024 Graz University of Technology.
# Copyright (C) 2024-2025 Graz University of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -75,7 +75,7 @@
check_response_redirect_url(resp, url)

# Assert that absolute redirects are allowed only if
# `APP_ALLOWED_HOSTS` is set and includes them. Otherwise, the relative
# `TRUSTED_HOSTS` is set and includes them. Otherwise, the relative
# path of the url is extracted and returned. Note if you need to
# redirect to index page you should pass '/' as next parameter.

Expand All @@ -87,13 +87,13 @@

check_response_redirect_url(resp, urlparse(test_url).path)

app_rest.config.update({"APP_ALLOWED_HOSTS": ["inveniosoftware.org"]})
app_rest.config.update({"TRUSTED_HOSTS": ["inveniosoftware.org"]})

resp = client.get(
url_for("invenio_oauthclient.rest_login", remote_app="test", next=test_url)
)

check_response_redirect_url(resp, test_url)

Check failure on line 96 in tests/test_views_rest.py

View workflow job for this annotation

GitHub Actions / Tests / Tests (3.9, postgresql14, opensearch2)

test_redirect_uri AssertionError

Check failure on line 96 in tests/test_views_rest.py

View workflow job for this annotation

GitHub Actions / Tests / Tests (3.12, postgresql14, opensearch2)

test_redirect_uri AssertionError


def test_login(app_rest):
Expand Down
Loading