Enterprise Software Engineering with C# and .NET: Architecture, Design Patterns, and AI-Enabled Systems · HIT

Week 10   Part IV · Domain Logic and Security

Security, Validation, and Robust API Design

Instructor lesson plan: lecture (2 h) and practice (2 h).

Learning objectives

Tools this week

JWTauthorization policiesFluentValidationProblemDetails

🎓Lecture · 2 hours

0:00-0:2020 minThreats in ordinary APIsOver-posting, broken authorization, leaky errors, invalid state transitions.
0:20-0:4525 minAuthentication and JWTIdentity, tokens, validation, expiration, and where trust is established.
0:45-1:1025 minAuthorization policiesRoles, claims, requirements, handlers, and use-case-level checks.
1:10-1:2010 minBreak
1:20-1:4525 minValidation and error contractsInput validation, domain validation, problem details, and consistent failures.
1:45-2:0015 minSecurity review checklistWhat every team must show by final presentation.
Common misconception to confront.

Students often think: authentication means the endpoint is secure.
Set it straight: authentication says who the caller is. Authorization decides what that caller may do.

Check for understanding
Where should ownership checks happen?
At the use-case or authorization-policy boundary, close to the business operation being protected.
Why avoid raw exception responses?
They leak implementation details and produce unstable contracts for clients.
Key takeaways.

📚Reading & resources

💻Practice · 2 hours

0:00-0:2525 minAdd authenticationConfigure token validation for the project API.
0:25-0:5530 minProtect use casesAdd policies and executable authorization examples for at least two protected operations.
0:55-1:1015 minError shapeReturn consistent validation and domain error responses.
1:10-1:2010 minBreak
1:20-1:5030 minSecurity reviewTeams review each other's endpoints for missing authorization.
1:50-2:0010 minProject-integration briefDocument protected endpoints and validation strategy.

Project integration (this week)

PreviousWeek 9: DDDNextWeek 11: Azure Cloud Services