Skip to content

Commit 8c8514c

Browse files
committed
Update JFrog GitHub OIDC setup docs
1 parent c65d6e0 commit 8c8514c

File tree

1 file changed

+25
-47
lines changed

1 file changed

+25
-47
lines changed
Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
title: Configuring OpenID Connect in JFrog
32
shortTitle: OpenID Connect in JFrog
43
intro: Use OpenID Connect within your workflows to authenticate with JFrog.
@@ -19,6 +18,8 @@ OpenID Connect (OIDC) allows your {% data variables.product.prodname_actions %}
1918

2019
This guide gives an overview of how to configure JFrog to trust {% data variables.product.prodname_dotcom %}'s OIDC as a federated identity, and demonstrates how to use this configuration in a {% data variables.product.prodname_actions %} workflow.
2120

21+
> **Note:** If you're using the [`jfrog/setup-jfrog-cli`](https://github.com/jfrog/setup-jfrog-cli) GitHub Action (v4.5.7+), OIDC authentication is fully supported out-of-the-box. You only need to configure your provider name and audience — no manual token exchange is necessary.
22+
2223
For an example {% data variables.product.prodname_actions %} workflow, see [Sample {% data variables.product.prodname_actions %} Integration](https://jfrog.com/help/r/jfrog-platform-administration-documentation/sample-github-actions-integration) in the JFrog documentation.
2324

2425
For an example {% data variables.product.prodname_actions %} workflow using the JFrog CLI, see [`build-publish.yml`](https://github.com/jfrog/jfrog-github-oidc-example/blob/main/.github/workflows/build-publish.yml) in the `jfrog-github-oidc-example` repository.
@@ -52,59 +53,36 @@ To use OIDC with JFrog, establish a trust relationship between {% data variables
5253

5354
## Updating your {% data variables.product.prodname_actions %} workflow
5455

55-
Once you establish a trust relationship between {% data variables.product.prodname_actions %} and the JFrog platform, you can update your {% data variables.product.prodname_actions %} workflow file.
56-
57-
In your {% data variables.product.prodname_actions %} workflow file, ensure you are using the provider name and audience you configured in the JFrog Platform.
58-
59-
The following example uses the placeholder `YOUR_PROVIDER_NAME`.
56+
### Example: Authenticating with JFrog using OIDC
6057

6158
```yaml
62-
- name: Fetch Access Token from Artifactory
63-
id: fetch_access_token
64-
env:
65-
ID_TOKEN: ${{ steps.idtoken.outputs.id_token }}
66-
run: |
67-
ACCESS_TOKEN=$(curl \
68-
-X POST \
69-
-H "Content-type: application/json" \
70-
https://example.jfrog.io/access/api/v1/oidc/token \
71-
-d \
72-
"{\"grant_type\": \"urn:ietf:params:oauth:grant-type:token-exchange\", \"subject_token_type\":\"urn:ietf:params:oauth:token-type:id_token\", \"subject_token\": \"$ID_TOKEN\", \"provider_name\": \"YOUR_PROVIDER_NAME\"}" | jq .access_token | tr -d '"')
73-
echo ACCESS_TOKEN=$ACCESS_TOKEN >> $GITHUB_OUTPUT
74-
```
75-
76-
The following example shows part of a {% data variables.product.prodname_actions %} workflow file using cURL.
77-
78-
```yaml
79-
- name: Get ID Token (cURL method)
80-
id: idtoken
81-
run: |
82-
ID_TOKEN=$(curl -sLS -H "User-Agent: actions/oidc-client" -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
83-
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=jfrog-github" | jq .value | tr -d '"')
84-
echo "ID_TOKEN=${ID_TOKEN}" >> $GITHUB_OUTPUT
85-
```
59+
permissions:
60+
id-token: write
61+
contents: read
8662

87-
Alternatively, you can set the audience as an environment variable using the `env` context. For more information about the `env` context, see [AUTOTITLE](/actions/learn-github-actions/contexts#env-context).
88-
89-
{% data reusables.actions.oidc-deployment-protection-rules %}
90-
91-
```yaml
9263
jobs:
9364
build:
9465
runs-on: ubuntu-latest
95-
env:
96-
OIDC_AUDIENCE: 'YOUR_AUDIENCE'
66+
steps:
67+
- name: Setup JFrog CLI with OIDC
68+
uses: jfrog/setup-jfrog-cli@v4
69+
with:
70+
oidc-provider-name: 'YOUR_PROVIDER_NAME'
71+
oidc-audience: 'YOUR_AUDIENCE'
72+
73+
- name: Upload artifact
74+
run: jf rt upload "dist/*.zip" my-repo/
9775
```
9876

99-
Then, in your workflow file, retrieve the value of the variables stored in the `env` context. The following example uses the `env` context to retrieve the OIDC audience.
77+
## Security Best Practices
10078

101-
```yaml
102-
- name: Get ID Token (using env context)
103-
uses: {% data reusables.actions.action-github-script %}
104-
id: idtoken
105-
with:
106-
script: |
107-
const coredemo = require('@actions/core');
108-
let id_token = await coredemo.getIDToken(process.env.OIDC_AUDIENCE);
109-
coredemo.setOutput('id_token', id_token);
79+
- Always use `permissions: id-token: write` in workflows that authenticate with JFrog.
80+
- Limit trust using specific claims like `repository`, `ref`, or `environment`.
81+
- Configure identity mappings in JFrog to restrict which workflows are allowed to authenticate.
82+
83+
## Further Reading
84+
85+
- [JFrog OpenID Connect Integration](https://jfrog.com/help/r/jfrog-platform-administration-documentation/openid-connect-integration)
86+
- [GitHub Docs: About security hardening with OpenID Connect](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
87+
- [JFrog CLI Docs: `exchange-oidc-token` command (manual usage)](https://jfrog.com/help/r/jfrog-cli-documentation/oidc-commands#exchange-oidc-token)
11088
```

0 commit comments

Comments
 (0)