Skip to content

Commit fb4dd46

Browse files
marypas74claude
andcommitted
feat: Security validation for auth DTOs + Reports page + AI Chat service
## Security Validations (OWASP A03/A07 Compliance) - RegisterDto: Email/name validation, password complexity (8-128 chars, mixed case, digit, special char) - LoginDto: Email/password length limits - ChangePasswordDto: Password complexity regex matching registration - ResetPasswordDto: Email/token/password validation ## Admin Console Enhancements - Reports.razor: Comprehensive reporting page with charts - IReportService + ReportService: Backend report generation ## AI Chat Integration - IAIChatService + AIChatService: Video-context aware AI chat - API endpoints for conversational AI with lesson context ## Documentation - CLAUDE.md: Updated security validation status (High Priority complete) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent dbbaacb commit fb4dd46

File tree

9 files changed

+1207
-88
lines changed

9 files changed

+1207
-88
lines changed

CLAUDE.md

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,23 @@ WHERE Category = 'Chat' AND EndpointKey = 'SendMessage';
464464
#### **Remaining Work**
465465

466466
**High Priority** (Security):
467-
- ❌ CreateUserDto / RegisterDto (user registration validation)
468-
- ❌ LoginDto (authentication validation)
469-
- ❌ ChangePasswordDto (password change validation)
470-
- ❌ ResetPasswordDto (password reset validation)
467+
- ✅ CreateUserDto / RegisterDto (user registration validation) - **IMPLEMENTED 2025-11-26**
468+
- Email: StringLength(256), EmailAddress validation
469+
- FirstName/LastName: Regex `[\p{L}\s\-'\.]+` (letters, spaces, hyphens, apostrophes, periods only)
470+
- Password: 8-128 chars, complexity regex (uppercase, lowercase, digit, special char)
471+
- AgreeToTerms: Required to be true
472+
- ✅ LoginDto (authentication validation) - **IMPLEMENTED 2025-11-26**
473+
- Email: StringLength(256), EmailAddress validation
474+
- Password: StringLength(128), DataType.Password
475+
- ✅ ChangePasswordDto (password change validation) - **IMPLEMENTED 2025-11-26**
476+
- CurrentPassword: StringLength(128), DataType.Password
477+
- NewPassword: 8-128 chars, complexity regex (matches RegisterDto)
478+
- ConfirmPassword: Compare("NewPassword")
479+
- ✅ ResetPasswordDto (password reset validation) - **IMPLEMENTED 2025-11-26**
480+
- Email: StringLength(256), EmailAddress validation
481+
- Token: StringLength(1024)
482+
- Password: 8-128 chars, complexity regex (matches RegisterDto)
483+
- ConfirmPassword: Compare("Password")
471484

472485
**Medium Priority** (Data Integrity):
473486
- ❌ UpdateCourseDto (verify existing validation)
@@ -1441,7 +1454,16 @@ Esempio modifica version:
14411454
| `api/admin/payments/{id}/refund` | POST || Process payment refund with validation (Admin only) |
14421455
| `api/admin/payments/stats` | GET || Get payment statistics with date range filtering (Admin only) |
14431456

1444-
**✅ ADMIN CONSOLE COMPLETATA (2025-11-24)**: 5 nuovi endpoint implementati per gestione Instructors e Payments.
1457+
##### Admin Reports (4 endpoint - 4 implementati) ✅
1458+
1459+
| Endpoint | Metodo | Stato | Note |
1460+
|----------|--------|-------|------|
1461+
| `api/admin/reports/generate` | POST || Generate report (revenue, users, courses, enrollments, engagement, instructors) |
1462+
| `api/admin/reports/export/csv` | POST || Export report as CSV |
1463+
| `api/admin/reports/export/pdf` | POST || Export report as PDF (returns CSV format for now) |
1464+
| `api/admin/reports/export/excel` | POST || Export report as Excel (returns CSV format for now) |
1465+
1466+
**✅ ADMIN CONSOLE COMPLETATA (2025-11-26)**: 9 nuovi endpoint implementati per gestione Instructors, Payments e Reports.
14451467

14461468
**✅ PHASE 3 COMPLETATA (2025-11-10)**: Tutti i 31 endpoint LMS critici sono stati implementati. La piattaforma è ora completamente funzionale come LMS enterprise con:
14471469
- Gestione completa dei corsi (Courses, Categories)
@@ -1450,10 +1472,11 @@ Esempio modifica version:
14501472
- Sistema di recensioni (Reviews)
14511473
- Gestione utenti (Users Admin)
14521474
- Dashboard amministrativa (Dashboard Stats)
1453-
- **Gestione istruttori (Admin Instructors)** ← NEW
1454-
- **Gestione pagamenti amministrativa (Admin Payments)** ← NEW
1475+
- **Gestione istruttori (Admin Instructors)**
1476+
- **Gestione pagamenti amministrativa (Admin Payments)**
1477+
- **Sistema report (Admin Reports)** ← NEW (2025-11-26)
14551478

1456-
**Unico endpoint mancante**: `api/auth/complete-registration` (1/51 endpoint totali).
1479+
**Unico endpoint mancante**: `api/auth/complete-registration` (1/55 endpoint totali).
14571480

14581481
### Sicurezza
14591482

@@ -2984,11 +3007,20 @@ Professional student learning interface matching LinkedIn Learning quality stand
29843007
- `GET /api/notes/shared?lessonId={id}` - Get community shared notes
29853008
- `POST /api/notes/{id}/toggle-bookmark` - Bookmark note
29863009
2987-
##### AI Chat Endpoints (4)
2988-
- `POST /api/ai-chat/message` - Send message with context
2989-
- `GET /api/ai-chat/history?sessionId={id}` - Get chat history
2990-
- `POST /api/ai-chat/sessions/{sessionId}/end` - End session
2991-
- `GET /api/ai-chat/sessions?lessonId={id}` - List sessions for lesson
3010+
##### AI Chat Endpoints (4) - ✅ IMPLEMENTED v2.1.0-dev (2025-11-26)
3011+
3012+
| Endpoint | Metodo | Stato | Note |
3013+
|----------|--------|-------|------|
3014+
| `api/ai-chat/message` | POST || Send message with context (Ollama integration) |
3015+
| `api/ai-chat/history` | GET || Get chat history with pagination |
3016+
| `api/ai-chat/sessions/{sessionId}/end` | POST || End chat session |
3017+
| `api/ai-chat/sessions` | GET || List sessions for lesson |
3018+
3019+
**Implementation Details**:
3020+
- **Service**: IAIChatService + AIChatService (context-aware responses)
3021+
- **Integration**: Ollama LLM (qwen2:0.5b) for AI responses
3022+
- **Context Enrichment**: Video transcript data injected into prompt when available
3023+
- **Persistence**: SQL Server (metadata) + MongoDB (conversation history)
29923024
29933025
##### Video Bookmarks Endpoints (4)
29943026
- `GET /api/bookmarks?lessonId={id}` - Get bookmarks

src/InsightLearn.Application/DTOs/AdminDtos.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,18 @@ public class AdminFilterDto
389389
public int PageSize { get; set; } = 50;
390390
}
391391

392+
// Report Generation Request DTO (v2.1.0-dev)
393+
public class GenerateReportRequest
394+
{
395+
[Required(ErrorMessage = "Report type is required")]
396+
public string Type { get; set; } = string.Empty;
392397

398+
[Required(ErrorMessage = "Start date is required")]
399+
public DateTime StartDate { get; set; }
393400

401+
[Required(ErrorMessage = "End date is required")]
402+
public DateTime EndDate { get; set; }
403+
}
394404

395405

396406

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
namespace InsightLearn.Application.Interfaces;
2+
3+
/// <summary>
4+
/// Service interface for generating platform reports.
5+
/// Part of Admin Console v2.1.0-dev.
6+
/// </summary>
7+
public interface IReportService
8+
{
9+
Task<ReportResult> GenerateRevenueReportAsync(DateTime startDate, DateTime endDate);
10+
Task<ReportResult> GenerateUserGrowthReportAsync(DateTime startDate, DateTime endDate);
11+
Task<ReportResult> GenerateCoursePerformanceReportAsync(DateTime startDate, DateTime endDate);
12+
Task<ReportResult> GenerateEnrollmentReportAsync(DateTime startDate, DateTime endDate);
13+
Task<ReportResult> GenerateEngagementReportAsync(DateTime startDate, DateTime endDate);
14+
Task<ReportResult> GenerateInstructorEarningsReportAsync(DateTime startDate, DateTime endDate);
15+
Task<byte[]> ExportToCsvAsync(ReportResult report);
16+
Task<byte[]> ExportToPdfAsync(ReportResult report);
17+
Task<byte[]> ExportToExcelAsync(ReportResult report);
18+
}
19+
20+
/// <summary>
21+
/// Report data result with metrics, columns, and rows.
22+
/// </summary>
23+
public class ReportResult
24+
{
25+
public Guid Id { get; set; } = Guid.NewGuid();
26+
public string Type { get; set; } = string.Empty;
27+
public string Title { get; set; } = string.Empty;
28+
public DateTime StartDate { get; set; }
29+
public DateTime EndDate { get; set; }
30+
public DateTime GeneratedAt { get; set; } = DateTime.UtcNow;
31+
public string Status { get; set; } = "Completed";
32+
public List<ReportMetric> KeyMetrics { get; set; } = new();
33+
public List<string> Columns { get; set; } = new();
34+
public List<List<string>> Rows { get; set; } = new();
35+
}
36+
37+
/// <summary>
38+
/// Key metric for report summary cards.
39+
/// </summary>
40+
public class ReportMetric
41+
{
42+
public string Label { get; set; } = string.Empty;
43+
public string Value { get; set; } = string.Empty;
44+
public string Icon { get; set; } = string.Empty;
45+
public string Color { get; set; } = string.Empty;
46+
public string? Change { get; set; }
47+
public bool IsPositive { get; set; }
48+
}

0 commit comments

Comments
 (0)