Skip to content

Multiple identities on the same registry for cargo login and cargo publish #16431

@cyqsimon

Description

@cyqsimon

Problem

I have multiple distinct accounts on crates.io for which I publish crates. I would prefer to be able to stay logged in to all these accounts simultaneously.

Proposed Solution

Perhaps namespace support in git-credential-manager is a good reference. Currently this is how I handle my multiple git identities.

But on second thought, maybe namespace support leads to too many edge cases and orthogonality concerns with multiple registries, and is frankly overkill for what I want. So perhaps a registry.identities (and the corresponding registries.<name>.identities) table? It would look something like this:

[registry.identities]
alice = { token = "TOKEN_ALICE" }
bob = { token = "TOKEN_BOB" }

So this would be an opt-in "named identity" feature, and the current system would be then known as "unnamed identity". Everything right now would work the same because "unnamed identity" would still be the default mode of operation. But now with an additional CLI option --identity <who> (for cargo login, cargo logout, and cargo publish), cargo would read and write these "named identity" fields instead.

Notes

Previously I have been saving the tokens to local files, and then using cargo publish --token to dynamically select which one I use. I had this all written in a script. But more recently cargo publish --token has been marked as deprecated, so now I'm looking elsewhere.

The easiest thing for me to do right now to "just make it work" would be to switch to the CARGO_REGISTRY_TOKEN environment variable. Or I can create multiple named registries that each represent an identity, but are all in fact crates.io, thereby coaxing the current multiple registry support to act as multiple identity support. But at this point the amount of gymnastics I'm doing plus my presumption that this may be a common need would warrant asking for proper upstream support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-credential-providerArea: credential provider for storing and retreiving credentialsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions