Skip to content

Commit 6aa5027

Browse files
committed
task(auth,graphql): Configure separate redis instance for rate limiting
Because: - We wanted to have a clean slate for rate limiting db state This Commit: - Adds config for a 'ratelimit' redis instance
1 parent 8962ca2 commit 6aa5027

4 files changed

Lines changed: 42 additions & 10 deletions

File tree

libs/accounts/rate-limit/src/lib/rate-limit.provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const RateLimitRedisProvider: Provider = {
1919
throw new Error('Missing config for redis');
2020
}
2121

22-
const redisRateLimitConfig = config.get<RedisOptions>('redis.customs');
22+
const redisRateLimitConfig = config.get<RedisOptions>('redis.ratelimit');
2323
if (redisRateLimitConfig == null) {
2424
throw new Error('Missing config for redis.customs');
2525
}

packages/fxa-auth-server/bin/key_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ async function run(config) {
225225
const rules = parseConfigRules(config.rateLimit.rules);
226226
const rateLimitRedis = new Redis({
227227
...config.redis,
228-
...config.redis.customs,
228+
...config.redis.ratelimit,
229229
});
230230
const rateLimit = new RateLimit(
231231
{

packages/fxa-graphql-api/src/config.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,33 +199,33 @@ const conf = convict({
199199
doc: 'Key prefix for access tokens in Redis',
200200
},
201201
},
202-
customs: {
202+
ratelimit: {
203203
enabled: {
204-
default: false,
204+
default: true,
205205
doc: 'Enable Redis for customs server rate limiting',
206206
format: Boolean,
207-
env: 'CUSTOMS_REDIS_ENABLED',
207+
env: 'RATELIMIT_REDIS_ENABLED',
208208
},
209209
host: {
210210
default: 'localhost',
211-
env: 'CUSTOMS_REDIS_HOST',
211+
env: 'RATELIMIT_REDIS_HOST',
212212
format: String,
213213
},
214214
port: {
215215
default: 6379,
216-
env: 'CUSTOMS_REDIS_PORT',
216+
env: 'RATELIMIT_REDIS_PORT',
217217
format: 'port',
218218
},
219219
password: {
220220
default: '',
221-
env: 'CUSTOMS_REDIS_PASSWORD',
221+
env: 'RATELIMIT_REDIS_PASSWORD',
222222
format: String,
223223
sensitive: true,
224224
doc: `Password for connecting to redis`,
225225
},
226226
prefix: {
227-
default: 'customs:',
228-
env: 'CUSTOMS_REDIS_KEY_PREFIX',
227+
default: 'ratelimit:',
228+
env: 'RATELIMIT_REDIS_KEY_PREFIX',
229229
format: String,
230230
doc: 'Key prefix for custom server records in Redis',
231231
},

packages/fxa-shared/db/config.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,38 @@ export function makeRedisConfig() {
308308
},
309309
},
310310

311+
ratelimit: {
312+
enabled: {
313+
default: true,
314+
doc: 'Enable Redis for customs server rate limiting',
315+
format: Boolean,
316+
env: 'RATELIMIT_REDIS_ENABLED',
317+
},
318+
host: {
319+
default: 'localhost',
320+
env: 'RATELIMIT_REDIS_HOST',
321+
format: String,
322+
},
323+
port: {
324+
default: 6379,
325+
env: 'RATELIMIT_REDIS_PORT',
326+
format: 'port',
327+
},
328+
password: {
329+
default: '',
330+
env: 'RATELIMIT_REDIS_PASSWORD',
331+
format: String,
332+
sensitive: true,
333+
doc: `Password for connecting to redis`,
334+
},
335+
prefix: {
336+
default: 'ratelimit:',
337+
env: 'RATELIMIT_REDIS_KEY_PREFIX',
338+
format: String,
339+
doc: 'Key prefix for custom server records in Redis',
340+
},
341+
},
342+
311343
metrics: {
312344
enabled: {
313345
default: true,

0 commit comments

Comments
 (0)