Skip to content

feat(auth): accept instance authenticators on Cargo endpoints - #61

Open
BaptisteCentreon wants to merge 1 commit into
pulp:mainfrom
BaptisteCentreon:oidc-cargo-auth
Open

BaptisteCentreon wants to merge 1 commit into
pulp:mainfrom
BaptisteCentreon:oidc-cargo-auth

Conversation

@BaptisteCentreon

Copy link
Copy Markdown

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant