@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.
- package/build/models/auth.js +4 -0
- package/build/models/user.js +3 -0
- package/package.json +1 -1
package/build/models/auth.js
CHANGED
|
@@ -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
|
};
|
package/build/models/user.js
CHANGED
|
@@ -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
|
};
|