Skip to content

Commit

Permalink
refactor: remove fake google credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
kormide committed Jan 10, 2025
1 parent d4eb8b0 commit 1ee4cc9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ jobs:

e2e:
runs-on: ubuntu-latest
# Don't run e2es on PRs from forks as it requires access to secrets
# when using `pull_request`.
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == 'bazel-contrib/publish-to-bcr' }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
Expand All @@ -42,14 +38,5 @@ jobs:
with:
node-version: 20
cache: pnpm
# Setup gcloud application default credentials. While the credentials are not actually
# used because Google api services are stubbed, instantiating any of the Google node
# clients requires the credentials file to exist and be valid.
- uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
- uses: google-github-actions/setup-gcloud@v2
with:
version: ">= 363.0.0"
- run: pnpm install --frozen-lockfile
- run: pnpm run e2e
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"exponential-backoff": "3.1.1",
"extract-zip": "^2.0.1",
"gcp-metadata": "^6.0.0",
"google-auth-library": "^9.15.0",
"nodemailer": "^6.7.8",
"reflect-metadata": "^0.2.2",
"rxjs": "7.8.1",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/infrastructure/secrets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SecretManagerServiceClient } from "@google-cloud/secret-manager";
import { Injectable } from "@nestjs/common";
import gcpMetadata from "gcp-metadata";
import type { JSONClient } from "google-auth-library/build/src/auth/googleauth";

@Injectable()
export class SecretsClient {
Expand All @@ -15,6 +16,14 @@ export class SecretsClient {
fallback: "rest",
protocol: "http",
port: Number(process.env.SECRET_MANAGER_PORT),
// Create a fake auth client to bypass checking for default credentials
authClient: {
getRequestHeaders(
url?: string
): Promise<{ [index: string]: string }> {
return Promise.resolve({});
},
} as JSONClient,
});
} else {
this.googleSecretsClient = new SecretManagerServiceClient();
Expand Down

0 comments on commit 1ee4cc9

Please sign in to comment.