Skip to content

Commit 337ed4e

Browse files
refactor: replace Secret Manager with env var for API key (#1)
Pass API key via environment variable instead of fetching from Secret Manager on each request. Cloud Run injects the secret at deploy time using --set-secrets, simplifying the code and removing GCP SDK deps.
1 parent 0e9acb9 commit 337ed4e

File tree

5 files changed

+47
-151
lines changed

5 files changed

+47
-151
lines changed

cloudbuild.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
substitutions:
2+
_REGION: us-east1
3+
_SERVICE_NAME: speed-proxy
4+
_ALLOWED_ORIGIN: https://speed.measurementlab.net
5+
_TOKEN_EXCHANGE_URL: https://auth.mlab-sandbox.measurementlab.net/v0/token/integration
6+
7+
steps:
8+
# 1. Build the container image
9+
- name: "gcr.io/cloud-builders/docker"
10+
id: Build
11+
args: ["build", "-t", "${_REGION}-docker.pkg.dev/${PROJECT_ID}/m-lab/${_SERVICE_NAME}:$BUILD_ID", "-t", "${_REGION}-docker.pkg.dev/${PROJECT_ID}/m-lab/${_SERVICE_NAME}:latest", "."]
12+
13+
# 2. Push to Artifact Registry
14+
- name: "gcr.io/cloud-builders/docker"
15+
id: Push
16+
args: ["push", "${_REGION}-docker.pkg.dev/${PROJECT_ID}/m-lab/${_SERVICE_NAME}:${BUILD_ID}"]
17+
waitFor: ["Build"]
18+
19+
# 3. Deploy to Cloud Run
20+
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
21+
id: Deploy
22+
entrypoint: gcloud
23+
args: [
24+
"run", "deploy", "${_SERVICE_NAME}",
25+
"--image", "${_REGION}-docker.pkg.dev/${PROJECT_ID}/m-lab/${_SERVICE_NAME}:$BUILD_ID",
26+
"--platform", "managed",
27+
"--region", "${_REGION}",
28+
"--allow-unauthenticated",
29+
"--set-secrets=API_KEY=speed-proxy-api-key:latest",
30+
"--set-env-vars=TOKEN_EXCHANGE_URL=${_TOKEN_EXCHANGE_URL},ALLOWED_ORIGIN=${_ALLOWED_ORIGIN}",
31+
"--memory=256Mi",
32+
"--cpu=1",
33+
"--project=${PROJECT_ID}"
34+
]
35+
waitFor: ["Push"]
36+
37+
images:
38+
- "${_REGION}-docker.pkg.dev/${PROJECT_ID}/m-lab/${_SERVICE_NAME}:$BUILD_ID"
39+
- "${_REGION}-docker.pkg.dev/${PROJECT_ID}/m-lab/${_SERVICE_NAME}:latest"

go.mod

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,9 @@ module github.com/m-lab/speed-proxy
22

33
go 1.25.5
44

5-
require (
6-
cloud.google.com/go/secretmanager v1.16.0
7-
github.com/m-lab/go v0.1.76
8-
)
5+
require github.com/m-lab/go v0.1.76
96

107
require (
11-
cloud.google.com/go/auth v0.16.4 // indirect
12-
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
13-
cloud.google.com/go/compute/metadata v0.8.0 // indirect
14-
cloud.google.com/go/iam v1.5.2 // indirect
158
github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1 // indirect
16-
github.com/felixge/httpsnoop v1.0.4 // indirect
17-
github.com/go-logr/logr v1.4.3 // indirect
18-
github.com/go-logr/stdr v1.2.2 // indirect
19-
github.com/google/s2a-go v0.1.9 // indirect
20-
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
21-
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
22-
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
23-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect
24-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
25-
go.opentelemetry.io/otel v1.36.0 // indirect
26-
go.opentelemetry.io/otel/metric v1.36.0 // indirect
27-
go.opentelemetry.io/otel/trace v1.36.0 // indirect
28-
golang.org/x/crypto v0.41.0 // indirect
29-
golang.org/x/net v0.43.0 // indirect
30-
golang.org/x/oauth2 v0.30.0 // indirect
31-
golang.org/x/sync v0.16.0 // indirect
32-
golang.org/x/sys v0.35.0 // indirect
33-
golang.org/x/text v0.28.0 // indirect
34-
golang.org/x/time v0.12.0 // indirect
35-
google.golang.org/api v0.247.0 // indirect
36-
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect
37-
google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c // indirect
38-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a // indirect
39-
google.golang.org/grpc v1.74.2 // indirect
40-
google.golang.org/protobuf v1.36.7 // indirect
9+
github.com/stretchr/testify v1.10.0 // indirect
4110
)

go.sum

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,14 @@
1-
cloud.google.com/go v0.120.0 h1:wc6bgG9DHyKqF5/vQvX1CiZrtHnxJjBlKUyF9nP6meA=
2-
cloud.google.com/go v0.120.0/go.mod h1:/beW32s8/pGRuj4IILWQNd4uuebeT4dkOhKmkfit64Q=
3-
cloud.google.com/go/auth v0.16.4 h1:fXOAIQmkApVvcIn7Pc2+5J8QTMVbUGLscnSVNl11su8=
4-
cloud.google.com/go/auth v0.16.4/go.mod h1:j10ncYwjX/g3cdX7GpEzsdM+d+ZNsXAbb6qXA7p1Y5M=
5-
cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIiLpZnkHRbnc=
6-
cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c=
7-
cloud.google.com/go/compute/metadata v0.8.0 h1:HxMRIbao8w17ZX6wBnjhcDkW6lTFpgcaobyVfZWqRLA=
8-
cloud.google.com/go/compute/metadata v0.8.0/go.mod h1:sYOGTp851OV9bOFJ9CH7elVvyzopvWQFNNghtDQ/Biw=
9-
cloud.google.com/go/iam v1.5.2 h1:qgFRAGEmd8z6dJ/qyEchAuL9jpswyODjA2lS+w234g8=
10-
cloud.google.com/go/iam v1.5.2/go.mod h1:SE1vg0N81zQqLzQEwxL2WI6yhetBdbNQuTvIKCSkUHE=
11-
cloud.google.com/go/secretmanager v1.16.0 h1:19QT7ZsLJ8FSP1k+4esQvuCD7npMJml6hYzilxVyT+k=
12-
cloud.google.com/go/secretmanager v1.16.0/go.mod h1://C/e4I8D26SDTz1f3TQcddhcmiC3rMEl0S1Cakvs3Q=
131
github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1 h1:TEBmxO80TM04L8IuMWk77SGL1HomBmKTdzdJLLWznxI=
142
github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1/go.mod h1:SLqhdZcd+dF3TEVL2RMoob5bBP5R1P1qkox+HtCBgGI=
153
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
164
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
17-
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
18-
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
19-
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
20-
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
21-
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
22-
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
23-
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
245
github.com/go-test/deep v1.0.6 h1:UHSEyLZUwX9Qoi99vVwvewiMC8mM2bf7XEM2nqvzEn8=
256
github.com/go-test/deep v1.0.6/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
26-
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
27-
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
28-
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
29-
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
30-
github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0=
31-
github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM=
32-
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
33-
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
34-
github.com/googleapis/enterprise-certificate-proxy v0.3.6 h1:GW/XbdyBFQ8Qe+YAmFU9uHLo7OnF5tL52HFAgMmyrf4=
35-
github.com/googleapis/enterprise-certificate-proxy v0.3.6/go.mod h1:MkHOF77EYAE7qfSuSS9PU6g4Nt4e11cnsDUowfwewLA=
36-
github.com/googleapis/gax-go/v2 v2.15.0 h1:SyjDc1mGgZU5LncH8gimWo9lW1DtIfPibOG81vgd/bo=
37-
github.com/googleapis/gax-go/v2 v2.15.0/go.mod h1:zVVkkxAQHa1RQpg9z2AUCMnKhi0Qld9rcmyfL1OZhoc=
387
github.com/m-lab/go v0.1.76 h1:zdxI5k0AIZaf99Cyh7zjNyNBBZxTlhIJvWg7AX710bU=
398
github.com/m-lab/go v0.1.76/go.mod h1:BirARfHWjjXHaCGNyWCm/CKW1OarjuEj8Yn6Z2rc0M4=
409
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4110
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4211
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
4312
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
44-
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
45-
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
46-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 h1:q4XOmH/0opmeuJtPsbFNivyl7bCt7yRBbeEm2sC/XtQ=
47-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0/go.mod h1:snMWehoOh2wsEwnvvwtDyFCxVeDAODenXHtn5vzrKjo=
48-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 h1:F7Jx+6hwnZ41NSFTO5q4LYDtJRXBf2PD0rNBkeB/lus=
49-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0/go.mod h1:UHB22Z8QsdRDrnAtX4PntOl36ajSxcdUMt1sF7Y6E7Q=
50-
go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg=
51-
go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E=
52-
go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE=
53-
go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs=
54-
go.opentelemetry.io/otel/sdk v1.36.0 h1:b6SYIuLRs88ztox4EyrvRti80uXIFy+Sqzoh9kFULbs=
55-
go.opentelemetry.io/otel/sdk v1.36.0/go.mod h1:+lC+mTgD+MUWfjJubi2vvXWcVxyr9rmlshZni72pXeY=
56-
go.opentelemetry.io/otel/sdk/metric v1.36.0 h1:r0ntwwGosWGaa0CrSt8cuNuTcccMXERFwHX4dThiPis=
57-
go.opentelemetry.io/otel/sdk/metric v1.36.0/go.mod h1:qTNOhFDfKRwX0yXOqJYegL5WRaW376QbB7P4Pb0qva4=
58-
go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w=
59-
go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA=
60-
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
61-
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
62-
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
63-
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
64-
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
65-
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
66-
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
67-
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
68-
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
69-
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
70-
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
71-
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
72-
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
73-
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
74-
google.golang.org/api v0.247.0 h1:tSd/e0QrUlLsrwMKmkbQhYVa109qIintOls2Wh6bngc=
75-
google.golang.org/api v0.247.0/go.mod h1:r1qZOPmxXffXg6xS5uhx16Fa/UFY8QU/K4bfKrnvovM=
76-
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 h1:rHWScKit0gvAPuOnu87KpaYtjK5zBMLcULh7gxkCXu4=
77-
google.golang.org/genproto v0.0.0-20250603155806-513f23925822/go.mod h1:HubltRL7rMh0LfnQPkMH4NPDFEWp0jw3vixw7jEM53s=
78-
google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c h1:AtEkQdl5b6zsybXcbz00j1LwNodDuH6hVifIaNqk7NQ=
79-
google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c/go.mod h1:ea2MjsO70ssTfCjiwHgI0ZFqcw45Ksuk2ckf9G468GA=
80-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a h1:tPE/Kp+x9dMSwUm/uM0JKK0IfdiJkwAbSMSeZBXXJXc=
81-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a/go.mod h1:gw1tLEfykwDz2ET4a12jcXt4couGAm7IwsVaTy0Sflo=
82-
google.golang.org/grpc v1.74.2 h1:WoosgB65DlWVC9FqI82dGsZhWFNBSLjQ84bjROOpMu4=
83-
google.golang.org/grpc v1.74.2/go.mod h1:CtQ+BGjaAIXHs/5YS3i473GqwBBa1zGQNevxdeBEXrM=
84-
google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A=
85-
google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
8613
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
8714
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

handler/handler.go

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@ import (
88
"io"
99
"log"
1010
"net/http"
11-
12-
secretmanager "cloud.google.com/go/secretmanager/apiv1"
13-
"cloud.google.com/go/secretmanager/apiv1/secretmanagerpb"
1411
)
1512

1613
// Config contains the configuration for the token handler.
1714
type Config struct {
18-
ProjectID string
19-
SecretName string
15+
APIKey string
2016
TokenExchangeURL string
2117
AllowedOrigin string
22-
SMClient *secretmanager.Client
2318
HTTPClient *http.Client
2419
}
2520

@@ -62,16 +57,8 @@ func (h *Handler) Token(w http.ResponseWriter, r *http.Request) {
6257

6358
ctx := r.Context()
6459

65-
// Get the API key from Secret Manager.
66-
apiKey, err := h.getAPIKey(ctx)
67-
if err != nil {
68-
log.Printf("Failed to get API key: %v", err)
69-
http.Error(w, "Internal server error", http.StatusInternalServerError)
70-
return
71-
}
72-
7360
// Exchange the API key for a JWT token.
74-
token, err := h.exchangeToken(ctx, apiKey)
61+
token, err := h.exchangeToken(ctx, h.config.APIKey)
7562
if err != nil {
7663
log.Printf("Failed to exchange token: %v", err)
7764
http.Error(w, "Internal server error", http.StatusInternalServerError)
@@ -91,20 +78,6 @@ func (h *Handler) setCORSHeaders(w http.ResponseWriter) {
9178
w.Header().Set("Access-Control-Max-Age", "86400")
9279
}
9380

94-
// getAPIKey retrieves the API key from Secret Manager.
95-
func (h *Handler) getAPIKey(ctx context.Context) (string, error) {
96-
name := fmt.Sprintf("projects/%s/secrets/%s/versions/latest", h.config.ProjectID, h.config.SecretName)
97-
98-
result, err := h.config.SMClient.AccessSecretVersion(ctx, &secretmanagerpb.AccessSecretVersionRequest{
99-
Name: name,
100-
})
101-
if err != nil {
102-
return "", fmt.Errorf("failed to access secret version: %w", err)
103-
}
104-
105-
return string(result.Payload.Data), nil
106-
}
107-
10881
// exchangeToken exchanges an API key for a JWT token.
10982
func (h *Handler) exchangeToken(ctx context.Context, apiKey string) (string, error) {
11083
reqBody, err := json.Marshal(tokenRequest{APIKey: apiKey})

main.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ import (
1010
"syscall"
1111
"time"
1212

13-
secretmanager "cloud.google.com/go/secretmanager/apiv1"
1413
"github.com/m-lab/go/flagx"
1514
"github.com/m-lab/go/rtx"
1615
"github.com/m-lab/speed-proxy/handler"
1716
)
1817

1918
var (
2019
listenAddr = flag.String("listen-addr", ":8080", "Address to listen on")
21-
projectID = flag.String("project-id", "", "GCP project ID for Secret Manager")
22-
secretName = flag.String("secret-name", "", "Name of the secret containing the API key")
20+
apiKey = flag.String("api-key", "", "API key for token exchange")
2321
tokenExchangeURL = flag.String("token-exchange-url", "https://auth.mlab-sandbox.measurementlab.net/v0/token/integration", "URL of the token exchange service")
2422
allowedOrigin = flag.String("allowed-origin", "https://speed.measurementlab.net", "Allowed CORS origin")
2523
)
@@ -28,28 +26,18 @@ func main() {
2826
flag.Parse()
2927
flagx.ArgsFromEnv(flag.CommandLine)
3028

31-
if *projectID == "" {
32-
log.Fatal("-project-id is required")
33-
}
34-
if *secretName == "" {
35-
log.Fatal("-secret-name is required")
29+
if *apiKey == "" {
30+
log.Fatal("-api-key is required")
3631
}
3732

3833
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
3934
defer stop()
4035

41-
// Initialize Secret Manager client.
42-
smClient, err := secretmanager.NewClient(ctx)
43-
rtx.Must(err, "Failed to create Secret Manager client")
44-
defer smClient.Close()
45-
4636
// Create the token handler.
4737
h := handler.New(handler.Config{
48-
ProjectID: *projectID,
49-
SecretName: *secretName,
38+
APIKey: *apiKey,
5039
TokenExchangeURL: *tokenExchangeURL,
5140
AllowedOrigin: *allowedOrigin,
52-
SMClient: smClient,
5341
HTTPClient: &http.Client{Timeout: 10 * time.Second},
5442
})
5543

0 commit comments

Comments
 (0)