Skip to content

Commit bb68b58

Browse files
authored
Merge pull request #626 from alphagov/impersonated_service_account
Allow service account impersonation for local development
2 parents 7918faa + ae7dd3a commit bb68b58

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ end
3030

3131
group :development, :test do
3232
gem "brakeman", require: false
33+
gem "googleauth", ">= 1.16.0"
3334
gem "govuk_test"
3435
gem "pry-byebug"
3536
gem "rspec-rails"

Gemfile.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ GEM
124124
grpc (~> 1.41)
125125
googleapis-common-protos-types (1.22.0)
126126
google-protobuf (~> 4.26)
127-
googleauth (1.15.1)
127+
googleauth (1.16.2)
128128
faraday (>= 1.0, < 3.a)
129129
google-cloud-env (~> 2.2)
130130
google-logging-utils (~> 0.1)
@@ -581,6 +581,7 @@ DEPENDENCIES
581581
connection_pool
582582
csv
583583
google-cloud-discovery_engine
584+
googleauth (>= 1.16.0)
584585
govuk_app_config
585586
govuk_message_queue_consumer
586587
govuk_test

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,17 @@ make search-api-v2
2626

2727
### Running search-api-v2
2828

29+
#### Prerequisites
30+
31+
1. You must be a member of the integration gcp access google group: govuk-gcp-access-integration@digital.cabinet-office.gov.uk
32+
2. You will need the email address of the custom search-api-v2 integration service account. This is the service account used by Search API v2 running in integration to authenticate its requests to Google Vertex AI Search.
33+
34+
The email address can be found under *IAM and admin > Service Accounts* in the __Search API V2 Integration__ project at https://console.cloud.google.com.
35+
36+
Note: There are two similarly named service accounts. Make sure to select the account used to provide access to the search-api-v2 Rails app and document sync worker.
37+
2938
```bash
30-
gcloud auth application-default login
39+
gcloud auth application-default login --impersonate-service-account <search-api-v2 service account email address>
3140
govuk-docker up -d search-api-v2-app
3241
```
3342

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This is a monkey patch to allow us to use impersonated service account credentials for local development with govuk-docker
2+
# https://github.com/googleapis/google-auth-library-ruby/issues/563
3+
module Google
4+
module Auth
5+
class ImpersonatedServiceAccountCredentials
6+
private
7+
8+
def prepare_auth_header
9+
@source_credentials.updater_proc.call({})
10+
end
11+
end
12+
end
13+
end

0 commit comments

Comments
 (0)