@astratra/saas-kit 1.6.0 → 1.6.1
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/package.json +1 -1
- package/src/app.js +15 -1
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -198,7 +198,21 @@ function createSaasApp(options = {}) {
|
|
|
198
198
|
skip: (req) => isBearerAuthenticated(req) || (normalized.csrf && normalized.csrf.skip && normalized.csrf.skip(req))
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
-
|
|
201
|
+
/*
|
|
202
|
+
* Le limiteur de connexion ne compte que les routes où l'on devine un secret :
|
|
203
|
+
* la connexion et la réinitialisation du mot de passe. Monté sur tout /auth, il
|
|
204
|
+
* comptait aussi /auth/me et /auth/refresh, qu'une app appelle à chaque lancement :
|
|
205
|
+
* après une dizaine d'ouvertures, l'app restait bloquée (« Too many login attempts »).
|
|
206
|
+
*/
|
|
207
|
+
const LIMITED_AUTH_PATHS = new Set(['/login', '/forgot-password', '/reset-password']);
|
|
208
|
+
const userLoginSkip = normalized.loginRateLimit && normalized.loginRateLimit.skip;
|
|
209
|
+
const loginLimiter = createLoginLimiter({
|
|
210
|
+
...normalized.loginRateLimit,
|
|
211
|
+
skip: (req, res) => !(req.method === 'POST' && LIMITED_AUTH_PATHS.has(req.path))
|
|
212
|
+
|| Boolean(userLoginSkip && userLoginSkip(req, res))
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
app.use('/auth', loginLimiter, createAuthRoutes({
|
|
202
216
|
...normalized,
|
|
203
217
|
authMiddleware,
|
|
204
218
|
csrfMiddleware
|