From 726392b1fa5a0867799702e666bf5ce13648d202 Mon Sep 17 00:00:00 2001 From: MueezKhan246 <93375917+MueezKhan246@users.noreply.github.com> Date: Wed, 17 Apr 2024 03:53:07 +0000 Subject: [PATCH] feat: removed ENABLE_USER_ID_SCOPE flag from validator --- .../dot_overrides/validators.py | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/openedx/core/djangoapps/oauth_dispatch/dot_overrides/validators.py b/openedx/core/djangoapps/oauth_dispatch/dot_overrides/validators.py index 83a17e1608..72475b3d53 100644 --- a/openedx/core/djangoapps/oauth_dispatch/dot_overrides/validators.py +++ b/openedx/core/djangoapps/oauth_dispatch/dot_overrides/validators.py @@ -100,22 +100,12 @@ class EdxOAuth2Validator(OAuth2Validator): client credentials, add `user_id` as a default scope if it is an allowed scope. """ default_scopes = super().get_default_scopes(client_id, request, *args, **kwargs) - # .. toggle_name: ENABLE_USER_ID_SCOPE - # .. toggle_implementation:DjangoSetting - # .. toggle_description: If enabled, the user_id scope will be added to the default scopes for client_credentials grant type. - # .. toggle_default: False - # .. toggle_use_cases: temporary - # .. toggle_creation_date: 2024-03-16 - # .. toggle_target_removal_date: 2024-04-16 - # .. toggle_warnings: This feature flag is temporary and will be removed once the feature is fully tested. - # .. toggle_tickets: https://github.com/openedx/edx-platform/issues/34381 (toggle removal ticket) - if settings.FEATURES.get('ENABLE_USER_ID_SCOPE', False): - if request.grant_type == 'client_credentials' and not request.scopes: - if get_scopes_backend().has_user_id_in_application_scopes(application=request.client): - # copy the default scopes and add user_id to it to avoid modifying the original list - extended_default_scopes = default_scopes.copy() - extended_default_scopes.append('user_id') - return extended_default_scopes + if request.grant_type == 'client_credentials' and not request.scopes: + if get_scopes_backend().has_user_id_in_application_scopes(application=request.client): + # copy the default scopes and add user_id to it to avoid modifying the original list + extended_default_scopes = default_scopes.copy() + extended_default_scopes.append('user_id') + return extended_default_scopes return default_scopes def validate_scopes(self, client_id, scopes, client, request, *args, **kwargs):