You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: services/backend/DB.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -162,6 +162,8 @@ Tables defined by plugins are automatically created when the plugin is loaded an
162
162
- Include proper foreign key constraints for relational data
163
163
- Add explicit types for all columns
164
164
- Always use migrations forschema changesin development and production
165
+
- **Important**: When adding foreign key relationships, update the dialect-specific schema files (e.g., `src/db/schema.sqlite.ts`) rather than the central `schema.ts` file, as Drizzle Kit uses these files for migration generation
166
+
- Never manually create migration files - always use `npm run db:generate` to ensure proper migration structure
Copy file name to clipboardExpand all lines: services/backend/SECURITY.md
+20-3Lines changed: 20 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,19 +21,36 @@ This approach ensures that even if the database were compromised, recovering the
21
21
22
22
## Session Management
23
23
24
-
User sessions are managed using `lucia-auth`.
24
+
User sessions are managed using `lucia-auth` v3.
25
25
26
-
- Session identifiers are cryptographically random and stored in secure, HTTP-only cookies to prevent XSS attacks from accessing them.
27
-
- Sessions have defined expiration times (both active and idle timeouts) to limit the window of opportunity for session hijacking.
26
+
- Session identifiers are cryptographically random (40 characters) generated using Lucia's `generateId()` function and stored in secure, HTTP-only cookies to prevent XSS attacks from accessing them.
27
+
- Sessions have defined expiration times (30 days from creation) to limit the window of opportunity for session hijacking.
28
+
- Session data is stored in the `authSession` table with proper foreign key constraints to the `authUser` table.
29
+
- Session cookies are configured with appropriate security attributes:
30
+
-`httpOnly`: true (prevents JavaScript access)
31
+
-`secure`: true in production (HTTPS only)
32
+
-`sameSite`: 'lax' (CSRF protection)
28
33
29
34
## Data Validation
30
35
31
36
All incoming data from clients (e.g., API request bodies, URL parameters) is rigorously validated using `zod` schemas on the server-side before being processed. This helps prevent common vulnerabilities such as injection attacks and unexpected data handling errors.
- Email addresses are normalized to lowercase before storage
40
+
- Duplicate username and email checks are performed before user creation
41
+
- All database operations use parameterized queries via Drizzle ORM to prevent SQL injection
42
+
33
43
## Dependencies
34
44
35
45
We strive to keep our dependencies up-to-date and regularly review them for known vulnerabilities. Automated tools may be used to scan for vulnerabilities in our dependency tree.
36
46
47
+
### Key Security Dependencies:
48
+
-`@node-rs/argon2`: Password hashing
49
+
-`lucia`: Session management
50
+
-`drizzle-orm`: Database ORM with parameterized queries
51
+
-`zod`: Input validation and sanitization
52
+
-`@fastify/cookie`: Secure cookie handling
53
+
37
54
## Infrastructure Security
38
55
39
56
[Placeholder: Add details about infrastructure security, e.g., network configuration, firewalls, access controls, HTTPS enforcement, etc., as applicable to your deployment environment.]
0 commit comments