Skip to content

Commit f9d2839

Browse files
authored
Add necessary changes to provision QA with Terraform (#2618)
Also programmatically determine backend service IDs.
1 parent c6a6bc7 commit f9d2839

28 files changed

+231
-148
lines changed

core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ dependencies {
166166
// gradleLint.ignore('unused-dependency') {
167167
implementation deps['com.google.gwt:gwt-user']
168168
// }
169+
implementation deps['com.google.cloud:google-cloud-compute']
169170
implementation deps['com.google.cloud:google-cloud-core']
170171
implementation deps['com.google.cloud:google-cloud-storage']
171172
implementation deps['com.google.cloud:google-cloud-tasks']

core/gradle.lockfile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ com.google.api-client:google-api-client-jackson2:2.0.1=compileClasspath,deploy_j
3232
com.google.api-client:google-api-client-jackson2:2.2.0=testRuntimeClasspath
3333
com.google.api-client:google-api-client-java6:2.1.4=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
3434
com.google.api-client:google-api-client-servlet:2.2.0=testRuntimeClasspath
35-
com.google.api-client:google-api-client-servlet:2.7.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath
36-
com.google.api-client:google-api-client:2.7.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
35+
com.google.api-client:google-api-client-servlet:2.7.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath
36+
com.google.api-client:google-api-client:2.7.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
3737
com.google.api.grpc:gapic-google-cloud-storage-v2:2.32.1-alpha=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath
3838
com.google.api.grpc:gapic-google-cloud-storage-v2:2.45.0-beta=testCompileClasspath,testRuntimeClasspath
3939
com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1:3.9.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
@@ -54,6 +54,7 @@ com.google.api.grpc:proto-google-cloud-bigquerystorage-v1beta1:0.181.0=compileCl
5454
com.google.api.grpc:proto-google-cloud-bigquerystorage-v1beta2:0.181.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
5555
com.google.api.grpc:proto-google-cloud-bigtable-admin-v2:2.43.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
5656
com.google.api.grpc:proto-google-cloud-bigtable-v2:2.43.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
57+
com.google.api.grpc:proto-google-cloud-compute-v1:1.64.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
5758
com.google.api.grpc:proto-google-cloud-datastore-v1:0.112.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
5859
com.google.api.grpc:proto-google-cloud-firestore-v1:3.25.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
5960
com.google.api.grpc:proto-google-cloud-monitoring-v3:3.49.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
@@ -94,7 +95,7 @@ com.google.apis:google-api-services-iam:v2-rev20240530-2.0.0=compileClasspath,de
9495
com.google.apis:google-api-services-iamcredentials:v1-rev20211203-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
9596
com.google.apis:google-api-services-monitoring:v3-rev20241017-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
9697
com.google.apis:google-api-services-pubsub:v1-rev20220904-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
97-
com.google.apis:google-api-services-sheets:v4-rev20241008-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
98+
com.google.apis:google-api-services-sheets:v4-rev20241203-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
9899
com.google.apis:google-api-services-sqladmin:v1beta4-rev20240925-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
99100
com.google.apis:google-api-services-storage:v1-rev20240706-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath
100101
com.google.apis:google-api-services-storage:v1-rev20241008-2.0.0=testRuntimeClasspath
@@ -120,6 +121,7 @@ com.google.cloud.sql:jdbc-socket-factory-core:1.21.0=compileClasspath,deploy_jar
120121
com.google.cloud.sql:postgres-socket-factory:1.21.0=deploy_jar,runtimeClasspath,testRuntimeClasspath
121122
com.google.cloud:google-cloud-bigquerystorage:3.9.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
122123
com.google.cloud:google-cloud-bigtable:2.43.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
124+
com.google.cloud:google-cloud-compute:1.64.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
123125
com.google.cloud:google-cloud-core-grpc:2.42.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath
124126
com.google.cloud:google-cloud-core-grpc:2.48.0=testCompileClasspath,testRuntimeClasspath
125127
com.google.cloud:google-cloud-core-http:2.31.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath
@@ -153,7 +155,7 @@ com.google.devtools.ksp:symbol-processing-api:1.9.20-1.0.14=annotationProcessor,
153155
com.google.errorprone:error_prone_annotation:2.23.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
154156
com.google.errorprone:error_prone_annotations:2.20.0=soy
155157
com.google.errorprone:error_prone_annotations:2.23.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
156-
com.google.errorprone:error_prone_annotations:2.35.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
158+
com.google.errorprone:error_prone_annotations:2.36.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
157159
com.google.errorprone:error_prone_annotations:2.7.1=checkstyle
158160
com.google.errorprone:error_prone_check_api:2.23.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
159161
com.google.errorprone:error_prone_core:2.23.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
@@ -179,14 +181,14 @@ com.google.guava:guava:33.0.0-jre=annotationProcessor,testAnnotationProcessor
179181
com.google.guava:guava:33.3.1-jre=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
180182
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
181183
com.google.gwt:gwt-user:2.10.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
182-
com.google.http-client:google-http-client-apache-v2:1.45.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
184+
com.google.http-client:google-http-client-apache-v2:1.45.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
183185
com.google.http-client:google-http-client-appengine:1.43.3=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath
184186
com.google.http-client:google-http-client-appengine:1.45.0=testCompileClasspath,testRuntimeClasspath
185-
com.google.http-client:google-http-client-gson:1.45.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
187+
com.google.http-client:google-http-client-gson:1.45.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
186188
com.google.http-client:google-http-client-jackson2:1.43.3=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath
187189
com.google.http-client:google-http-client-jackson2:1.45.0=testCompileClasspath,testRuntimeClasspath
188190
com.google.http-client:google-http-client-protobuf:1.44.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
189-
com.google.http-client:google-http-client:1.45.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
191+
com.google.http-client:google-http-client:1.45.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
190192
com.google.inject:guice:5.1.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
191193
com.google.inject:guice:7.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,soy,testCompileClasspath,testRuntimeClasspath
192194
com.google.j2objc:j2objc-annotations:1.3=checkstyle
@@ -262,10 +264,11 @@ io.github.eisop:dataflow-errorprone:3.34.0-eisop1=annotationProcessor,errorprone
262264
io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
263265
io.github.java-diff-utils:java-diff-utils:4.15=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
264266
io.grpc:grpc-alts:1.68.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
265-
io.grpc:grpc-api:1.68.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
267+
io.grpc:grpc-api:1.68.1=compileClasspath,nonprodCompileClasspath,testCompileClasspath
268+
io.grpc:grpc-api:1.68.2=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
266269
io.grpc:grpc-auth:1.68.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
267270
io.grpc:grpc-census:1.66.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
268-
io.grpc:grpc-context:1.68.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
271+
io.grpc:grpc-context:1.68.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
269272
io.grpc:grpc-core:1.68.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
270273
io.grpc:grpc-googleapis:1.68.1=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
271274
io.grpc:grpc-grpclb:1.68.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
@@ -484,7 +487,7 @@ org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.0.1=deploy_jar,nonprodRun
484487
org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.1=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
485488
org.jetbrains:annotations:13.0=annotationProcessor,testAnnotationProcessor
486489
org.jetbrains:annotations:17.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
487-
org.jline:jline:3.27.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
490+
org.jline:jline:3.28.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
488491
org.joda:joda-money:2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
489492
org.json:json:20230618=soy
490493
org.json:json:20240303=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath

core/src/main/java/google/registry/config/RegistryConfig.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import java.lang.annotation.Retention;
4747
import java.net.URI;
4848
import java.net.URL;
49-
import java.util.Map;
5049
import java.util.Map.Entry;
5150
import java.util.Optional;
5251
import java.util.function.Supplier;
@@ -118,12 +117,6 @@ public static long provideProjectIdNumber(RegistryConfigSettings config) {
118117
return config.gcpProject.projectIdNumber;
119118
}
120119

121-
@Provides
122-
@Config("backendServiceIds")
123-
public static Map<String, Long> provideBackendServiceIds(RegistryConfigSettings config) {
124-
return config.gcpProject.backendServiceIds;
125-
}
126-
127120
@Provides
128121
@Config("baseDomain")
129122
public static String provideBaseDomain(RegistryConfigSettings config) {

core/src/main/java/google/registry/config/RegistryConfigSettings.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public static class GcpProject {
5656
public String bsaServiceUrl;
5757
public String toolsServiceUrl;
5858
public String pubapiServiceUrl;
59-
public Map<String, Long> backendServiceIds;
6059
public String baseDomain;
6160
}
6261

core/src/main/java/google/registry/config/files/default-config.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@ gcpProject:
2424
toolsServiceUrl: https://tools.example.com
2525
pubapiServiceUrl: https://pubapi.example.com
2626

27-
# The backend service IDs created when setting up GKE routes. They will be included in the
28-
# audience field in the JWT that IAP creates.
29-
# See: https://cloud.google.com/iap/docs/signed-headers-howto#verifying_the_jwt_payload
30-
backendServiceIds:
31-
frontend: 12345
32-
backend: 12345
33-
pubapi: 12345
34-
console: 12345
35-
3627
# The base domain name of the registry service. Services are reachable at [service].baseDomain.
3728
baseDomain: registry.test
3829

core/src/main/java/google/registry/request/auth/AuthModule.java

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,31 @@
1414

1515
package google.registry.request.auth;
1616

17+
import static com.google.common.base.Preconditions.checkNotNull;
1718
import static com.google.common.net.HttpHeaders.AUTHORIZATION;
19+
import static google.registry.util.RegistryEnvironment.UNITTEST;
1820

21+
import com.google.cloud.compute.v1.BackendService;
22+
import com.google.cloud.compute.v1.BackendServicesClient;
23+
import com.google.cloud.compute.v1.BackendServicesSettings;
1924
import com.google.common.collect.ImmutableList;
25+
import com.google.common.collect.ImmutableMap;
26+
import com.google.re2j.Matcher;
27+
import com.google.re2j.Pattern;
28+
import dagger.Lazy;
2029
import dagger.Module;
2130
import dagger.Provides;
31+
import google.registry.config.CredentialModule.ApplicationDefaultCredential;
2232
import google.registry.config.RegistryConfig.Config;
2333
import google.registry.request.auth.OidcTokenAuthenticationMechanism.IapOidcAuthenticationMechanism;
2434
import google.registry.request.auth.OidcTokenAuthenticationMechanism.RegularOidcAuthenticationMechanism;
2535
import google.registry.request.auth.OidcTokenAuthenticationMechanism.TokenExtractor;
2636
import google.registry.request.auth.OidcTokenAuthenticationMechanism.TokenVerifier;
37+
import google.registry.util.GoogleCredentialsBundle;
2738
import google.registry.util.RegistryEnvironment;
28-
import java.util.Map;
39+
import java.io.IOException;
2940
import javax.annotation.Nullable;
41+
import javax.inject.Named;
3042
import javax.inject.Qualifier;
3143
import javax.inject.Singleton;
3244

@@ -44,6 +56,13 @@ public class AuthModule {
4456
private static final String IAP_GKE_AUDIENCE_FORMAT = "/projects/%d/global/backendServices/%d";
4557
private static final String IAP_ISSUER_URL = "https://cloud.google.com/iap";
4658
private static final String REGULAR_ISSUER_URL = "https://accounts.google.com";
59+
// The backend service IDs created when setting up GKE routes. They will be included in the
60+
// audience field in the JWT that IAP creates.
61+
// See: https://cloud.google.com/iap/docs/signed-headers-howto#verifying_the_jwt_payload
62+
// The automatically generated backend service ID has the following format:
63+
// gkemcg1-default-console[-canary]-80-(some random string)
64+
private static final Pattern BACKEND_END_PATTERN =
65+
Pattern.compile(".*-default-((frontend|backend|console|pubapi)(-canary)?)-80-.*");
4766

4867
/** Provides the custom authentication mechanisms. */
4968
@Provides
@@ -68,13 +87,18 @@ ImmutableList<AuthenticationMechanism> provideApiAuthenticationMechanisms(
6887
TokenVerifier provideIapTokenVerifier(
6988
@Config("projectId") String projectId,
7089
@Config("projectIdNumber") long projectIdNumber,
71-
@Config("backendServiceIds") Map<String, Long> backendServiceIds) {
90+
@Named("backendServiceIdMap") ImmutableMap<String, Long> backendServiceIdMap) {
7291
com.google.auth.oauth2.TokenVerifier.Builder tokenVerifierBuilder =
7392
com.google.auth.oauth2.TokenVerifier.newBuilder().setIssuer(IAP_ISSUER_URL);
7493
return (String service, String token) -> {
7594
String audience;
7695
if (RegistryEnvironment.isOnJetty()) {
77-
long backendServiceId = backendServiceIds.get(service);
96+
Long backendServiceId = backendServiceIdMap.get(service);
97+
checkNotNull(
98+
backendServiceId,
99+
"Backend service ID not found for service: %s, available IDs are %s",
100+
service,
101+
backendServiceIdMap);
78102
audience = String.format(IAP_GKE_AUDIENCE_FORMAT, projectIdNumber, backendServiceId);
79103
} else {
80104
audience = String.format(IAP_GAE_AUDIENCE_FORMAT, projectIdNumber, projectId);
@@ -116,4 +140,38 @@ TokenExtractor provideRegularTokenExtractor() {
116140
return null;
117141
};
118142
}
143+
144+
@Provides
145+
@Singleton
146+
static BackendServicesClient provideBackendServicesClients(
147+
@ApplicationDefaultCredential GoogleCredentialsBundle credentialsBundle) {
148+
try {
149+
return BackendServicesClient.create(
150+
BackendServicesSettings.newBuilder()
151+
.setCredentialsProvider(credentialsBundle::getGoogleCredentials)
152+
.build());
153+
} catch (IOException e) {
154+
throw new RuntimeException(e);
155+
}
156+
}
157+
158+
@Provides
159+
@Singleton
160+
@Named("backendServiceIdMap")
161+
static ImmutableMap<String, Long> provideBackendServiceList(
162+
Lazy<BackendServicesClient> client, @Config("projectId") String projectId) {
163+
if (RegistryEnvironment.isInTestServer() || RegistryEnvironment.get() == UNITTEST) {
164+
return ImmutableMap.of();
165+
}
166+
ImmutableMap.Builder<String, Long> builder = ImmutableMap.builder();
167+
for (BackendService service : client.get().list(projectId).iterateAll()) {
168+
String name = service.getName();
169+
Matcher matcher = BACKEND_END_PATTERN.matcher(name);
170+
if (!matcher.matches()) {
171+
continue;
172+
}
173+
builder.put(matcher.group(1), service.getId());
174+
}
175+
return builder.build();
176+
}
119177
}

core/src/main/java/google/registry/request/auth/OidcTokenAuthenticationMechanism.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ public AuthResult authenticate(HttpServletRequest request) {
8787
if (RegistryEnvironment.isOnJetty()) {
8888
String hostname = request.getServerName();
8989
service = Splitter.on('.').split(hostname).iterator().next();
90+
if (request.getHeader("canary") != null) {
91+
service += "-canary";
92+
}
9093
}
9194
token = tokenVerifier.verify(service, rawIdToken);
9295
} catch (Exception e) {

0 commit comments

Comments
 (0)