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

Add support for workload identity federation and consolidate GCP/BigQuery APIs into seperate classes #120

Merged
merged 7 commits into from
Apr 30, 2024

Conversation

asatwal
Copy link
Collaborator

@asatwal asatwal commented Mar 18, 2024

Use workload identity federation as an alternative authentication for GCP.

For more details please see GCP documentation here.

Configuration of workload identity federation with Azure and links to the azure documentation can be found here

The steps involved for authentication are shown in the diagram below:

azure-gcp-wif

From the diagram, Step 4 is what we have to today with the API key - We go straight to step 4 with the API Key.
So with WIF weeliminate the API Key, but go through Steps 1-3 to get an service account impersonation access token - This replaces the API Key.

This file:
lib/dfe/analytics/azure_federated_auth.rb
implements steps 1-3>

Also the streaming API used to send data to BQ need to be changed.
The old API doesn't work with the new Auth and the new Auth doesn't work with the old API, hence the new event client and the legacy event client.
All config need is from either Azure end variables setup by DevOps:
AZURE_CLIENT_ID
AZURE_FEDERATED_TOKEN_FILE
The rest of the config is from the ENV variable:
GOOGLE_CLOUD_CREDENTIALS
This comes from Google and is a downloadable cloud config.

@asatwal asatwal self-assigned this Mar 18, 2024
@asatwal asatwal force-pushed the workload-identity-federation-auth branch from 6b1eba7 to 6ddbc49 Compare March 18, 2024 11:53
end

context 'when authorization endoint returns OK response' do
it 'calls the expected big query apis' do
Copy link
Contributor

@ericaporter ericaporter Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endpoint

end

context 'when authorization endoint returns OK response' do
let(:events_client) { double(:events_client) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endpoint


azure_federated_auth:
description: |
Whether to use azure workload identity federation for authentication
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asatwal does this also switch between APIs? If so could we add that to the description?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this does switch APIs as the old APIs don't work with the new WIF Auth. Good point I'll add to this description.


module DfE
module Analytics
# For use with for workload identity federeation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asatwal would it be possible for a team to use this API without WIF? How much effort would it be to add that flexibility? In future I can see the old API being decommissioned and some teams needing to move to the new one but not having been able to get things set up in Azure such that they can use WIF.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asatwal I was wondering generally if it's a strong recommend that teams migrate to WIF?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is possible to use the new streaming APIs with the old authentication, but this would be effort though. I think we could consider this if there is a real need for this. As Erica points out above, we could insist on WIF initially and it's a strong recommendation.

@asatwal asatwal force-pushed the workload-identity-federation-auth branch from b7b8206 to 7043e06 Compare March 20, 2024 17:12
@asatwal asatwal marked this pull request as ready for review March 20, 2024 19:44
@asatwal asatwal force-pushed the workload-identity-federation-auth branch 2 times, most recently from ed2384d to 3e0087c Compare March 25, 2024 12:29
@asatwal asatwal force-pushed the workload-identity-federation-auth branch 3 times, most recently from 36ae1eb to e75f6d3 Compare April 24, 2024 14:47
Copy link
Contributor

@ericaporter ericaporter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good!

@asatwal asatwal force-pushed the workload-identity-federation-auth branch from e75f6d3 to 977c1ae Compare April 30, 2024 09:53
@asatwal asatwal merged commit 656807c into main Apr 30, 2024
7 checks passed
@asatwal asatwal deleted the workload-identity-federation-auth branch April 30, 2024 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants