-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Update OIDC connections to use single-step login-action flow #25659
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 all commits
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 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |||||||||||
| title: Create and manage OIDC connections | ||||||||||||
| linkTitle: Create and manage connections | ||||||||||||
| description: Create, update, and delete OIDC connections for your organization | ||||||||||||
| keywords: oidc connections, create oidc connection, github actions, docker/oidc-action, openid connect, enterprise security, admin | ||||||||||||
| keywords: oidc connections, create oidc connection, github actions, docker/login-action, openid connect, enterprise security, admin | ||||||||||||
| tags: [admin] | ||||||||||||
| weight: 10 | ||||||||||||
| --- | ||||||||||||
|
|
@@ -33,68 +33,51 @@ YAML file. | |||||||||||
| 1. Select **Create connection**. | ||||||||||||
| 1. Copy your OIDC connection ID. | ||||||||||||
|
|
||||||||||||
| ### Step 2: Define the GitHub Actions workflow | ||||||||||||
|
|
||||||||||||
| 1. Add a top-level `permissions` key that requests a GitHub OIDC ID token: | ||||||||||||
|
|
||||||||||||
| ```yaml | ||||||||||||
| permissions: | ||||||||||||
| id-token: write | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| 1. Define a job that triggers the OIDC exchange. Update `connection_id` | ||||||||||||
| with the connection ID you copied from Docker: | ||||||||||||
|
|
||||||||||||
| ```yaml | ||||||||||||
| jobs: | ||||||||||||
| login: | ||||||||||||
| runs-on: ubuntu-latest | ||||||||||||
| steps: | ||||||||||||
| - name: OIDC connections | ||||||||||||
| id: docker_oidc | ||||||||||||
| uses: docker/oidc-action@v1 | ||||||||||||
| with: | ||||||||||||
| connection_id: <YOUR_CONNECTION_ID> | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| 1. Add a step that signs in to Docker with an access token once the ID | ||||||||||||
| token passes authentication: | ||||||||||||
|
|
||||||||||||
| ```yaml | ||||||||||||
| - name: Sign in to Docker Hub | ||||||||||||
| uses: docker/login-action@{{% param "login_action_version" %}} | ||||||||||||
| with: | ||||||||||||
| username: <DOCKER_ORGANIZATION_NAME> | ||||||||||||
| password: ${{ steps.docker_oidc.outputs.token }} | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| The `username` value must be an organization name. Personal accounts | ||||||||||||
| aren't supported. | ||||||||||||
|
|
||||||||||||
| Your updated workflow YAML should look like this: | ||||||||||||
|
|
||||||||||||
| ```yaml | ||||||||||||
| permissions: | ||||||||||||
| id-token: write | ||||||||||||
|
|
||||||||||||
| jobs: | ||||||||||||
| login: | ||||||||||||
| runs-on: ubuntu-latest | ||||||||||||
| steps: | ||||||||||||
| - name: OIDC connections | ||||||||||||
| id: docker_oidc | ||||||||||||
| uses: docker/oidc-action@v1 | ||||||||||||
| with: | ||||||||||||
| connection_id: <YOUR_CONNECTION_ID> | ||||||||||||
|
|
||||||||||||
| - name: Sign in to Docker Hub | ||||||||||||
| uses: docker/login-action@{{% param "login_action_version" %}} | ||||||||||||
| with: | ||||||||||||
| username: <YOUR_ORGANIZATION_NAME> | ||||||||||||
| password: ${{ steps.docker_oidc.outputs.token }} | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| 1. Run your GitHub Action and verify the workflow can sign in to Docker. | ||||||||||||
| ### Step 2: Update your workflow | ||||||||||||
|
|
||||||||||||
| Add the OIDC connection ID and your Docker organization name as | ||||||||||||
| [GitHub Actions variables](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables) | ||||||||||||
| in your repository or organization settings. Then update your workflow: | ||||||||||||
|
|
||||||||||||
| ```yaml | ||||||||||||
| name: ci | ||||||||||||
|
|
||||||||||||
| on: | ||||||||||||
| push: | ||||||||||||
| branches: main | ||||||||||||
|
|
||||||||||||
| permissions: | ||||||||||||
| contents: read | ||||||||||||
| id-token: write | ||||||||||||
|
|
||||||||||||
| jobs: | ||||||||||||
| login: | ||||||||||||
| runs-on: ubuntu-latest | ||||||||||||
| steps: | ||||||||||||
| - | ||||||||||||
| name: Login to Docker Hub | ||||||||||||
| uses: docker/login-action@{{% param "login_action_version" %}} | ||||||||||||
| env: | ||||||||||||
| DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_CONNECTIONID }} | ||||||||||||
|
Contributor
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. just to x2 confirm, meant to be an all caps variable?
Contributor
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. nvm intentional, yippee |
||||||||||||
| with: | ||||||||||||
| username: ${{ vars.DOCKERHUB_ORGANIZATION }} | ||||||||||||
|
Comment on lines
+53
to
+63
Contributor
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. @dotjoshrc Is |
||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| The `id-token: write` permission lets the workflow request a GitHub OIDC | ||||||||||||
|
Contributor
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. This is a little dense to read as a full paragraph. We can either add this context next to the key/value pairs as code comments for in-line documentation, or maybe use unordered lists? It's fine as is just a little nit lol: "
Contributor
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
|
||||||||||||
| token. The `docker/login-action` handles the OIDC token exchange and | ||||||||||||
| Docker login in a single step when `DOCKERHUB_OIDC_CONNECTIONID` is set | ||||||||||||
| and `password` is omitted. | ||||||||||||
|
|
||||||||||||
| The `username` value must be an organization name. Personal accounts | ||||||||||||
| aren't supported. | ||||||||||||
|
Comment on lines
+71
to
+72
Member
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. Maybe use a callout for this and if we have a link to roadmap issue tracking personal accounts support that would be great.
Suggested change
|
||||||||||||
|
|
||||||||||||
| Run your GitHub Action and verify the workflow can sign in to Docker. | ||||||||||||
|
|
||||||||||||
| > [!TIP] | ||||||||||||
| > If your workflow needs the Docker access token as a separate output | ||||||||||||
| > (for example, for API calls or custom authentication flows), use | ||||||||||||
| > [`docker/oidc-action`](https://github.com/docker/oidc-action) to | ||||||||||||
| > perform the token exchange explicitly. | ||||||||||||
|
|
||||||||||||
| ## Manage OIDC connections | ||||||||||||
|
|
||||||||||||
|
|
@@ -118,14 +101,13 @@ your Docker resources without deleting the connection. While a connection | |||||||||||
| is deactivated: | ||||||||||||
|
|
||||||||||||
| - It can't issue Docker access tokens. | ||||||||||||
| - Without Docker access tokens, `docker/oidc-action` fails at the | ||||||||||||
| token-exchange step until you activate the connection. | ||||||||||||
| - The login step in your workflow will fail at the token-exchange step | ||||||||||||
| until you activate the connection. | ||||||||||||
|
|
||||||||||||
| Unlike deactivation, deleting an OIDC connection is permanent. Any workflow | ||||||||||||
| whose `docker/oidc-action` step still references the deleted | ||||||||||||
| `connection_id` fails at the token-exchange step. Update that input with a | ||||||||||||
| replacement connection's ID in every affected workflow before it runs | ||||||||||||
| again. | ||||||||||||
| that still references the deleted connection ID will fail at the | ||||||||||||
| token-exchange step. Update the connection ID in every affected workflow | ||||||||||||
| before it runs again. | ||||||||||||
|
|
||||||||||||
| ## What's next | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
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.
Docker organization? GitHub repository? IDK what your take is but since both of us share these words, might want to risk some redundancy to specify which we mean. WYT @gmondello