Skip to content

Commit 7cbaa95

Browse files
authored
chore: add section manager lambda key id to config (#367)
* chore: add section manager lambda keys to config - remove terraform cloud for incident management - clean up a buggy spec test
1 parent 0a82c25 commit 7cbaa95

File tree

5 files changed

+43
-31
lines changed

5 files changed

+43
-31
lines changed

.aws/src/main.ts

+3-23
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import { Construct } from 'constructs';
2-
import {
3-
App,
4-
DataTerraformRemoteState,
5-
S3Backend,
6-
TerraformStack,
7-
} from 'cdktf';
2+
import { App, S3Backend, TerraformStack } from 'cdktf';
83
import { AwsProvider, datasources, kms, sns } from '@cdktf/provider-aws';
94
import { config } from './config';
105
import {
@@ -91,27 +86,12 @@ class AdminAPI extends TerraformStack {
9186
return null;
9287
}
9388

94-
const incidentManagement = new DataTerraformRemoteState(
95-
this,
96-
'incident_management',
97-
{
98-
organization: 'Pocket',
99-
workspaces: {
100-
name: 'incident-management',
101-
},
102-
},
103-
);
104-
10589
return new PocketPagerDuty(this, 'pagerduty', {
10690
prefix: config.prefix,
10791
service: {
10892
// This is a Tier 2 service and as such only raises non-critical alarms.
109-
criticalEscalationPolicyId: incidentManagement
110-
.get('policy_default_non_critical_id')
111-
.toString(),
112-
nonCriticalEscalationPolicyId: incidentManagement
113-
.get('policy_default_non_critical_id')
114-
.toString(),
93+
criticalEscalationPolicyId: 'PXOQVEP',
94+
nonCriticalEscalationPolicyId: 'PXOQVEP',
11595
},
11696
});
11797
}

src/config.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,40 @@ const config = {
2626
//Mozilla Auth Proxy supports a larger number of user groups for a user.
2727
cognito: {
2828
jwtIssuer:
29+
// COGNITO_JWT_ISSUER is not set in this repo (or anywhere?)
2930
process.env.COGNITO_JWT_ISSUER ||
3031
'cognito-idp.us-east-1.amazonaws.com/us-east-1_1alKls4qw',
32+
// COGNITO_KIDS is not set in this repo (or anywhere?)
3133
kids: process.env.COGNITO_KIDS?.split(',') || [
3234
'kze4M0CiXoDO7Qkpig1oH0F6OInzZg6ugk0PyojOlzc=',
3335
'4w35mrh4EBECpjJnyIjdQ60yjh3xeI1m0VF1H/z0T/c=',
3436
],
3537
},
3638
mozillaAuthProxy: {
3739
jwtIssuer:
40+
// MOZILLA_AUTH_PROXY_JWT_ISSUER is not set in this repo (or anywhere?)
3841
process.env.MOZILLA_AUTH_PROXY_JWT_ISSUER ||
3942
'cognito-idp.us-east-1.amazonaws.com/us-east-1_qYkccPmmu',
43+
// MOZILLA_AUTH_PROXY_KIDS is not set in this repo (or anywhere?)
4044
kids: process.env.MOZILLA_AUTH_PROXY_KIDS?.split(',') || [
4145
'OR8erz5A8/hCkVdHczk879k2zUQXoAke9p8TQXsgKLQ=',
4246
'QtBbT/twDz6JmT99PQkAOB+QBhG4eJvxk8pOr7YzfWU=',
4347
],
4448
},
4549
pocket: {
50+
// POCKET_JWT_ISSUER is not set in this repo (or anywhere?)
4651
jwtIssuer: process.env.POCKET_JWT_ISSUER || 'getpocket.com',
4752
kids:
53+
// POCKET_KIDS is not set in this repo (or anywhere?)
4854
process.env.POCKET_KIDS?.split(',') ||
55+
// if you add a new JWK to https://github.com/Pocket/dotcom-gateway/blob/main/static/.well-known/jwk
56+
// you must also specify it here for the environment you want
4957
process.env.NODE_ENV === 'production'
50-
? ['CURMIG', 'CORPSL']
51-
: ['CMGDEV', 'CORDEV'],
58+
? ['CURMIG', 'CORPSL', 'SEMGRL']
59+
: ['CMGDEV', 'CORDEV', 'SMGRDV'],
5260
},
5361
defaultKid:
62+
// DEFAULT_KID is not set in this repo (or anywhere?)
5463
process.env.DEFAULT_KID || 'OR8erz5A8/hCkVdHczk879k2zUQXoAke9p8TQXsgKLQ=',
5564
},
5665
};

src/jwtUtils.spec.ts

+18-2
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,22 @@ describe('jwtUtils', () => {
145145
alg: 'RS256',
146146
n: 'q8ft1Rs-kUFWlsiGZeZLgc85iNi3dKWQUhAurSfh00q7oltZFam4djkwLMfTJ2mTlobMMXYppilGN_liZkRZg8W3hFxYY_lwGseDvCtiUMXrPDauF4fjCxnc3RNFsaeqfouOsTktBVuwGC2j-aEPVbdyIqppZ3kwkiRRkYioJae4I1Djabzc8Q48VhVbuWDc1-QWpyGHel73mUFVbLPleLqu-4-LrDquaxRDrd65d3CP0LpYwQSzb6bsVvvCB0YSJKCi1top-ZkrVfw_O0toukAJIK-QN7vxcOga_CEraa-J-I9VdEtY0gjsO_70FZ9BNueBMpCJoGbrMQR923YxBQ',
147147
},
148+
{
149+
kty: 'RSA',
150+
e: 'AQAB',
151+
use: 'sig',
152+
kid: 'SEMGRL',
153+
alg: 'RS256',
154+
n: 'sjOK-Rmytt_g8F-9FImGHCKwkPBlgr_DpBTw3Y5esLYTJAqXsQwGtJf2OR4azGcbec5796fE9lhnLEmi6MFz0oBDxhPHwMCyf9DBZhsCVUmAIysosOqeDdxFB_9upCCcYvMpty8hrgoJp9U01ITnYVxRYCSwnJnjJFkxyA2ZXhlMjYwI0W5qo9tUXMwyEnt8408gK_etKrj6A24-oxMpau_gSxSgZDxAi2vpNEapX-hYV0grofnEy25dtHu_5xVVPlDpeQzGWdfRbFQKJKv8km3wvgvv0CsC-CukPZd40kHQiq71a47zNL4OyM-FcGt_KfuZDuFy79g5I8KEFsZOJw',
155+
},
156+
{
157+
kty: 'RSA',
158+
e: 'AQAB',
159+
use: 'sig',
160+
kid: 'SMGRDV',
161+
alg: 'RS256',
162+
n: 'ja9Fr70SvubM7UFsQKUAHWk86nLCgX3zpUnutqMcfrUfFkWRZ3PQiFuE0UL96ao3RPEuY0eXZaIy3ts0B3YgBo_XUEefbW4V_bRFgsZKJwRvQNUzvYincKxOPQPWqGZqXemqqQFkZguBKiYxBMmhgJytcuFGZ1VfpkttOVGvJS1_Qp2Dp-vimjYaLzTCYTmERsjVXDkWUisMeYY-Sifm4ZdXebVUOs3t4by3mKcdVdoELWjuU_OXlkwREEZACWiA4hVr4PsmaEHF5JDMUaNKb-0pJ0S3YyEUCRy7AYC4GMl24_aHJbKxZEKtsfqYVtWWKSuAg4S7HJmHnIGrliIV9w',
163+
},
148164
],
149165
};
150166

@@ -161,8 +177,8 @@ describe('jwtUtils', () => {
161177
'OR8erz5A8/hCkVdHczk879k2zUQXoAke9p8TQXsgKLQ=',
162178
'QtBbT/twDz6JmT99PQkAOB+QBhG4eJvxk8pOr7YzfWU=',
163179
...(env === 'development'
164-
? ['CMGDEV', 'CORDEV']
165-
: ['CURMIG', 'CORPSL']),
180+
? ['CMGDEV', 'CORDEV', 'SMGRDV']
181+
: ['CURMIG', 'CORPSL', 'SEMGRL']),
166182
];
167183

168184
const cognitoMock = nock('https://' + config.auth.cognito.jwtIssuer)

src/server/context.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ export async function getAppContext(
4949
let publicKeys: Record<string, string>;
5050

5151
async function getSigningKeys() {
52-
if (publicKeys) return publicKeys;
53-
publicKeys = await getSigningKeysFromServer();
52+
if (!publicKeys) {
53+
publicKeys = await getSigningKeysFromServer();
54+
}
55+
5456
return publicKeys;
5557
}
5658

src/server/main.spec.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ import * as jwtUtils from '../jwtUtils';
44

55
describe('Context factory function', () => {
66
it('multiple invocations only fetch public keys once', async () => {
7-
const keySpy = sinon.spy(jwtUtils, 'getSigningKeysFromServer');
7+
const keyStub = sinon.stub(jwtUtils, 'getSigningKeysFromServer').resolves({
8+
testKID: 'hereisalongkidstring',
9+
});
810
await contextFactory({ req: { headers: {} } });
911
await contextFactory({ req: { headers: {} } });
1012
await contextFactory({ req: { headers: {} } });
11-
expect(keySpy.callCount).toEqual(1);
13+
14+
expect(keyStub.callCount).toEqual(1);
15+
16+
keyStub.restore();
1217
});
1318
});

0 commit comments

Comments
 (0)