Skip to content
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

Azure US Government OIDC #298

Closed
jamesseiwert opened this issue Feb 3, 2023 · 16 comments · Fixed by #321
Closed

Azure US Government OIDC #298

jamesseiwert opened this issue Feb 3, 2023 · 16 comments · Fixed by #321
Assignees
Labels
question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@jamesseiwert
Copy link

When using OIDC in azure government an error is thrown on login but still works successfully

Using OIDC authentication...
Error: undefined. Please make sure to give write permissions to id-token in the workflow.
/usr/bin/az cloud set -n azureusgovernment
WARNING: Switched active cloud to 'AzureUSGovernment'.
WARNING: Use 'az login' to log in to this cloud.
WARNING: Use 'az account set' to set the active subscription.
Done setting cloud: "azureusgovernment"
Login successful.

The workflow has the permissions set as well

permissions:
id-token: write
contents: read

@jamesseiwert jamesseiwert added the need-to-triage Requires investigation label Feb 3, 2023
@arnoldna
Copy link

arnoldna commented Feb 6, 2023

There is an open PR on this issue #258. Waiting on approval of the PR since November

@BALAGA-GAYATRI BALAGA-GAYATRI added question The issue doesn't require a change to the product in order to be resolved. Most issues start as that and removed need-to-triage Requires investigation labels Feb 15, 2023
@BALAGA-GAYATRI
Copy link
Contributor

BALAGA-GAYATRI commented Feb 15, 2023

@jamesseiwert Ideally it should throw an error saying Govt clouds are not supported. Can you share more details if you are using a forked version of the action where you are bypassing that condition. Please share your workflow yaml for better understanding. Coming to the support for Govt clouds we are following up and will get back to you with more info.

@jamesseiwert
Copy link
Author

jamesseiwert commented Feb 25, 2023

@BALAGA-GAYATRI sorry for the delay. The workflow is simple and the login appears to work just with the false positive error. Below is the workflow file we are doing and at the end we can do a simple print out of all resource groups.

`

steps:
  - name: Login to Azure US Gov Cloud
    uses: azure/login@v1
    with:
      environment: "AzureUSGovernment"
      client-id: ${{ vars.AZURE_CLIENT_ID }}
      tenant-id: ${{ vars.AZURE_TENANT_ID }}
      subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}

  - name: List Resource Groups
    run: |
      az group list`

Screenshot 2023-02-24 at 11 34 15 PM

@BALAGA-GAYATRI
Copy link
Contributor

Can you please add the below permissions for OIDC token and check the logs once.

permissions:
      id-token: write
      contents: read

@jamesseiwert
Copy link
Author

@BALAGA-GAYATRI we do have those permissions in the workflow

@BALAGA-GAYATRI
Copy link
Contributor

https://github.com/Azure/login/blob/master/src/main.ts#L116
The error is being thrown in this line while getting an id-token. Since we aren't handling the error correctly there, it's continuing the flow(not expected though). But login successful is still not expected here. Since the error was thrown before itself, our execution is not reaching this point to throw the error for Govt clouds. I need to look into more details to understand this better. Are you using this action in GitHub enterprise? If yes, make sure to check this out.

@github-actions
Copy link

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle Inactive for 14 days label Mar 30, 2023
@jamesseiwert
Copy link
Author

We are using this in both Github.com and Github Enterprise

@github-actions github-actions bot removed the idle Inactive for 14 days label Apr 13, 2023
@github-actions
Copy link

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle Inactive for 14 days label Apr 27, 2023
@some-natalie
Copy link

not stale, Gov users matter! ❤️

@devopsjesus
Copy link

Hello, can we have an update on this issue? We are trying to move to OIDC authentication as recommended by the DoD Reference Architecture for DevSecOps, but have run into this same issue. Noting the documentation has read that government cloud support is coming 'soon' but this issue itself is now months old, presumably outside the definition of 'soon.' Thanks 😃

@MoChilia MoChilia self-assigned this May 17, 2023
@jamesseiwert
Copy link
Author

@MoChilia - Any update you can provide?

@MoChilia
Copy link
Member

Hi @jamesseiwert! I have submitted pr #321 to fix this issue. Once this pr is merged, we will plan a release for it so that the OIDC authentication for sovereign clouds will be supported.

@MoChilia
Copy link
Member

Closing this issue for now. It has been solved by #321.

@danelson
Copy link

@MoChilia this change does not seem to address powershell login as mentioned in #248.

Specifically:

"Error": "AADSTS900382: Confidential Client is not supported in Cross Cloud request

name: Test Azure powershell login with OIDC

on:
  workflow_dispatch:

permissions:
  id-token: write
  contents: read

jobs:
  test-oidc-login-ps
    runs-on: ubuntu-latest
    environment: Azure-Gov-Dev # valid environment
    steps:
    - name: OIDC Login to Azure
      uses: azure/login@master # I built lib/main.js from master
      with:
        client-id: ${{ secrets.AZURE_CLIENT_ID }}
        tenant-id: ${{ secrets.AZURE_TENANT_ID }}
        subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
        environment: 'AzureUSGovernment'
        enable-AzPSSession: true # works if this is not included

@YanaXu
Copy link
Collaborator

YanaXu commented Jul 28, 2023

@danelson , could you open a new issue and provide this workflow & the debug log of your workflow?
Since this is a closed issue, we may miss information here. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants