Compare commits

...

7 Commits

Author SHA1 Message Date
github-actions[bot] 4ff0d3f1cb [dependabot skip] chore: update generated content 2026-07-27 05:53:42 +00:00
dependabot[bot] a7569c1208 build(deps): bump js-yaml from 5.2.1 to 5.2.2
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 5.2.1 to 5.2.2.
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/5.2.1...5.2.2)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 5.2.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-27 05:52:54 +00:00
CrazyMax abd2ef45e7 Merge pull request #1055 from crazy-max/test-registry-auth-oidc
test: cover Docker Hub OIDC with registry-auth
2026-07-24 14:22:47 +02:00
CrazyMax d49d3a9839 Merge pull request #1054 from crazy-max/oidc-missing-dhi
support dhi.io as Docker Hub OIDC registry
2026-07-24 14:22:20 +02:00
CrazyMax b58b17c30b test: cover Docker Hub OIDC with registry-auth
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-07-24 10:37:01 +02:00
CrazyMax be646c21ce chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-07-24 10:33:14 +02:00
CrazyMax d77c059cb9 support dhi.io as Docker Hub OIDC registry
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-07-24 10:26:38 +02:00
10 changed files with 245 additions and 127 deletions
+21
View File
@@ -173,6 +173,27 @@ jobs:
with:
username: ${{ vars.DOCKERHUB_OIDC_USERNAME }}
registry-auth-oidc:
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
-
name: Login to registries
uses: ./
env:
DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_CONNECTIONID }}
with:
registry-auth: |
- username: ${{ vars.DOCKERHUB_OIDC_USERNAME }}
- registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
ecr:
runs-on: ${{ matrix.os }}
strategy:
+32
View File
@@ -648,6 +648,38 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
```
Docker Hub OIDC can also be used with `registry-auth`. Grant `id-token: write`,
set `DOCKERHUB_OIDC_CONNECTIONID`, pass the Docker Hub organization name as
`username`, and omit `password` for the Docker Hub object:
```yaml
name: ci
on:
push:
branches: main
permissions:
contents: read
id-token: write
jobs:
login:
runs-on: ubuntu-latest
steps:
-
name: Login to registries
uses: docker/login-action@v4
env:
DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_CONNECTIONID }}
with:
registry-auth: |
- username: ${{ vars.DOCKERHUB_ORGANIZATION }}
- registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
```
### Set scopes for the authentication token
The `scope` input allows limiting registry credentials to a specific repository
+19
View File
@@ -54,6 +54,25 @@ test('getAuthList skips secret masking when registry-auth password is absent', a
});
});
test('getAuthList supports password-less Docker Hub registry-auth for OIDC', async () => {
const [auth] = getAuthList({
registry: '',
username: '',
password: '',
scope: '',
ecr: '',
logout: true,
registryAuth: '- username: docker-org\n'
});
expect(auth).toMatchObject({
registry: 'docker.io',
username: 'docker-org',
password: undefined,
ecr: 'auto'
});
});
test('getAuthList masks registry-auth password when present', async () => {
const stdoutWriteSpy = vi.spyOn(process.stdout, 'write').mockImplementation(() => true);
getAuthList({
+39 -2
View File
@@ -1,8 +1,14 @@
import {expect, test, vi} from 'vitest';
import {afterEach, expect, test, vi} from 'vitest';
import {Docker} from '@docker/actions-toolkit/lib/docker/docker.js';
import {loginStandard, logout} from '../src/docker.js';
import {login, loginStandard, logout} from '../src/docker.js';
import * as dockerhub from '../src/dockerhub.js';
afterEach(() => {
vi.restoreAllMocks();
delete process.env.DOCKERHUB_OIDC_CONNECTIONID;
});
test('loginStandard calls exec', async () => {
const execSpy = vi.spyOn(Docker, 'getExecOutput').mockImplementation(async () => {
@@ -32,6 +38,37 @@ test('loginStandard calls exec', async () => {
});
});
test('login exchanges Docker Hub OIDC token for password-less auth', async () => {
process.env.DOCKERHUB_OIDC_CONNECTIONID = '123e4567-e89b-42d3-a456-426614174000';
const execSpy = vi.spyOn(Docker, 'getExecOutput').mockImplementation(async () => {
return {
exitCode: 0,
stdout: '',
stderr: ''
};
});
const oidcSpy = vi.spyOn(dockerhub, 'getOIDCToken').mockResolvedValue({
username: 'docker-org',
token: 'hub-token'
});
await login({
registry: 'docker.io',
username: 'docker-org',
password: '',
scope: '',
ecr: 'auto',
configDir: ''
});
expect(oidcSpy).toHaveBeenCalledWith('docker.io', 'docker-org');
expect(execSpy).toHaveBeenCalledWith(['login', '--password-stdin', '--username', 'docker-org', 'docker.io'], {
input: Buffer.from('hub-token'),
silent: true,
ignoreReturnCode: true
});
});
test('logout calls exec', async () => {
const execSpy = vi.spyOn(Docker, 'getExecOutput').mockImplementation(async () => {
return {
Generated Vendored
+113 -113
View File
File diff suppressed because one or more lines are too long
Generated Vendored
+3 -3
View File
File diff suppressed because one or more lines are too long
Generated Vendored
+3 -2
View File
@@ -2396,11 +2396,12 @@ SOFTWARE.
-----------
The following npm package may be included in this product:
The following npm packages may be included in this product:
- js-yaml@5.2.1
- js-yaml@5.2.2
This package contains the following license:
These packages each contain the following license:
(The MIT License)
+1 -1
View File
@@ -30,7 +30,7 @@
"@docker/actions-toolkit": "^0.94.0",
"http-proxy-agent": "^9.1.0",
"https-proxy-agent": "^9.1.0",
"js-yaml": "^5.2.1",
"js-yaml": "^5.2.2",
"uuid": "^14.0.1"
},
"devDependencies": {
+2 -5
View File
@@ -12,17 +12,14 @@ interface OIDCTokenResponse {
access_token: string;
}
const registries = new Set(['', 'docker.io', 'registry-1.docker.io', 'registry-1-stage.docker.io', 'dhi.io']);
const defaultExpiresIn = 300;
const minExpiresIn = 300;
const maxExpiresIn = 3600;
const maxRetries = 5;
export const isDockerHubOIDC = (registry: string, password: string): boolean => {
return process.env.DOCKERHUB_OIDC_CONNECTIONID !== undefined && !password && isDockerHubRegistry(registry);
};
const isDockerHubRegistry = (registry: string): boolean => {
return registry === '' || registry === 'docker.io' || registry === 'registry-1.docker.io' || registry === 'registry-1-stage.docker.io';
return process.env.DOCKERHUB_OIDC_CONNECTIONID !== undefined && !password && registries.has(registry);
};
export const getOIDCToken = async (registry: string, username: string): Promise<LoginCredentials> => {
+12 -1
View File
@@ -3174,7 +3174,7 @@ __metadata:
globals: "npm:^17.3.0"
http-proxy-agent: "npm:^9.1.0"
https-proxy-agent: "npm:^9.1.0"
js-yaml: "npm:^5.2.1"
js-yaml: "npm:^5.2.2"
prettier: "npm:^3.8.1"
typescript: "npm:^5.9.3"
uuid: "npm:^14.0.1"
@@ -4357,6 +4357,17 @@ __metadata:
languageName: node
linkType: hard
"js-yaml@npm:^5.2.2":
version: 5.2.2
resolution: "js-yaml@npm:5.2.2"
dependencies:
argparse: "npm:^2.0.1"
bin:
js-yaml: bin/js-yaml.mjs
checksum: 10/2b4c2933af12c97e1c4894a4f27fe9b06dab70a64a96bb50624b4429bef6bf11008bde20d868bce52a36784473314efc30078ba6025b58cf7537961e23b1ae9c
languageName: node
linkType: hard
"jsbn@npm:1.1.0":
version: 1.1.0
resolution: "jsbn@npm:1.1.0"