Skip to content

Commit 93579cf

Browse files
authored
AAP-42306 Revert ansible#623 Do not intercept is_superuser JWT auth (ansible#867)
Makes gateway the source of truth for is_superuser Allows it to be synced to other components via JWT authentication
1 parent f31b1f2 commit 93579cf

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

ansible_base/jwt_consumer/common/auth.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ def parse_jwt_token(self, request):
133133
except IntegrityError as exc:
134134
logger.debug(f'Existing user {self.token["user_data"]} is a conflict with local user, error: {exc}')
135135
with no_reverse_sync():
136-
if user_defaults['is_superuser'] is False:
137-
user_defaults.pop('is_superuser')
138136
self.user, created = get_user_model().objects.update_or_create(
139137
username=self.token["user_data"]['username'],
140138
defaults=user_defaults,
@@ -174,8 +172,6 @@ def map_user_fields(self):
174172
"Please make sure the sync task is running to prevent this warning in the future."
175173
)
176174
continue
177-
if attribute == 'is_superuser' and new_value is False:
178-
continue
179175
logger.debug(f"Changing {attribute} for {self.user.username} from {old_value} to {new_value}")
180176
setattr(self.user, attribute, new_value)
181177
user_needs_save = True

test_app/tests/jwt_consumer/common/test_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ def test_authenticate(self, jwt_token, django_user_model, mocked_http, test_encr
642642
@pytest.mark.django_db()
643643
@pytest.mark.parametrize(
644644
"original_is_superuser, token_is_superuser, expected_is_superuser",
645-
[(True, False, True), (False, True, True), (True, True, True), (False, False, False)],
645+
[(True, False, False), (False, True, True), (True, True, True), (False, False, False)],
646646
)
647647
def test_authenticate_is_superuser(
648648
self, jwt_token, django_user_model, mocked_http, test_encryption_public_key, original_is_superuser, token_is_superuser, expected_is_superuser

0 commit comments

Comments
 (0)