auth: sessions, login/logout/me/change-password, CSRF, guards, audit

argon2id passwords with a min length and a common-password list (SecLists,
MIT). Login failures are limited per IP and per email; must_change_password
blocks everything outside /api/auth/*. The first admin is created from env
on startup. pnpm dev derives DATABASE_URL from .env.

Task: M1-T3
This commit is contained in:
iamdoubz committed 2026-10-17 15:08:44 -05:00
1 parent 15b8a20751
commit 13733ac262
20 files changed
+1937 -46

No files matched your search

+155
View File
@@ -41,9 +41,15 @@ importers:
apps/api:
dependencies:
'@fastify/cookie':
specifier: ^11.1.3
version: 11.1.3
'@fastify/static':
specifier: ^10.1.6
version: 10.1.6
'@node-rs/argon2':
specifier: ^2.2.2
version: 2.2.2
'@selfphoneng/shared':
specifier: workspace:*
version: link:../../packages/shared
@@ -685,6 +691,9 @@ packages:
'@fastify/ajv-compiler@4.0.7':
resolution: {integrity: sha512-VP0yIfwlc1ohj733keYDqyHm1VWeP9VQxYomunhr90jkC4aNNibbkrRiaNgPgqj1ORxUenILR4qzA/ppYBNAtQ==}
'@fastify/cookie@11.1.3':
resolution: {integrity: sha512-RBhlMNsmSG6C5KGiTkhSXBF75xIrUMSytDDBcpnVewhJ8XVYnJTu+SV6FYKXClIRsBuRjOfKbBSULvnPD3X/mg==}
'@fastify/deepmerge@3.2.2':
resolution: {integrity: sha512-155eqA/WMQdN6gUD4RrhS2K0Pcz2Ou9pQ86L0sipOpP9ONbTA6oYw/hW4VdBjR4egcDHqmWUK9x80oUX7S1mDQ==}
@@ -758,6 +767,92 @@ packages:
resolution: {integrity: sha512-9I2Zn6+NJLfaGoz9jN3lpwDgAYvfGeNYdbAIjJOqzs4Tpc+VU3Jqq4IofSUBKajiDS8k9fZIg18/z13mpk1bsA==}
engines: {node: '>=8'}
'@node-rs/argon2-android-arm-eabi@2.2.2':
resolution: {integrity: sha512-c11BOrPLBWNC1cDyzGB+Bil+flmxfZbB2hv8EhcobmAsFKMyqkHPNhUY4qhcjv1U+4+Vmw4G8H+l224iO2g/Dw==}
engines: {node: '>= 10'}
cpu: [arm]
os: [android]
'@node-rs/argon2-android-arm64@2.2.2':
resolution: {integrity: sha512-dpMYIoxhN/wY6hFH+3MM5kQErcH3luMekkszbkDF3NKqhB1kFRntkOLDpFY87oItBSHJrsoYkXC3vBRhjYoCjQ==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [android]
'@node-rs/argon2-darwin-arm64@2.2.2':
resolution: {integrity: sha512-vxVAXcIG0iiHizkCuImmzVhOFsRnU4Z79xiOxdISLyI+QhOAWbbTaVSXw0PNfThB3zAdkzzDJ/WWu52Hs/qHGg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [darwin]
'@node-rs/argon2-darwin-x64@2.2.2':
resolution: {integrity: sha512-r7GbSFpFZZ9EAV9cvIm9prUjOupK7QQXTyP+FJ6bWSMq0h+qRDBlUOXQXduDIIrLEGoBVelixKUtf4ksZ0ljoQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [darwin]
'@node-rs/argon2-freebsd-x64@2.2.2':
resolution: {integrity: sha512-AmWxDSmQgprilD6NX3jmxCgcDvWAW7kGJnnWQo+0qav6nfMXdPZYgSezK/skmw1GBWipr4yZMIUzpeNHnVpMxg==}
engines: {node: '>= 10'}
cpu: [x64]
os: [freebsd]
'@node-rs/argon2-linux-arm-gnueabihf@2.2.2':
resolution: {integrity: sha512-M1gnPBTr9GFeEUWkQ53qCJeTsX03C3kcUeHnDbN7dU2xkI58wMP4Z1sEBN7WmKJ/fTHYEgti4truz7r4A82DLg==}
engines: {node: '>= 10'}
cpu: [arm]
os: [linux]
'@node-rs/argon2-linux-arm64-gnu@2.2.2':
resolution: {integrity: sha512-4CYDlIdITlLSVcAXYUtEoGUahRaayPXM+4Rcfg3BZx9WGi6UB8HUycs6GNMTPYXV5kVXCpyE2u1HmYUpgmIzOQ==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@node-rs/argon2-linux-arm64-musl@2.2.2':
resolution: {integrity: sha512-FYlfj3XgQ1xrx6HzQbKbUcKiYMG/3iSi/X81KyhHaItTJ7vZlMwrbVLl9yqDmvotKUF6VjrhrlZ8KRbbzchseA==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [musl]
'@node-rs/argon2-linux-x64-gnu@2.2.2':
resolution: {integrity: sha512-ULXLs8UFYZANlwiROM7AeccxZndr2Xk3IstADq3jAUhnwV2W75mxMBTABUZ+7AdKRhPLOrxU77OgnMWlDkYJQg==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [glibc]
'@node-rs/argon2-linux-x64-musl@2.2.2':
resolution: {integrity: sha512-zgjIwc9TyGodn62vGc+36DGwFqVV5e7L8Ptd2FQWuBxe5aFrcFxvtDGn1/qfYwoHLv09utgtR+RBAPCXepWG3Q==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [musl]
'@node-rs/argon2-win32-arm64-msvc@2.2.2':
resolution: {integrity: sha512-3nLhvLie/ec5xfxUBXXqGMb7oGeqF+YXrcGckqaTaGkPtOBozho0Kh2IuP/zi9BcOriirTG2LW3gtIOfpuh+mQ==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [win32]
'@node-rs/argon2-win32-ia32-msvc@2.2.2':
resolution: {integrity: sha512-6RJKD6cFl7UeiYJLjRsXPywVXSFSaSDdr6xGpztNDV31QHCEecWnsnNmKxzi4gVpln2F9XeWEtIgM4Nqw1hLbA==}
engines: {node: '>= 10'}
cpu: [ia32]
os: [win32]
'@node-rs/argon2-win32-x64-msvc@2.2.2':
resolution: {integrity: sha512-dQOO9S4QKBaVul0Uyk/2quJc/OBeHNZRJP+GZZTy1A5kYIaAfIJGHUYLY6oFoAlcuLIkdFouLaHX3fCl8tZm/w==}
engines: {node: '>= 10'}
cpu: [x64]
os: [win32]
'@node-rs/argon2@2.2.2':
resolution: {integrity: sha512-NtdlPPWtR5U4BxX5EGJYza+UklNaoWORmkaKCMqf/nyKeXWKVwNt8KfQoRpNT7OB1DcEwmePafO4wZyW+sbfCQ==}
engines: {node: '>= 10'}
'@oxc-project/types@0.154.0':
resolution: {integrity: sha512-KYOUGQFlLWR+s4QMV2Q9ko38TZm7EdO87Qm7rvZLqk/webse/cDjtyxKhg/47l0byCbs/k46LT8qc4PKjAikzA==}
@@ -2696,6 +2791,11 @@ snapshots:
ajv-formats: 3.0.1(ajv@8.20.0)
fast-uri: 4.2.2
'@fastify/cookie@11.1.3':
dependencies:
cookie: 2.0.1
fastify-plugin: 6.0.1
'@fastify/deepmerge@3.2.2': {}
'@fastify/error@4.2.1': {}
@@ -2778,6 +2878,61 @@ snapshots:
'@lukeed/ms@2.0.2': {}
'@node-rs/argon2-android-arm-eabi@2.2.2':
optional: true
'@node-rs/argon2-android-arm64@2.2.2':
optional: true
'@node-rs/argon2-darwin-arm64@2.2.2':
optional: true
'@node-rs/argon2-darwin-x64@2.2.2':
optional: true
'@node-rs/argon2-freebsd-x64@2.2.2':
optional: true
'@node-rs/argon2-linux-arm-gnueabihf@2.2.2':
optional: true
'@node-rs/argon2-linux-arm64-gnu@2.2.2':
optional: true
'@node-rs/argon2-linux-arm64-musl@2.2.2':
optional: true
'@node-rs/argon2-linux-x64-gnu@2.2.2':
optional: true
'@node-rs/argon2-linux-x64-musl@2.2.2':
optional: true
'@node-rs/argon2-win32-arm64-msvc@2.2.2':
optional: true
'@node-rs/argon2-win32-ia32-msvc@2.2.2':
optional: true
'@node-rs/argon2-win32-x64-msvc@2.2.2':
optional: true
'@node-rs/argon2@2.2.2':
optionalDependencies:
'@node-rs/argon2-android-arm-eabi': 2.2.2
'@node-rs/argon2-android-arm64': 2.2.2
'@node-rs/argon2-darwin-arm64': 2.2.2
'@node-rs/argon2-darwin-x64': 2.2.2
'@node-rs/argon2-freebsd-x64': 2.2.2
'@node-rs/argon2-linux-arm-gnueabihf': 2.2.2
'@node-rs/argon2-linux-arm64-gnu': 2.2.2
'@node-rs/argon2-linux-arm64-musl': 2.2.2
'@node-rs/argon2-linux-x64-gnu': 2.2.2
'@node-rs/argon2-linux-x64-musl': 2.2.2
'@node-rs/argon2-win32-arm64-msvc': 2.2.2
'@node-rs/argon2-win32-ia32-msvc': 2.2.2
'@node-rs/argon2-win32-x64-msvc': 2.2.2
'@oxc-project/types@0.154.0': {}
'@pinojs/redact@0.4.0': {}