This guide needs the SafeDep Cloud Team or Enterprise plan. See pricing.
Prerequisites
- An owner of your GitHub organization, for step 1.
- A SafeDep Cloud Owner or Admin of your tenant, for steps 2 and 3.
- Your tenant domain, such as
your-team.your-org.safedep.io. Thetenant-idinput of the action takes this value.safedep auth statusshows it in the tenant field. The Tenant ID button on the API keys settings page also shows it. - The safedep CLI
v0.12.0or later, signed in withsafedep auth login. - For PMG: the
safedep/pmgactionv0.37.0or later, which installs PMGv0.37.0or later.safedep/pmg@v2with the defaultversion: latestmeets this. - For vet: the vet v2 GitHub Action.
safedep/vet-action@v1has no OIDC mode and needs an API key.
Set up the tenant
1
Link the SafeDep GitHub App
An owner of the GitHub organization installs the SafeDep GitHub App, and links the installation to your tenant when SafeDep Cloud asks.If the app is already installed:
- An owner of the GitHub organization accepts the new permission Members: read of the SafeDep GitHub App in the organization settings on GitHub.
- An owner of the GitHub organization links the installation to your tenant again, as at install time.
2
Check the provider
A provider is the record in your tenant that accepts the GitHub OIDC tokens of one GitHub account. The link of an owner creates it. List the providers:
LINK must be active. If your account has no row, see Troubleshoot.3
Create the org-wide rule
Replace
acme with the account in the PROVIDER column:--grant tool lets a job make only the calls that PMG and vet use. For the list, see What the credential can do.The rule covers only the default events. When a repository has no project, its first run that publishes scan results creates the project. This works only when the app installation selects the repository.Change the workflow
Give the jobid-token: write, set tenant-id, and remove api-key. Store the tenant domain as a GitHub Actions variable, because it is not a secret. These examples use a variable with the name SAFEDEP_CLOUD_TENANT_DOMAIN.
- PMG
- vet v2
endpoint-id input and prints a warning. For the result of each failure case, see Use GitHub OIDC instead of an API key in the PMG action documentation.Check the credential
- Run the workflow.
-
List the exchanges of the last day:
issued. After the job ends, the DETAIL column of a revoked credential says revoked.
If the list is empty, no exchange reached your provider. Read the log of the PMG or vet step, and see Troubleshoot.
Move from an API key
While the job setsapi-key, the PMG action and the vet action use the API key. So you can move one workflow at a time.
1
Add the permission
Add
id-token: write to the permissions of the job.2
Remove the API key input
Remove the
api-key input. Keep tenant-id.3
Run the workflow
Run the workflow, and check the credential.
4
Change the other workflows
Do steps 1 to 3 for each other workflow that uses the API key.
5
Delete the secret
When no workflow uses the API key, delete its secret from GitHub.
6
Delete the API key
Delete the API key on the API keys settings page.
Narrow the rule
For each flag, see thesafedep workload command reference.
A job gets a credential when any rule matches it. A narrower rule does not limit the org-wide rule. To give credentials to some repositories only, delete the org-wide rule. Then create rules that name the repositories:
--repositorynames a repository of the account. The server stores its numeric ID, so a rename does not change the rule. Repeat the flag for more repositories.--reftakes a full ref, such asrefs/heads/main, or a prefix that ends with/*, such asrefs/heads/release/*.--eventlists the events that the rule covers. See Events that a rule covers.--max-lifetimesets the longest life of a credential, from1mto6h. The default is6h. PMG cannot refresh its credential, so give a PMG job a maximum life that is longer than the job.--project-binding manualstops a run from creating a project for a repository. A member adds the repository as a project first. The default isautofor a rule with no--repository, andmanualfor a rule with--repository.
--repository, --ref and --event adds one condition to the rule. When more than one rule matches a job, SafeDep Cloud uses the rule with the most conditions. Its --max-lifetime and --project-binding apply. When two such rules have the same number of conditions, the older rule applies.
The CLI has no condition on the runner. For self-hosted runners, see Self-hosted runners.
Events that a rule covers
A rule with no--event covers only these default events: push, pull_request, merge_group, schedule, workflow_dispatch and release.
An outsider can start most other events, so a rule must list them. For the reason, see Which events a rule covers. To allow an event such as pull_request_target, create a rule that lists it, and name the repositories that need it:
--event covers only the events that it lists. A run of an event outside the defaults can fetch the policy, check in and send events. It publishes no scan results to a project.
Troubleshoot
When SafeDep Cloud refuses the exchange, the PMG step fails. The error and the job summary name the tenant and the reason that SafeDep Cloud gives. vet scans with no SafeDep Cloud data and writes the reason in theworkload_exchange_failed diagnostic. To see the refused exchanges of your tenant, run safedep workload exchange list --denied --since 1d.
The rows are in the order that a PMG job meets them. The last row is for the admin who creates rules.
Workload Identity
See how the exchange works and what a compromised step can do.
PMG in GitHub Actions
Block malicious packages in GitHub Actions.
Authentication
See the other ways that tools sign in to SafeDep Cloud.
Review CI Blocks
See the packages that PMG blocked across your pipelines.

