-
Notifications
You must be signed in to change notification settings - Fork 61.9k
Update JFrog GitHub OIDC setup docs #37596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 26 commits
8c8514c
8aca661
7c0f732
b6e661d
d295d1a
9c67e23
adb9081
5152bae
9246dee
48859cf
a1ca515
ed8ab47
1d1b453
25123d1
554c351
c219ce1
33afa50
2162642
14c5fee
9554cc2
6ff7f79
b855d02
3126895
970249b
e3cba36
01a424a
43a087d
fe5153a
b2d7317
285c775
0398058
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -52,59 +52,52 @@ To use OIDC with JFrog, establish a trust relationship between {% data variables | |||||
|
||||||
## Updating your {% data variables.product.prodname_actions %} workflow | ||||||
|
||||||
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. | ||||||
### Example: Authenticating with JFrog using OIDC | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
In your {% data variables.product.prodname_actions %} workflow file, ensure you are using the provider name and audience you configured in the JFrog Platform. | ||||||
EyalDelarea marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
The following example uses the placeholder `YOUR_PROVIDER_NAME`. | ||||||
EyalDelarea marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
The following example uses the placeholders `YOUR_PROVIDER_NAME` and `YOUR_AUDIENCE`. | ||||||
|
||||||
```yaml | ||||||
- name: Fetch Access Token from Artifactory | ||||||
id: fetch_access_token | ||||||
env: | ||||||
ID_TOKEN: ${{ steps.idtoken.outputs.id_token }} | ||||||
run: | | ||||||
ACCESS_TOKEN=$(curl \ | ||||||
-X POST \ | ||||||
-H "Content-type: application/json" \ | ||||||
https://example.jfrog.io/access/api/v1/oidc/token \ | ||||||
-d \ | ||||||
"{\"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 '"') | ||||||
echo ACCESS_TOKEN=$ACCESS_TOKEN >> $GITHUB_OUTPUT | ||||||
``` | ||||||
|
||||||
The following example shows part of a {% data variables.product.prodname_actions %} workflow file using cURL. | ||||||
|
||||||
```yaml | ||||||
- name: Get ID Token (cURL method) | ||||||
id: idtoken | ||||||
run: | | ||||||
ID_TOKEN=$(curl -sLS -H "User-Agent: actions/oidc-client" -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \ | ||||||
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=jfrog-github" | jq .value | tr -d '"') | ||||||
echo "ID_TOKEN=${ID_TOKEN}" >> $GITHUB_OUTPUT | ||||||
``` | ||||||
|
||||||
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). | ||||||
|
||||||
{% data reusables.actions.oidc-deployment-protection-rules %} | ||||||
permissions: | ||||||
id-token: write | ||||||
contents: read | ||||||
|
||||||
```yaml | ||||||
jobs: | ||||||
build: | ||||||
runs-on: ubuntu-latest | ||||||
env: | ||||||
OIDC_AUDIENCE: 'YOUR_AUDIENCE' | ||||||
steps: | ||||||
- name: Setup JFrog CLI with OIDC | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
id: setup-jfrog-cli | ||||||
uses: jfrog/setup-jfrog-cli@29fa5190a4123350e81e2a2e8d803b2a27fed15e | ||||||
with: | ||||||
JF_URL: ${{ env.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/ | ||||||
|
||||||
``` | ||||||
|
||||||
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. | ||||||
> [!TIP] | ||||||
> 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. | ||||||
EyalDelarea marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
> To reference these outputs, ensure the step has an explicit `id` defined (e.g., `id: setup-jfrog-cli`). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
### Example: Using OIDC Credentials in Other Steps | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a bit of extra context you could add here, just to set the scene for the example? |
||||||
```yaml | ||||||
- name: Get ID Token (using env context) | ||||||
uses: {% data reusables.actions.action-github-script %} | ||||||
id: idtoken | ||||||
- name: Login to Artifactory Docker Registry | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
If this isn't accurate, please say so; I'm only recommending this based on https://learn.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/s/sign-in-sign-out |
||||||
uses: docker/login-action@v3 | ||||||
with: | ||||||
script: | | ||||||
const coredemo = require('@actions/core'); | ||||||
let id_token = await coredemo.getIDToken(process.env.OIDC_AUDIENCE); | ||||||
coredemo.setOutput('id_token', id_token); | ||||||
registry: ${{ env.JF_URL }} | ||||||
username: ${{ steps.setup-jfrog-cli.outputs.oidc-user }} | ||||||
password: ${{ steps.setup-jfrog-cli.outputs.oidc-token }} | ||||||
``` | ||||||
|
||||||
## Further Reading | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
EyalDelarea marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
- [JFrog OpenID Connect Integration](https://jfrog.com/help/r/jfrog-platform-administration-documentation/openid-connect-integration) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- [Configure Identity Mappings](https://jfrog.com/help/r/jfrog-platform-administration-documentation/identity-mappings) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- [GitHub Docs: About Security Hardening with OIDC](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this information not accurate any more? It seems to add a nice bridge between the H2 and the H3