From b64f23f0a64b90b5148b80cabff3d9822906cf4e Mon Sep 17 00:00:00 2001 From: Clayton Singh Date: Mon, 29 Jan 2024 00:11:10 -0800 Subject: [PATCH] Don't access oauth2_settings if OAuthLibCore server parameter is provided --- AUTHORS | 1 + oauth2_provider/oauth2_backends.py | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 8596063b9..fe1f8f790 100644 --- a/AUTHORS +++ b/AUTHORS @@ -35,6 +35,7 @@ Bart Merenda Bas van Oostveen Brian Helba Carl Schwan +Clayton Singh Daniel Golding Daniel 'Vector' Kerr Darrel O'Pry diff --git a/oauth2_provider/oauth2_backends.py b/oauth2_provider/oauth2_backends.py index 3ddb9c90b..780d9b3c3 100644 --- a/oauth2_provider/oauth2_backends.py +++ b/oauth2_provider/oauth2_backends.py @@ -22,10 +22,12 @@ def __init__(self, server=None): """ :params server: An instance of oauthlib.oauth2.Server class """ - validator_class = oauth2_settings.OAUTH2_VALIDATOR_CLASS - validator = validator_class() - server_kwargs = oauth2_settings.server_kwargs - self.server = server or oauth2_settings.OAUTH2_SERVER_CLASS(validator, **server_kwargs) + if not server: + validator_class = oauth2_settings.OAUTH2_VALIDATOR_CLASS + validator = validator_class() + server_kwargs = oauth2_settings.server_kwargs + server = oauth2_settings.OAUTH2_SERVER_CLASS(validator, **server_kwargs) + self.server = server def _get_escaped_full_path(self, request): """