-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check if the Authorization header for Basic Authentication is valid #1589
Conversation
6c313b1
to
3f8f8fa
Compare
I successfully tested image pushing with the following settings (with the enabled basic authentication and remote authentication at the same time): dynaconf list
Note that when omitting etc/nginx/pulp/pulp_container.conf
|
@@ -80,13 +81,18 @@ def authenticate(self, request): | |||
return (AnonymousUser, None) | |||
|
|||
try: | |||
return super().authenticate(request) | |||
result = super().authenticate(request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None
is returned only when this is evaluated to True
. We exploit this check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds brittle. Even with this explanation it's hard to understand. You should have a comment at the very least. Is the "empty username and password" working at all with remote auth?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the empty username and password mean in this context? If there is no Remote_User
passed with the request, and no Authorization header is present, Pulp considers this request being anonymous, allowing standard pull operations for public repositories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What i mean is: When remote auth is configured, and the reverse proxy terminates the authentication process, does it also accept empty for anonymous?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, RemoteUserRegistryAuthentication().authenticate(request)
returns None
if there is no Remote_User
header set. Returning None
from the method means that we deal with AnonymousUser
, same as with returning (AnonymousUser, None)
. Maybe we want to return None
at all times, @ipanova?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed result
into a more explicit variable: authenticated_user
.
51ed1c3
to
2a288fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works well testing container push with Katello.
2a288fa
to
ff895fb
Compare
After discussing this with Ina, I will try to test this once again with different settings for the remote authentication and return either |
ff895fb
to
96c7d4c
Compare
According to the I removed Besides that, I tested latest changes with 1. |
While you listed the combinations you tested of auth backends, did you test auth classes with remote auth only and remote auth + basic auth? |
If the header is not valid, DRF returns None when calling the authenticate() method. This can cause troubles when users are leveraging the remote authentication because Pulp thinks they are anonymous users. In the end, authorized users cannot push or pull content from Pulp. This affects only admin users in scenarios where the token authentication is disabled. closes pulp#1577
96c7d4c
to
7b70f29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified again on Katello latest, still works 👍
Backport to 2.19: 💚 backport PR created✅ Backport PR branch: Backported as #1600 🤖 @patchback |
@lubosmj I'd like to request a backport for this on the 2.16 branch if possible. It applied cleanly on my system. |
Backport to 2.16: 💚 backport PR created✅ Backport PR branch: Backported as #1678 🤖 @patchback |
@ianballou, I have just released https://github.com/pulp/pulp_container/releases/tag/2.16.8! |
Thanks @lubosmj ! |
If the header is not valid, DRF returns None when calling the
authenticate() method. This can cause troubles when users are
leveraging the remote authentication because Pulp thinks they
are anonymous users. In the end, authorized users cannot
push or pull content from Pulp. This affects only admin users
in scenarios where the token authentication is disabled.
closes #1577