-
Notifications
You must be signed in to change notification settings - Fork 61.6k
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
Draft
EyalDelarea
wants to merge
9
commits into
github:main
Choose a base branch
from
EyalDelarea:update_jfrog_docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+25
−43
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8c8514c
Update JFrog GitHub OIDC setup docs
EyalDelarea 8aca661
Merge branch 'main' into update_jfrog_docs
EyalDelarea 7c0f732
Remove note section
EyalDelarea b6e661d
Merge branch 'update_jfrog_docs' of https://github.com/EyalDelarea/do…
EyalDelarea d295d1a
Merge branch 'main' of https://github.com/github/docs into update_jfr…
EyalDelarea 9c67e23
Fix diff
EyalDelarea adb9081
CR
EyalDelarea 5152bae
Merge branch 'main' of https://github.com/github/docs into update_jfr…
EyalDelarea 9246dee
Remove unused variable
EyalDelarea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,59 +52,41 @@ 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 | ||
|
||
In your {% data variables.product.prodname_actions %} workflow file, ensure you are using the provider name and audience you configured in the JFrog Platform. | ||
|
||
The following example uses the placeholder `YOUR_PROVIDER_NAME`. | ||
EyalDelarea marked this conversation as resolved.
Show resolved
Hide resolved
|
||
The following example uses the placeholder `YOUR_PROVIDER_NAME` & `YOUR_AUDIENCE`. | ||
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. Please correct to: "The following example uses the placeholders |
||
|
||
```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 | ||
uses: jfrog/setup-jfrog-cli@v4 | ||
with: | ||
oidc-provider-name: 'YOUR_PROVIDER_NAME' | ||
oidc-audience: 'YOUR_AUDIENCE' | ||
|
||
- 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. | ||
## Security Best Practices | ||
|
||
```yaml | ||
- name: Get ID Token (using env context) | ||
uses: {% data reusables.actions.action-github-script %} | ||
id: idtoken | ||
with: | ||
script: | | ||
const coredemo = require('@actions/core'); | ||
let id_token = await coredemo.getIDToken(process.env.OIDC_AUDIENCE); | ||
coredemo.setOutput('id_token', id_token); | ||
- Always use `permissions: id-token: write` in workflows that authenticate with JFrog. | ||
- Limit trust using specific claims like `repository`, `ref`, or `environment`. | ||
- Configure identity mappings in JFrog to restrict authentication to specific workflows. | ||
|
||
## Further Reading | ||
|
||
- [JFrog OpenID Connect Integration](https://jfrog.com/help/r/jfrog-platform-administration-documentation/openid-connect-integration) | ||
- [JFrog Platform Identify Mappings DOCS](https://jfrog.com/help/r/jfrog-platform-administration-documentation/identity-mappings) | ||
- [JFrog CLI Docs: `exchange-oidc-token` command (manual usage)](https://jfrog.com/help/r/jfrog-cli-documentation/oidc-commands#exchange-oidc-token) | ||
- [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) | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Format the workflow file name as code, like this:
{% data variables.product.prodname_actions %}