Overview
OpenID Connect (OIDC) allows your GitHub Actions workflows to authenticate with JFrog to download and publish artifacts without storing JFrog passwords, tokens, or API keys in GitHub.
This guide gives an overview of how to configure JFrog to trust GitHub's OIDC as a federated identity, and demonstrates how to use this configuration in a GitHub Actions workflow.
For an example GitHub Actions workflow, see Sample GitHub Actions Integration in the JFrog documentation.
For an example GitHub Actions workflow using the JFrog CLI, see build-publish.yml
in the jfrog-github-oidc-example
repository.
Prerequisites
-
Pour en savoir plus sur les concepts de base décrivant la façon dont GitHub utilise OIDC (OpenID Connect) ainsi que sur son architecture et ses avantages, consultez À propos du renforcement de la sécurité avec OpenID Connect.
-
Avant de continuer, vous devez planifier votre stratégie de sécurité pour veiller à ce que les jetons d’accès soient uniquement alloués de manière prévisible. Pour contrôler la façon dont votre fournisseur de cloud émet des jetons d’accès, vous devez définir au moins une condition, afin que les dépôts non approuvés ne puissent pas demander de jetons d’accès à vos ressources cloud. Pour plus d’informations, consultez « À propos du renforcement de la sécurité avec OpenID Connect ».
-
Si vous suivez ce guide sur GHE.com, sachez que vous devez remplacer certaines valeurs dans la documentation suivante. Consultez À propos du renforcement de la sécurité avec OpenID Connect.
-
To be secure, you need to set a Claims JSON in JFrog when configuring identity mappings. For more information, see AUTOTITLE and À propos du renforcement de la sécurité avec OpenID Connect.
For example, you can set
iss
tohttps://token.actions.githubusercontent.com
, and therepository
to something like "octo-org/octo-repo"`. This will ensure only Actions workflows from the specified repository will have access to your JFrog platform. The following is an example Claims JSON when configuring identity mappings.JSON { "iss": "https://token.actions.githubusercontent.com", "repository": "octo-org/octo-repo" }
{ "iss": "https://token.actions.githubusercontent.com", "repository": "octo-org/octo-repo" }
Adding the identity provider to JFrog
To use OIDC with JFrog, establish a trust relationship between GitHub Actions and the JFrog platform. For more information about this process, see OpenID Connect Integration in the JFrog documentation.
- Sign in to your JFrog Platform.
- Configure trust between JFrog and your GitHub Actions workflows.
- Configure identity mappings.
Updating your GitHub Actions workflow
Authenticating with JFrog using OIDC
In your GitHub Actions workflow file, ensure you are using the provider name and audience you configured in the JFrog Platform.
The following example uses the placeholders YOUR_PROVIDER_NAME
and YOUR_AUDIENCE
.
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up JFrog CLI with OIDC
id: setup-jfrog-cli
uses: jfrog/setup-jfrog-cli@29fa5190a4123350e81e2a2e8d803b2a27fed15e
with:
JF_URL: $
oidc-provider-name: 'YOUR_PROVIDER_NAME'
oidc-audience: 'YOUR_AUDIENCE' # This is optional
- name: Upload artifact
run: jf rt upload "dist/*.zip" my-repo/
Conseil
When OIDC authentication is used, the setup-jfrog-cli
action automatically provides oidc-user
and oidc-token
as step outputs.
These can be used for other integrations that require authentication with JFrog.
To reference these outputs, ensure the step has an explicit id
defined (for example id: setup-jfrog-cli
).
Using OIDC Credentials in other steps
- name: Sign in to Artifactory Docker registry
uses: docker/login-action@v3
with:
registry: $
username: $
password: $
Further reading
- OpenID Connect Integration in the JFrog documentation
- Identity Mappings in the JFrog documentation
- À propos du renforcement de la sécurité avec OpenID Connect