Skip to content

Commit

Permalink
feat(ppa): add origin trial token (#11309)
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo authored Jun 13, 2024
1 parent 9822241 commit 8128007
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ jobs:
--set-env-vars="ORIGIN_PLAY=mdnplay.dev" \
--set-env-vars="SOURCE_CONTENT=https://storage.googleapis.com/${{ vars.GCP_BUCKET_NAME }}/main/" \
--set-env-vars="SOURCE_API=https://api.developer.mozilla.org/" \
--set-env-vars="ORIGIN_TRIAL_TOKEN=A9YWJd0eN0+JyqsF5/4sYlFePcOgkAIKtGSnrERJ7zmzK65fqcrdYjmHUlxAV79Fphmwt96Gkyw2F1WmMEUEztgAAABdeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb24iLCJleHBpcnkiOjE3NDk3NDMyNjF9" \
--set-env-vars="BSA_ENABLED=true" \
--set-env-vars="SENTRY_DSN=${{ secrets.SENTRY_DSN_CLOUD_FUNCTION }}" \
--set-env-vars="SENTRY_ENVIRONMENT=prod" \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/stage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ jobs:
--set-env-vars="ORIGIN_PLAY=mdnyalp.dev" \
--set-env-vars="SOURCE_CONTENT=https://storage.googleapis.com/${{ vars.GCP_BUCKET_NAME }}/main/" \
--set-env-vars="SOURCE_API=https://api.developer.allizom.org/" \
--set-env-vars="ORIGIN_TRIAL_TOKEN=A708kbzhofFLGMe7BHKr3aym5saxaywBDqhAzxv4vU9sM6B49iYwec+xy2Y3Imt0+nhR03/jmbuNY0BRvM+Ng5cAAABdeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5hbGxpem9tLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb24iLCJleHBpcnkiOjE3NDk3NDMzMDB9" \
--set-env-vars="BSA_ENABLED=true" \
--set-env-vars="SENTRY_DSN=${{ secrets.SENTRY_DSN_CLOUD_FUNCTION }}" \
--set-env-vars="SENTRY_ENVIRONMENT=stage" \
Expand Down
4 changes: 4 additions & 0 deletions cloud-function/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export function sourceUri(source: Source): string {
}
}

// Origin trial.
export const ORIGIN_TRIAL_TOKEN: string | undefined =
process.env["ORIGIN_TRIAL_TOKEN"];

// Kevel.
export const KEVEL_SITE_ID = Number(process.env["KEVEL_SITE_ID"] ?? 0);
export const KEVEL_NETWORK_ID = Number(process.env["KEVEL_NETWORK_ID"] ?? 0);
Expand Down
2 changes: 2 additions & 0 deletions cloud-function/src/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
PLAYGROUND_UNSAFE_CSP_VALUE,
} from "./internal/constants/index.js";
import { isLiveSampleURL } from "./utils.js";
import { ORIGIN_TRIAL_TOKEN } from "./env.js";

const HASHED_MAX_AGE = 60 * 60 * 24 * 365;
const DEFAULT_MAX_AGE = 60 * 60;
Expand Down Expand Up @@ -94,6 +95,7 @@ export function setContentResponseHeaders(
["Strict-Transport-Security", "max-age=63072000"],
...(csp ? [["Content-Security-Policy", CSP_VALUE]] : []),
...(xFrame ? [["X-Frame-Options", "DENY"]] : []),
...(ORIGIN_TRIAL_TOKEN ? [["Origin-Trial", ORIGIN_TRIAL_TOKEN]] : []),
].forEach(([k, v]) => k && v && setHeader(k, v));
}

Expand Down

0 comments on commit 8128007

Please sign in to comment.