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

GitHub Enterprise Server External OIDC endpoint failed #283

Closed
Ravio1i opened this issue Dec 16, 2022 · 8 comments
Closed

GitHub Enterprise Server External OIDC endpoint failed #283

Ravio1i opened this issue Dec 16, 2022 · 8 comments
Assignees
Labels
idle Inactive for 14 days question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@Ravio1i
Copy link

Ravio1i commented Dec 16, 2022

So I've st up oidc following the documentation https://docs.github.com/en/[email protected]/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-azure

Error

However when using it i run into the following error:

Using OIDC authentication...
Federated token details: 
 issuer - https://<GITHUB_ENTEPRRISE_URL>/_services/token 
 subject claim - repo:<MY_ORG>/<MY_REPO>:environment:azure
/usr/bin/az cloud set -n azurecloud
Done setting cloud: "azurecloud"
Error: : AADSTS501661: Request to External OIDC endpoint failed.

Usage:

on:
  workflow_dispatch:
  push:

permissions:
  id-token: write
  contents: read

jobs:
  build:
    runs-on: linux
    environment: azure
    steps:
      - run: az version  
      - name: 'Az CLI login'
        uses: actions/login@v1
        with:
          client-id: ${{ secrets.AZURE_CLIENT_ID }}
          tenant-id: ${{ secrets.AZURE_TENANT_ID }}
          subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

      - name: Get az vmss list
        run: az vmss list

Azure configuration of federated credential
Screenshot from 2022-12-16 17-33-19

When changing the Issuer to https://<GITHUB_ENTEPRRISE_URL>/_services/token/ with an appended / the error messages changes to

AADSTS70021: No matching federated identity record found for presented assertion. Assertion Issuer: 'https://<GITHUB_ENTEPRRISE_URL>/_services/token'. Assertion Subject: 'repo:<MY_ORG>/<MY_REPO>:environment:azure'. Assertion Audience: 'api://AzureADTokenExchange'. https://docs.microsoft.com/en-us/azure/active-directory/develop/workload-identity-federation

Where the values of subject and audience are completely the same as configured in azure federeated

@Ravio1i Ravio1i added the need-to-triage Requires investigation label Dec 16, 2022
@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 Dec 19, 2022
@BALAGA-GAYATRI BALAGA-GAYATRI self-assigned this Dec 19, 2022
@BALAGA-GAYATRI
Copy link
Contributor

Hi @Ravio1i ,
It appears that the problem is with the Private instance. Please expose two well-known endpoints to the public internet from the GHES environment.
https://code.cicd.opm.gov/_services/token/.well-known/jwks
https://code.cicd.opm.gov/_services/token/.well-known/openid-configuration
Azure will be unable to validate the OIDC token if these APIs are not available.
Please give it a try and let us know the results.

@Ravio1i
Copy link
Author

Ravio1i commented Dec 20, 2022

Okay got it.
So azure requires network access to these 2 endpoints.
Maybe this is the wrong repo to ask this question, but is there actually a way to just expose those 2 endpoints from ghes settings?

@BALAGA-GAYATRI
Copy link
Contributor

It should be done from your machine/Instance not from the cloud. Were you able to do it? Let us know if you are still stuck with the problem.

@Ravio1i
Copy link
Author

Ravio1i commented Jan 2, 2023

Not exactly. I'm not fully certain which connectivity is required. There is no way to expose the github enterprise server endpoint directly. Its only possible to expose everything or nothing. (Would it require some sort of loadbalancer magic?)

I allowed the inbound access from the AzureActiveDirectory service tags to the Github enterprise instance, but still the same error.
Do we also need outbound from GitHub to the AzureActiveDirectory service?

@BALAGA-GAYATRI
Copy link
Contributor

Adding @kchandra548 to this thread for further help.

@hendrik-schaffer
Copy link

hendrik-schaffer commented Jan 13, 2023

Hi all,
we were facing the same issue and also struggeled to get it up and running. In the end it comes down to what already has been mentioned above, the two endpoints

However, as most GHES instances might be running within a private network, this means those URLs are NOT available from the internet and additionall setup is required.

The tricky part is probably to get the DNS setup right as you are required to use the same DNS for your GHES hostname also for the public DNS entries. This might require special configuration for your networking team

Once you have the DNS in place, you can either add a load balancing solution in front of your GHES which is available from the internet. When using this approach I would also recommend to setup a Web Application Firewall and only allow the access of those endpoints above.

Another solution would be to setup a web server or Lambda/Azure Function that return the content from above URLs once they are requested.

Hope this helps a little

@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 Jan 27, 2023
@BALAGA-GAYATRI
Copy link
Contributor

Closing this issue as the action itself doesn't deal with exposing these endpoints and the complications associated with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idle Inactive for 14 days 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

No branches or pull requests

3 participants