Skip to content

Commit 714e77f

Browse files
authored
Add username (#855)
* user org_id and username for basic auth
1 parent 94d593e commit 714e77f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pulp_service/pulp_service/app/authentication.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def authenticate_header(self, request):
2525
class RHEntitlementCertAuthentication(JSONHeaderRemoteAuthentication):
2626

2727
header = "HTTP_X_RH_IDENTITY"
28-
jq_filter = ".identity.org_id"
28+
# Combines org_id with username - returns null if either is missing
29+
jq_filter = '.identity | if .org_id and .user.username then "\(.org_id):\(.user.username)" else null end'
2930

3031
def authenticate_header(self, request):
3132
return "Bearer"

pulp_service/pulp_service/tests/functional/test_authentication.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ def test_authentication_with_username_and_org_id(
4848
assert repo is not None
4949

5050

51-
def test_authentication_with_only_org_id(
51+
def test_authentication_with_org_id_and_username(
5252
anonymous_user,
5353
pulpcore_bindings,
5454
python_bindings,
5555
gen_object_with_cleanup,
5656
cleanup_auth_headers,
5757
):
58-
"""Test that requests with only org_id in x-rh-identity header work."""
59-
only_orgid = {"identity": {"org_id": 67890}}
58+
"""Test that requests with org_id and username in x-rh-identity header work."""
59+
user_with_orgid = {"identity": {"org_id": 67890, "user": {"username": "testuser2"}}}
6060
with anonymous_user:
61-
header_content = json.dumps(only_orgid)
61+
header_content = json.dumps(user_with_orgid)
6262
auth_header = b64encode(bytes(header_content, "ascii"))
6363

6464
pulpcore_bindings.DomainsApi.api_client.default_headers["x-rh-identity"] = auth_header

0 commit comments

Comments
 (0)