-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Improve documentation about private registry credentials #15021
Comments
What I would want to be cautious about is confusing people who don't need this, particularly but the fact that the most common registry people will use does not do this.
I don't know enough about authentication conventions and best practices to weigh on this. Alternatively, should it be the responsibility of the registry that needs it to advertise the token with the |
Well I do not disagree with this, but even if the registry does document that the token needs to be sent in Bearer scheme its difficult to know a user to know what authentication scheme Cargo will send it as. I think its not unreasonable to assume Cargo will send a token as Bearer (which it does not) as that is generally the most common scheme for sending tokens in requests. Perhaps just adding something like this to the Cargo book would be enough to avoid confusion.
|
This looks fine, though I would generally recommend private registries moving away from plain token, and use credential provider instead. |
Looking at the suggestion, I can see crates.io users being easily confused. imo this is still best documented on the registry. |
Hmm yeah that is fair.
I have mixed emotions about this. I don't disagree, but at the same time the way Cargo sends token's to the registry is an implementation detail of Cargo so I feel it should at least be documented in Cargo (even if very briefly) The reason I think this is a problem worth addressing is because its fairly difficult to diagnosis this issue when it happens. |
Hmmm well looking at the docs for JFrog Artifactory (which is what I was using), it does have a code snippet documenting that you do need the Perhaps this was just user error on my part 😓 |
What about mentioning how Cargo pass the token without talking about auth scheme? We already have it in registry doc: cargo/src/doc/src/reference/registry-web-api.md Lines 6 to 7 in 5ffbef3
Perhaps we can expand reference/registry-authentication.md and talk about Cargo setting the "Authorization" header value with the token without modification. And on the doc section of credential file, link to that page with somthing like Tokens are used by some Cargo commands such as [`cargo publish`] for
authenticating with remote registries. Care should be taken to protect the
-tokens and to keep them secret.
+tokens and to keep them secret. See the "Registry Authentication" chapter for
+how the plain text token is used, and other safer authentication alternatives. |
That seems reasonable. I think the reference/registry-authentication.md you linked has the necessary information so having a link to that should make finding that easier for users with authentication issues. 👍 |
Overall, my expectation is we'd work to deprecate However, what authentication methods a registry supports is a choice made by the registry and I don't see getting into the details of the protocol to be helpful to the users but more confusing. It invites questions from the user about how it is relevant. This is why any details beyond "if your registry gives you a token, paste it here" seems like it should belong on the registry side as that narrows the scope to those it affects so it is relevant to them. |
I agree we should update the documentation to make it clear that Cargo will send the token as the Authorization header value without an additional scheme. I'd rather avoid automatically adding the |
Problem
In the Cargo Book it states that you can set a token like so.
However, the Cargo uses this token directly in the
Authorization
header without modifying it.Many private registries will expect the token in the bearer format (
Bearer {token}
) so you will need to addBearer
to the token field incredentials.toml
.Generally when I see a
token
field in a config file, I expect to just add my token without caring about the format the registry expected the token to be delivered in. This lead to a good amount of confusion today 😅Possible Solution(s)
Basic
orBearer
to the token field.Bearer
if there is a 401 response.Notes
There is already precedence for retry failed request for getting the index
config.json
so extending it to downloading crates seems reasonable.See the sparse authentication docs
Version
The text was updated successfully, but these errors were encountered: