feat(auth): accept instance authenticators on Cargo endpoints - #61
Open
BaptisteCentreon wants to merge 1 commit into
Open
BaptisteCentreon wants to merge 1 commit into
BaptisteCentreon wants to merge 1 commit into
Conversation
BaptisteCentreon
force-pushed
the
oidc-cargo-auth
branch
from
September 28, 2026 13:08
87aa0b6 to
7875c0b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Today the Cargo views (/me, publish, download/yank) hardcode authentication_classes = [CargoTokenAuthentication].
This overrides DEFAULT_AUTHENTICATION_CLASSES. So the endpoints only accept crg_ tokens. Every other credential the deployment supports (Basic, session, SSO, OIDC) gets rejected.
Authorization is not the problem: the views already call request.user.has_perm(...), which works for any user. Only authentication blocks them.
The fix
This PR replaces the hardcoded list with a small mixin. It keeps CargoTokenAuthentication first, then adds the instance's configured authenticators. So cargo login keeps working, and any other configured credential also reaches the Cargo endpoints. Nothing ties the plugin to a specific authenticator.
It also sets the index config.json auth-required flag from the distribution's content guard. A guarded distribution now tells cargo to send its credentials on the index and downloads, not only on publish.
Tests
I added functional tests. They check that Basic auth reaches /me, and that auth-required follows the content guard.