From d3f309aa0644d3ce11e095a8b3c1c71a9efc96f4 Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Tue, 24 Sep 2024 21:34:31 +0200 Subject: [PATCH 1/4] fix: for flask >= 3.0.0 compatibility * flask >= 3.0.0 removes Markup. to keep the functionality Markup has to be imported from markupsafe directly --- invenio_oauthclient/handlers/ui.py | 3 ++- setup.cfg | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/invenio_oauthclient/handlers/ui.py b/invenio_oauthclient/handlers/ui.py index cf09b85..485b032 100644 --- a/invenio_oauthclient/handlers/ui.py +++ b/invenio_oauthclient/handlers/ui.py @@ -2,6 +2,7 @@ # # This file is part of Invenio. # Copyright (C) 2015-2019 CERN. +# Copyright (C) 2024 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. @@ -11,7 +12,6 @@ from functools import partial, wraps from flask import ( - Markup, current_app, flash, redirect, @@ -23,6 +23,7 @@ from flask_security.utils import do_flash, get_message from invenio_db import db from invenio_i18n import gettext as _ +from markupsafe import Markup from ..errors import ( AlreadyLinkedError, diff --git a/setup.cfg b/setup.cfg index 1e503a8..63c6f43 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,6 +35,7 @@ install_requires = invenio-mail>=1.0.2 invenio-theme>=3.0.0 oauthlib>=1.1.2,<3.0.0 + markupsafe>=2.1.5 requests-oauthlib>=0.6.2,<1.2.0 uritools>=1.0.1 github3.py>=1.0.0a4 From d1982c2b7bab8416d8aaa50145b0c12a86922a87 Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Wed, 25 Sep 2024 22:03:25 +0200 Subject: [PATCH 2/4] global: jws use from invenio-base * jws functionality has been moved to invenio-base because itsdangerous removes it with v2.1.0 --- invenio_oauthclient/utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/invenio_oauthclient/utils.py b/invenio_oauthclient/utils.py index 40f4cee..4de906c 100644 --- a/invenio_oauthclient/utils.py +++ b/invenio_oauthclient/utils.py @@ -2,6 +2,7 @@ # # This file is part of Invenio. # Copyright (C) 2015-2023 CERN. +# Copyright (C) 2024 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. @@ -12,13 +13,20 @@ from flask_login import current_user from flask_principal import RoleNeed, UserNeed from invenio_db.utils import rebuild_encrypted_properties -from itsdangerous import TimedJSONWebSignatureSerializer from uritools import uricompose, urisplit from werkzeug.local import LocalProxy from werkzeug.utils import import_string from .models import RemoteToken +try: + # itsdangerous < 2.1.0 + from itsdangerous import TimedJSONWebSignatureSerializer +except ImportError: + # itsdangerous >= 2.1.0 + from invenio_base.jws import TimedJSONWebSignatureSerializer + + _security = LocalProxy(lambda: current_app.extensions["security"]) From 6ff4f3584a59ff0406c8494f288882b24a93c97f Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Wed, 25 Sep 2024 22:04:52 +0200 Subject: [PATCH 3/4] setup: remove upper pins oauthlib,requests-oauthlib * this change was done to migrate to flask >= 3.0 --- setup.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 63c6f43..17078e0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -34,9 +34,9 @@ install_requires = invenio-i18n>=2.0.0 invenio-mail>=1.0.2 invenio-theme>=3.0.0 - oauthlib>=1.1.2,<3.0.0 + oauthlib>=1.1.2 markupsafe>=2.1.5 - requests-oauthlib>=0.6.2,<1.2.0 + requests-oauthlib>=0.6.2 uritools>=1.0.1 github3.py>=1.0.0a4 uritemplate>=3.0.1 From 426501d3b6defad9587b216d56e38bbe8ce6893e Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Thu, 10 Oct 2024 21:39:20 +0200 Subject: [PATCH 4/4] chore: remove unused imports --- invenio_oauthclient/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/invenio_oauthclient/utils.py b/invenio_oauthclient/utils.py index 4de906c..b042558 100644 --- a/invenio_oauthclient/utils.py +++ b/invenio_oauthclient/utils.py @@ -10,8 +10,7 @@ """Utility methods.""" from flask import current_app, request, session -from flask_login import current_user -from flask_principal import RoleNeed, UserNeed +from flask_principal import RoleNeed from invenio_db.utils import rebuild_encrypted_properties from uritools import uricompose, urisplit from werkzeug.local import LocalProxy