This is an automated email from the ASF dual-hosted git repository. gcruz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/allura.git
commit 36b22194aab858f0e9cbefe18483f2b2346299cc Author: Dave Brondsema <dbronds...@slashdotmedia.com> AuthorDate: Wed May 29 14:46:35 2024 -0400 [#7272] better repr for if/when oauthlib DEBUG logging is enabled --- Allura/allura/controllers/rest.py | 5 +++++ Allura/allura/model/oauth.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py index ec1a3266f..9cb8ca180 100644 --- a/Allura/allura/controllers/rest.py +++ b/Allura/allura/controllers/rest.py @@ -255,6 +255,11 @@ class Oauth1Validator(oauthlib.oauth1.RequestValidator): class Oauth2Validator(oauthlib.oauth2.RequestValidator): + def __init__(self): + super().__init__() + if asbool(tg.config.get('debug')): + oauthlib.set_debug(True) + def validate_client_id(self, client_id: str, request: oauthlib.common.Request, *args, **kwargs) -> bool: return M.OAuth2ClientApp.query.get(client_id=client_id) is not None diff --git a/Allura/allura/model/oauth.py b/Allura/allura/model/oauth.py index 69043635a..d70b5baaa 100644 --- a/Allura/allura/model/oauth.py +++ b/Allura/allura/model/oauth.py @@ -192,6 +192,9 @@ class OAuth2ClientApp(MappedClass): def description_html(self): return g.markdown.cached_convert(self, 'description') + def __repr__(self): + return f'<{self.__class__.__name__} _id={self._id} client_id={self.client_id} {self.name}>' + class OAuth2AuthorizationCode(MappedClass): class __mongometa__: @@ -250,6 +253,9 @@ class OAuth2AccessToken(MappedClass): user = RelationProperty('User') + def __repr__(self): + return f'<{self.__class__.__name__} _id={self._id} client_id={self.client_id} user_id={self.user_id}>' + def dummy_oauths(): from allura.controllers.rest import Oauth1Validator