Commit c59e11a
authored
fix: secure admin pages with server-side authentication and role-based access (#845)
* fix: secure admin pages with server-side authentication and role-based access
BREAKING CHANGES:
- Admin pages now require server-side authentication
- Hardcoded admin email replaced with database role checks
- All admin access now requires ADMIN role from database
Security Improvements:
- Convert all admin pages from getStaticProps to getServerSideProps
- Add server-side authentication checks before rendering admin pages
- Block unauthorized access at server level (not client-side)
- Replace hardcoded 'jeromehardaway' email with role-based checks
Pages Updated:
- admin/users.tsx: Fetch real user data from database, added role badges
- admin/courses.tsx: Fetch real course data with enrollment counts
- admin/index.tsx: Display real dashboard statistics, remove dev-session
- admin/blog-images.tsx: Add server-side auth protection
- courses/index.tsx: Use role check for admin dashboard link
Database Integration:
- admin/users: Query users with enrollment counts
- admin/courses: Query courses with module/enrollment counts
- admin/index: Aggregate platform statistics from database
This fixes critical security vulnerability where admin pages were:
1. Publicly accessible as static pages
2. Using client-side auth checks (bypassable)
3. Displaying mock data instead of real database data
4. Hardcoding admin access to single GitHub user
* fix: add permissions to playwright workflow and use VWC_GITHUB_TOKEN
- Add explicit permissions block for workflow scoping
- Use VWC_GITHUB_TOKEN secret instead of default GITHUB_TOKEN
- Fixes build failure when fetching GitHub project data1 parent 189b0e6 commit c59e11a
File tree
6 files changed
+482
-423
lines changed- .github/workflows
- src/pages
- admin
- courses
6 files changed
+482
-423
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
9 | 14 | | |
10 | | - | |
| 15 | + | |
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | | - | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | | - | |
19 | | - | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 26 | + | |
40 | 27 | | |
41 | 28 | | |
42 | 29 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 30 | + | |
56 | 31 | | |
57 | 32 | | |
58 | 33 | | |
| |||
290 | 265 | | |
291 | 266 | | |
292 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
293 | 297 | | |
0 commit comments