Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+17
-30
@@ -22,11 +22,11 @@ import { Params, redirect } from "react-router";
|
||||
import IpAddressServiceServer from "~/modules/ipAddress/services/IpAddressService.server";
|
||||
import { isCanonicalAdminHostRoute } from "~/utils/app/HostRouting.server";
|
||||
import { absoluteAdminPath, absoluteAppPath, absoluteAppRootPath } from "~/utils/app/CrossHostUrls";
|
||||
import { loadRequiredWebConfig } from "@toolctrl/config";
|
||||
import { loadRequiredWebConfig } from "@hivegrid/config";
|
||||
import { isRemovedRoutePath } from "~/utils/app/RedirectSafety.server";
|
||||
import { checkAuthRateLimit } from "~/services/auth/auth-rate-limit.server";
|
||||
import { clearFailedLogins, getFailedLoginCount, loginRequiresCaptcha, recordFailedLogin } from "~/services/auth/login-captcha-gate.server";
|
||||
import { getSitekey, isCaptchaConfigured, resolveCaptchaConfig, verifyCaptchaToken } from "@toolctrl/captcha";
|
||||
import { getSecret, getSitekey, isCaptchaConfigured, resolveCaptchaConfig, verifyCaptchaToken } from "@hivegrid/captcha";
|
||||
import { createScopedLogger } from "~/utils/logger.server";
|
||||
import { validatePassword as validatePolicyPassword } from "~/services/auth/password-policy.server";
|
||||
|
||||
@@ -209,15 +209,16 @@ async function loginFromRequest(request: Request, form: FormData) {
|
||||
return Response.json({ fields, error: t("api.errors.tooManyRequests") }, { status: 429, headers: { "Retry-After": String(rateLimit.retryAfterSeconds) } });
|
||||
}
|
||||
|
||||
// Brute-Force-Soft-Gate: ab dem 3. Fehlversuch (pro IP+Email) ein mCaptcha verlangen,
|
||||
// bevor der Passwort-Check laeuft. No-op, solange mCaptcha nicht konfiguriert ist.
|
||||
// Brute-force soft gate: after repeated failures per IP+email, require the
|
||||
// configured self-hosted captcha before checking the password.
|
||||
const captchaConfig = resolveCaptchaConfig(process.env);
|
||||
if (isCaptchaConfigured(captchaConfig) && loginRequiresCaptcha(getFailedLoginCount({ request, identifier: email }))) {
|
||||
const captchaOk = await verifyCaptchaToken({
|
||||
token: form.get("captchaToken")?.toString(),
|
||||
token: form.get("cap-token")?.toString() ?? form.get("mcaptcha__token")?.toString() ?? form.get("captchaToken")?.toString(),
|
||||
sitekey: getSitekey(captchaConfig, "login"),
|
||||
secret: captchaConfig.accountSecret,
|
||||
secret: getSecret(captchaConfig, "login"),
|
||||
instanceUrl: captchaConfig.instanceUrl,
|
||||
provider: captchaConfig.provider,
|
||||
failOpen: captchaConfig.failOpen,
|
||||
logger: authLogger,
|
||||
});
|
||||
@@ -241,31 +242,17 @@ async function loginFromRequest(request: Request, form: FormData) {
|
||||
}
|
||||
}
|
||||
// Phase 01 / #20 — Magic-link-only accounts have `passwordHash = null`
|
||||
// (invitation flow provisions them without a password). Reject the
|
||||
// password-login attempt *before* the verify step so we never grant a
|
||||
// session on the dummy-hash fallthrough, and surface a friendly
|
||||
// message pointing the user at the magic-link entrypoint. We still
|
||||
// return 400 so the response shape stays compatible with existing
|
||||
// clients and login-form error rendering.
|
||||
if (user && user.passwordHash === null) {
|
||||
return Response.json(
|
||||
{
|
||||
fields,
|
||||
error: t("auth:errors.passwordlessAccountUseMagicLink"),
|
||||
requiresMagicLink: true,
|
||||
magicLinkHref: "/forgot-password",
|
||||
},
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// (invitation flow provisions them without a password). We must never
|
||||
// grant a session on such a row, but we must also not reveal that the
|
||||
// account exists: an early distinct "use the magic link" response (plus
|
||||
// skipping verifyPassword) let an attacker enumerate invited accounts by
|
||||
// their content and timing. Instead we fall through to the SAME dummy-hash
|
||||
// comparison and the SAME generic invalid-credentials response as an
|
||||
// unknown email — verifyPassword against DUMMY_PASSWORD_HASH always returns
|
||||
// false for a null-hash row, so no session is ever issued. The magic-link
|
||||
// hint is surfaced generically on the /forgot-password flow, not here.
|
||||
const { valid: isCorrectPassword, rehashedHash } = await verifyPassword(password, user?.passwordHash ?? DUMMY_PASSWORD_HASH);
|
||||
if (!user) {
|
||||
recordFailedLogin({ request, identifier: email });
|
||||
return Response.json({ fields, error: t("api.errors.invalidPassword") }, { status: 400 });
|
||||
}
|
||||
|
||||
if (!isCorrectPassword) {
|
||||
if (!user || user.passwordHash === null || !isCorrectPassword) {
|
||||
recordFailedLogin({ request, identifier: email });
|
||||
return Response.json({ fields, error: t("api.errors.invalidPassword") }, { status: 400 });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user