Skip to content

Commit d5fd5ba

Browse files
committed
Use testing credentials secret for JWT key
1 parent d68d9ee commit d5fd5ba

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

generate_jwt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const getSecretValue = async (secretId) => {
2020
}
2121
};
2222

23-
const secrets = await getSecretValue("infra-core-api-config");
23+
const secrets = await getSecretValue("infra-core-api-testing-credentials");
2424
const client = new STSClient({ region: "us-east-1" });
2525
const command = new GetCallerIdentityCommand({});
2626
let data;

src/api/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
environmentConfig,
1616
genericConfig,
1717
SecretConfig,
18+
SecretTesting,
1819
} from "../common/config.js";
1920
import organizationsPlugin from "./routes/organizations.js";
2021
import authorizeFromSchemaPlugin from "./plugins/authorizeFromSchema.js";
@@ -252,13 +253,20 @@ async function init(prettyPrint: boolean = false) {
252253
app.dynamoClient = dynamoClient;
253254
app.secretsManagerClient = secretsManagerClient;
254255
app.redisClient = redisClient;
255-
app.secretConfig = secret;
256256
app.refreshSecretConfig = async () => {
257257
app.secretConfig = (await getSecretValue(
258258
app.secretsManagerClient,
259259
genericConfig.ConfigSecretName,
260260
)) as SecretConfig;
261+
if (app.environmentConfig.TestingCredentialsSecret) {
262+
const temp = (await getSecretValue(
263+
app.secretsManagerClient,
264+
app.environmentConfig.TestingCredentialsSecret,
265+
)) as SecretTesting;
266+
app.secretConfig = { ...app.secretConfig, ...temp };
267+
}
261268
};
269+
app.refreshSecretConfig();
262270
app.addHook("onRequest", (req, _, done) => {
263271
req.startTime = now();
264272
const hostname = req.hostname;

src/common/config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type ConfigType = {
2323
PaidMemberPriceId: string;
2424
AadValidReadOnlyClientId: string;
2525
LinkryCloudfrontKvArn?: string;
26+
TestingCredentialsSecret?: string;
2627
};
2728

2829
export type GenericConfigType = {
@@ -98,6 +99,7 @@ const environmentConfig: EnvironmentConfigType = {
9899
/^https:\/\/(?:.*\.)?acmuiuc\.pages\.dev$/,
99100
/http:\/\/localhost:\d+$/,
100101
],
102+
TestingCredentialsSecret: "infra-core-api-testing-credentials",
101103
AadValidClientId: "39c28870-94e4-47ee-b4fb-affe0bf96c9f",
102104
LinkryBaseUrl: "https://core.aws.qa.acmuiuc.org",
103105
PasskitIdentifier: "pass.org.acmuiuc.qa.membership",
@@ -137,7 +139,6 @@ const environmentConfig: EnvironmentConfigType = {
137139
};
138140

139141
export type SecretConfig = {
140-
jwt_key?: string;
141142
discord_guild_id: string;
142143
discord_bot_token: string;
143144
entra_id_private_key?: string;
@@ -151,6 +152,10 @@ export type SecretConfig = {
151152
redis_url: string;
152153
};
153154

155+
export type SecretTesting = {
156+
jwt_key: string;
157+
}
158+
154159
const roleArns = {
155160
Entra: process.env.EntraRoleArn,
156161
};

tests/e2e/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function getSecrets() {
3030
let response = { PLAYWRIGHT_USERNAME: "", PLAYWRIGHT_PASSWORD: "" };
3131
let keyData;
3232
if (!process.env.PLAYWRIGHT_USERNAME || !process.env.PLAYWRIGHT_PASSWORD) {
33-
keyData = await getSecretValue("infra-core-api-config");
33+
keyData = await getSecretValue("infra-core-api-testing-credentials");
3434
}
3535
response["PLAYWRIGHT_USERNAME"] =
3636
process.env.PLAYWRIGHT_USERNAME ||

tests/live/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function getSecrets() {
3030
const response = { JWTKEY: "" };
3131
let keyData;
3232
if (!process.env.JWT_KEY) {
33-
keyData = await getSecretValue("infra-core-api-config");
33+
keyData = await getSecretValue("infra-core-api-testing-credentials");
3434
}
3535
response["JWTKEY"] =
3636
process.env.JWT_KEY || ((keyData ? keyData["jwt_key"] : "") as string);

0 commit comments

Comments
 (0)