diff --git a/README.md b/README.md index af5c833..ad303b5 100644 --- a/README.md +++ b/README.md @@ -757,10 +757,10 @@ The following inputs can be used as `step.with` keys: The following environment variables can be set as `step.env` keys: -| Name | Type | Default | Description | -|-------------------------------|--------|---------|-----------------------------------------------------------------------------| -| `DOCKERHUB_OIDC_CONNECTIONID` | String | | Docker Hub OIDC connection ID. Required for Docker Hub OIDC login | -| `DOCKERHUB_OIDC_EXPIREIN` | Number | `300` | Docker Hub OIDC token lifetime in seconds. Must be between `300` and `3600` | +| Name | Type | Default | Description | +|-------------------------------|--------|---------|----------------------------------------------------------------------------------------------------| +| `DOCKERHUB_OIDC_CONNECTIONID` | String | | Docker Hub OIDC connection ID. Required for Docker Hub OIDC login | +| `DOCKERHUB_OIDC_EXPIREIN` | Number | `300` | Docker Hub OIDC token lifetime in seconds. Must be between `300` (5 minutes) and `21600` (6 hours) | ## Contributing diff --git a/__tests__/dockerhub.test.ts b/__tests__/dockerhub.test.ts index d326780..6345f0d 100644 --- a/__tests__/dockerhub.test.ts +++ b/__tests__/dockerhub.test.ts @@ -86,10 +86,10 @@ describe('getOIDCToken', () => { }); test('uses custom token expiration', async () => { - process.env.DOCKERHUB_OIDC_EXPIREIN = '900'; + process.env.DOCKERHUB_OIDC_EXPIREIN = '21600'; await dockerhub.getOIDCToken('docker.io', 'dbowie'); const body = new URLSearchParams(postSpy.mock.calls[0][1]); - expect(body.get('expires_in')).toBe('900'); + expect(body.get('expires_in')).toBe('21600'); }); test('uses stage identity host for stage registry', async () => { @@ -112,9 +112,9 @@ describe('getOIDCToken', () => { expect(postSpy).not.toHaveBeenCalled(); }); - test.each(['not-a-number', '299', '3601'])('validates token expiration %p', async expiresIn => { + test.each(['not-a-number', '299', '21601'])('validates token expiration %p', async expiresIn => { process.env.DOCKERHUB_OIDC_EXPIREIN = expiresIn; - await expect(dockerhub.getOIDCToken('docker.io', 'dbowie')).rejects.toThrow(`Invalid DOCKERHUB_OIDC_EXPIREIN: ${expiresIn}. Must be between 300 and 3600`); + await expect(dockerhub.getOIDCToken('docker.io', 'dbowie')).rejects.toThrow(`Invalid DOCKERHUB_OIDC_EXPIREIN: ${expiresIn}. Must be between 300 and 21600`); expect(getIDTokenMock).not.toHaveBeenCalled(); expect(postSpy).not.toHaveBeenCalled(); }); diff --git a/src/dockerhub.ts b/src/dockerhub.ts index 0a39ac2..1939bf0 100644 --- a/src/dockerhub.ts +++ b/src/dockerhub.ts @@ -15,7 +15,7 @@ interface OIDCTokenResponse { 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 maxExpiresIn = 21600; const maxRetries = 5; export const isDockerHubOIDC = (registry: string, password: string): boolean => {