diff --git a/invenio_oauthclient/utils.py b/invenio_oauthclient/utils.py index 79d6448f..654a37c1 100644 --- a/invenio_oauthclient/utils.py +++ b/invenio_oauthclient/utils.py @@ -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. @@ -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) diff --git a/tests/conftest.py b/tests/conftest.py index ed2836e2..02b58374 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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. @@ -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", diff --git a/tests/test_views.py b/tests/test_views.py index bedfae9d..efc13c9a 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -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. @@ -79,7 +79,7 @@ def test_redirect_uri(views_fixture): 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. @@ -91,7 +91,7 @@ def test_redirect_uri(views_fixture): 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) diff --git a/tests/test_views_rest.py b/tests/test_views_rest.py index 4c0fee99..419154cc 100644 --- a/tests/test_views_rest.py +++ b/tests/test_views_rest.py @@ -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. @@ -75,7 +75,7 @@ def test_redirect_uri(app_rest): 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. @@ -87,7 +87,7 @@ def test_redirect_uri(app_rest): 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)