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 workload identity federation docs #160

Merged
merged 3 commits into from
Aug 16, 2024

Conversation

asatwal
Copy link
Collaborator

@asatwal asatwal commented Aug 12, 2024

Context

Add workload identity federation documentation to allow teams to setup on their own projects.

Trello tickets:

https://trello.com/c/F7WrGYYq

Changes proposed in this pull request

Documentation only with full WIF instructions.

@asatwal asatwal self-assigned this Aug 12, 2024
@asatwal asatwal force-pushed the add-workload-identity-federation-docs branch from 1e155b8 to b8d92fa Compare August 13, 2024 11:40
1. Access the `development` service account you previously set up
1. Go to the keys tab, click on "Add key" > "Create new key"
1. Create a JSON private key. This file will be downloaded to your local system.
Set the following environment variables for your Rails app.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe .....Rails app:

### 3. BigQuery authentication method

### 3.1 Workload Identity Federation

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe #### for 3.1

top right.
2. Click "ADD PRINCIPAL".
3. Paste in the email address of the service account you created into the "New
principals" box.
4. Select the "BigQuery Appender Custom" role you created previously.
5. Click "SAVE" to finish.


Copy link
Contributor

@ericaporter ericaporter Aug 13, 2024

Choose a reason for hiding this comment

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

Extra line (unless this follows formatting pattern)


![[azure-gcp-wif.svg]]


Copy link
Contributor

@ericaporter ericaporter Aug 13, 2024

Choose a reason for hiding this comment

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

Extra line (unless this follows formatting pattern)

`AZURE_CLIENT_ID`
`AZURE_FEDERATED_TOKEN_FILE`


Copy link
Contributor

Choose a reason for hiding this comment

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

Extra line (unless this follows formatting pattern)


The service account defined in step 4 above should be granted access using service account impersonation.

If this does not exist then access can be granted with either the [update wif service account permissions ](https://github.com/DFE-Digital/teacher-services-analytics-cloud/blob/main/scripts/gcloud/update-wif-service-account-permissions.sh) gcloud script or from the [IAM](https://console.cloud.google.com/iam-admin/workload-identity-pools/pool/azure-cip-identity-pool) gcloud console, by navigating to the "GRANT ACCESS" window. Use the attributes specified in the gcloud script. Note that the subject must be set to the Managed Identity Object ID from azure for each environment (see Step 1 above).
Copy link
Contributor

Choose a reason for hiding this comment

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

from 'Azure'

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

README.md Outdated

#### 3.1 Workload Identity Federation

We recommend using Workload identity federation as your authentication method as detailed in the [Workload Identity Federation Setup](docs/google_cloud_bigquery_setup.md#workload-identity-federation-setup) guide.
Copy link
Contributor

Choose a reason for hiding this comment

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

@asatwal worth saying why briefly? e.g. 'to avoid security risks associated with use of long-lived JSON keys' or something?


With DfE::Analytics our strong preference is to use WIF where possible. Where WIF is not possible to use then OAuth should be considered. The use of service account API Keys is discouraged.

The diagram below demonstrates our use of WIF within DfE Analytics connecting from an Azure client to BigQuery.
Copy link
Contributor

Choose a reason for hiding this comment

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

"with dfe-analytics" instead of "within DfE Analytics" to be precise?

`AZURE_CLIENT_ID`
`AZURE_FEDERATED_TOKEN_FILE`

Within Azure a managed identity will also exist for each namespace. The managed identity will have the text `gcp-wif` within it's name.
Copy link
Contributor

Choose a reason for hiding this comment

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

its not it's


Within Azure a managed identity will also exist for each namespace. The managed identity will have the text `gcp-wif` within it's name.

Please note the Managed Identity Object ID for each namespace (environment). This is a uuid that will be required in later steps below.
Copy link
Contributor

Choose a reason for hiding this comment

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

'take note of' rather than 'note'? 'note' to me implies something I need to read not an ID I need to copy


### 3. Workload identity pool provider

For each project a workload identity pool with the name `azure-cip-oidc-provider` should exist.
Copy link
Contributor

Choose a reason for hiding this comment

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

provider not pool?


`GOOGLE_CLOUD_CREDENTIALS`

Download the JSON WIF Credentials file either the [create wif client credentials](https://github.com/DFE-Digital/teacher-services-analytics-cloud/blob/main/scripts/gcloud/create-wif-client-credentials.sh) gcloud script or from the [IAM](https://console.cloud.google.com/iam-admin/workload-identity-pools/pool/azure-cip-identity-pool) gcloud console, by navigating to the "CONNECTED SERVICE ACCOUNTS" tab. Use the the attributes specified in the gcloud script.
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing a word or two in this sentence I think

@asatwal asatwal merged commit c21a061 into main Aug 16, 2024
7 checks passed
@asatwal asatwal deleted the add-workload-identity-federation-docs branch August 16, 2024 09:38
@ericaporter ericaporter mentioned this pull request Aug 16, 2024
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