Connect Cargo to Artifactory

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide

Prerequisites: Before connecting your Cargo client to Artifactory, you must have an existing Cargo repository in Artifactory. For more information, see Create a Cargo Repository.

Logged in vs. Anonymous User: You can work with Cargo and Artifactory as a logged-in user or anonymously. To work with Artifactory using Anonymous Access, configure that access under Admin | Security | General. For details, refer to Allow Anonymous Access.Allow Anonymous Access

Using Cargo Repositories with Authentication

The Cargo client does not authenticate install and search commands. This means these commands will fail if your repository blocks anonymous access.

To solve this, enable the Allow anonymous download and search setting for your repository. This option keeps the repository private from other anonymous requests but creates a specific exception that allows Cargo's install and search commands to work correctly.

To connect the Cargo client to Artifactory:

  1. Open your Cargo configuration file in a text editor. The file is located in the Cargo home directory, for example ~/.cargo/config.toml.

  2. Add the following snippet to point your Cargo client to Artifactory:

    [registry]
    default = "artifactory"
    
    [registries.artifactory]
    index = "sparse+https://[JFrogPlatformURL]/artifactory/api/cargo/<REPO_NAME>/index/"

    Where:

    • [JFrogPlatformURL]: Your organization's Artifactory URL

    • <REPO_NAME>: The name of your Cargo repository

    For example:

    [registry]
    default = "artifactory"
    
    [registries.artifactory]
    index = "sparse+https://company.jfrog.io/artifactory/api/cargo/cargo-local/index/"
  3. Save the changes to the configuration file.

  4. Open your Cargo credentials file in a text editor. The file is located in the Cargo home directory, for example ~/.cargo/credentials.toml.

  5. Add the following snippet to set credentials for API calls like yank and publish:

    [registries.artifactory]
    token = "<AUTH>"

    Where <AUTH> is your Artifactory identity token. For example:

    [registries.artifactory]
    token = "x7rT4hL9bA2vW1pZ5sE8dR6gK3jCqV0nU7fM9yB4iO1uF2oP5tS8eG7wZ"
  6. Save the changed to the credentials file.

Note

You can also use JFrog Set me up to copy the snippet populated with your token and environment. For more information, see Use Artifactory Set Me Up for Configuring Package Manager Clients.

Next steps: