@riocrypto/common-server 1.0.2915 → 1.0.2916

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -208,6 +208,10 @@ const buildAuth = (mongoose) => {
208
208
  unique: true,
209
209
  partialFilterExpression: { phoneNumber: { $type: "string" } },
210
210
  });
211
+ // API key validation runs before every authenticated request. Without this
212
+ // an unrecognised key costs a full collection scan, which is also a denial
213
+ // of service vector on the unauthenticated edge.
214
+ AuthSchema.index({ "apiKeys.value": 1 });
211
215
  const Auth = mongoose.model("Auth", AuthSchema);
212
216
  return Auth;
213
217
  };
@@ -255,6 +255,9 @@ const buildUser = (mongoose) => {
255
255
  userSchema.index({ brokerId: 1 });
256
256
  // Serves the unfiltered admin listing, which sorts on createdAt alone.
257
257
  userSchema.index({ createdAt: -1, _id: -1 });
258
+ // Resolving the user from the auth record runs on every authenticated
259
+ // request, so this stays on the hot path for the whole API.
260
+ userSchema.index({ authIds: 1 });
258
261
  userSchema.statics.build = (attrs) => {
259
262
  return new User(attrs);
260
263
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2915",
3
+ "version": "1.0.2916",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",