Authenticate with Artifact Central

  • Tier: Premium, Ultimate
  • Offering: GitLab.com
  • Status: Beta

Authentication with Artifact Central requires a special Artifact Central token. Standard GitLab authentication methods are not supported.

Specific authentication steps vary based on your package manager and package client.

Authentication workflow

You authenticate to Artifact Central with your package client and a supported GitLab token:

  1. The client uses your GitLab token to request an Artifact Central token from GitLab.
  2. GitLab returns the Artifact Central token to the client.
  3. The client sends the token to Artifact Central in every request.
  4. Artifact Central verifies the token’s signature.

During this exchange, Artifact Central never calls back to GitLab.

If your account belongs to more than one organization that uses Artifact Central, the token exchange returns a 409 Conflict error. GitLab chooses the organization from your memberships and does not guess between the two. For more information, see Troubleshooting Artifact Central.

Supported GitLab tokens

Artifact Central accepts the following GitLab tokens for authentication:

Legacy personal access tokens, project access tokens, group access tokens, and OAuth tokens need the api scope, because the token exchange is a POST request. The read_api scope isn’t enough. Fine-grained personal access tokens and CI/CD job tokens don’t need a scope.

When Artifact Central receives an Artifact Central token, it retrieves the user’s identity and evaluates it against the registry’s role assignments before it authorizes or denies a request.

Deploy tokens are not supported.

To authenticate from CI/CD outside GitLab, such as GitHub Actions or Jenkins, see Publish and install with CI/CD pipelines outside GitLab.

Token lifetime

The token exchange endpoint issues a five-minute token by default. The GitLab CLI suggests a 15-minute expiry time for the token, but you can set it up to 12 hours.

A token cannot be revoked before it expires. Ask for the shortest lifetime your build requires.

Authenticate with Artifact Central and the GitLab CLI

The GitLab CLI exchanges your GitLab token for a short-lived access token scoped to Artifact Central.

Prerequisites:

To authenticate with Artifact Central with the GitLab CLI, run the following commands:

  1. Get an Artifact Central token:

    shell
    # Prints a token to stdout so a shell can capture it directly
    glab artifact-registry get-token --duration <1h>
    • If not included, --duration defaults to 15 minutes.
  2. Log in with your package client:

    shell
    # Writes the generated token into the configuration file for your package manager
    glab artifact-registry login --<package_format> --registry <registry>
    • For <package_format>, enter a supported package manager. For example, maven.
    • For <registry>, enter the value your format expects:
      • For --docker, enter a bare hostname, such as ar.example.com. The Docker credential helper stores credentials by hostname, so a URL does not work.
      • For every other format, enter the repository URL, such as https://ar.example.com/acme/maven/my-repo.

    Maven and Gradle also take --registry-alias <alias>. For the exact command for your tool, see Artifact Central formats.

  3. Check Artifact Central access status:

    shell
    glab artifact-registry status

Running glab artifact-registry login --docker registers glab as a Docker credential helper. The credential helper ignores the GITLAB_TOKEN environment variable and refreshes the Artifact Central token on every pull and push request. Run glab auth login first if you use --docker and have no stored credential for the host.

Every other flag, and glab artifact-registry get-token, uses the GITLAB_TOKEN environment variable if it is set, and otherwise the credential that glab auth login stores. A CI/CD job that sets GITLAB_TOKEN does not require glab auth login first.

These commands are experiments. Their names and flags can change.

For more information about glab commands and flags for Artifact Central, see glab artifact-registry.

Package client authentication methods

ClientAuthentication method
Docker and OCI clientsBearer token obtained from the registry’s token endpoint.
Maven, Gradle, and sbtBasic authentication. The registry reads the password only and ignores the username.
npm, yarn, and pnpmBearer token.
dnf and dnf5Basic authentication. The registry reads the password only and ignores the username.
The management APIBearer token.

The Private-Token header used in the GitLab Maven package registry is not supported. Custom header authentication is also not supported.

Configure your package manager

The GitLab CLI writes the credential into your package manager’s configuration file. The exact command depends on the format:

The GitLab CLI has no command for dnf yet (issue 8721). Configure an RPM repository by hand instead. For more information, see Configure your client.

Troubleshooting

If your client gets a 401 or 403 response during authentication, see Troubleshooting Artifact Central.