Web Security and Logins
Protect real users: hash passwords, build safe logins with 2FA, choose sessions or tokens, guard React pages and Django APIs, and stop injection, XSS and CSRF.
- 0 students
- 94 lessons
- 7 h 29 min
Created by Ayim Nelson
What you will learn
- Explain the OWASP Top 10 and think about a feature the way an attacker would
- Store passwords as slow, salted hashes and use Django's hashers, validators and a custom user model
- Defend logins with rate limiting, safe password resets and TOTP two-factor codes
- Choose between sessions, tokens and JWT, and decide where a React app keeps its credentials
- Build protected pages in React with an auth context, knowing the server is the real guard
- Stop broken access control, SQL injection, XSS, CSRF and clickjacking
- Set CORS and security headers (CSP, HSTS) correctly and pass python manage.py check --deploy
- Keep secrets out of code and dependencies up to date with pip-audit, npm audit and Dependabot
About this course
Your Django site and React app work. Now make them safe for real people's money and data. Through SikaPay, a small mobile money wallet built in Accra, you'll learn how attackers actually break in and how to stop them: storing passwords as slow salted hashes, a custom user model that logs in by email, rate-limited logins, password resets and two-factor codes, sessions versus tokens and JWT, where a React app should keep its login, protected pages, object-level permissions, SQL injection, XSS, CSRF, clickjacking, CORS, security headers, secrets and security updates.
For: developers who have finished The Ultimate Django Course, REST APIs with Django REST Framework and The Ultimate React Course (or know Django, DRF and React to that level). The Python exercises run in your browser and the React exercises in the Web runner; the Django output you see was produced by a real Django 6.1 project.
By the end: you'll have hashed and verified passwords with PBKDF2, written a TOTP code generator that passes the RFC 6238 test vectors, verified signed tokens, guarded a React dashboard with an auth context, written access checks and a login rate limiter, found SQL built from strings, audited cookies and security headers, and know how to run check --deploy, pip-audit and Dependabot on your own projects.
Course content
11 sections · 94 lessons
Thinking about security6 lessons
- Why security is every developer's jobPreviewReading · 3 min
- Assets, threats and attackersPreviewReading · 3 min
- The OWASP Top 10PreviewReading · 4 min
- Never trust inputReading · 4 min
- Defence in depth and least privilegeReading · 3 min
- Check a transfer requestExercise · 12 min
Storing passwords8 lessons
- Never store plain passwordsReading · 3 min
- Hashing: a one-way fingerprintReading · 3 min
- Why a fast hash isn't enoughReading · 4 min
- SaltsReading · 3 min
- Slow hashes: PBKDF2Reading · 4 min
- bcrypt, scrypt and Argon2Reading · 3 min
- Comparing in constant timeReading · 3 min
- Hash and verify passwordsExercise · 12 min
Users and passwords in Django10 lessons
- How Django stores passwordsReading · 4 min
- Switching to Argon2Reading · 4 min
- set_password and check_passwordReading · 4 min
- Password strength rulesReading · 4 min
- Why start with a custom user modelReading · 3 min
- Creating the User modelReading · 4 min
- AUTH_USER_MODEL and the first migrationReading · 4 min
- Logging in with an email addressReading · 4 min
- Referring to the user modelReading · 3 min
- Check a Django password hashExercise · 12 min
Logins under attack9 lessons
- Guessing, stuffing and sprayingReading · 3 min
- Rate limiting loginsReading · 4 min
- One message for every failed loginReading · 3 min
- Password reset done rightReading · 4 min
- Django's password reset tokensReading · 4 min
- Two-factor authenticationReading · 3 min
- How TOTP codes workReading · 4 min
- 2FA in a real Django siteReading · 4 min
- A TOTP code generatorExercise · 15 min
Sessions, tokens and JWT7 lessons
- Session cookies in DjangoReading · 4 min
- Tokens for appsReading · 3 min
- What's inside a JWTReading · 4 min
- How a JWT is signedReading · 4 min
- JWT pitfallsReading · 4 min
- Sessions, tokens or JWT?Reading · 3 min
- Verify a signed tokenExercise · 15 min
Where an SPA keeps its login8 lessons
- Where should the token go?Reading · 3 min
- localStorage and XSSReading · 4 min
- HttpOnly cookiesReading · 4 min
- Cookies bring CSRF backReading · 3 min
- Django's CSRF token in a React appReading · 4 min
- Keeping a token in memoryReading · 3 min
- Choosing for SikaPayReading · 3 min
- Audit the cookiesExercise · 12 min
Protected pages in React10 lessons
- The server is the real guardReading · 3 min
- An auth contextReading · 4 min
- A useAuth hookReading · 3 min
- Sending visitors to the login pageReading · 4 min
- Back where they startedReading · 3 min
- Protect the SikaPay dashboardExercise · 15 min
- When the API says 401Reading · 4 min
- Hiding buttons by roleReading · 3 min
- With React RouterReading · 4 min
- Log out when the session endsExercise · 12 min
Access control6 lessons
- Broken access control: number oneReading · 3 min
- Guessable idsReading · 4 min
- Scoping queries to the userReading · 4 min
- Object-level permissions in DRFReading · 4 min
- Groups and permissionsReading · 4 min
- Who can see this transfer?Exercise · 12 min
Injection and XSS9 lessons
- Injection: data that becomes codeReading · 3 min
- SQL injection in actionReading · 4 min
- Parameterised queriesReading · 3 min
- Django's ORM and raw SQLReading · 4 min
- Command injectionReading · 3 min
- XSS: escaping depends on where text goesReading · 4 min
- Django autoescaping and |safeReading · 4 min
- React escapes text tooReading · 4 min
- Find SQL built from stringsExercise · 12 min
Browser defences and security headers10 lessons
- How Django's CSRF protection worksReading · 4 min
- ClickjackingReading · 3 min
- CORS done rightReading · 4 min
- HTTPS everywhere with HSTSReading · 4 min
- Content Security PolicyReading · 4 min
- Smaller headers that helpReading · 3 min
- Django's headers, for realReading · 3 min
- python manage.py check --deployReading · 4 min
- Fixing the deploy warningsReading · 4 min
- Check the security headersExercise · 12 min
Secrets and security updates11 lessons
- Secrets don't belong in codeReading · 3 min
- When a secret leaksReading · 3 min
- Why updates matterReading · 3 min
- Django's releases and security fixesReading · 4 min
- Finding known vulnerabilities with pip-auditReading · 4 min
- npm audit for the React appReading · 3 min
- DependabotReading · 4 min
- Pinning and lock filesReading · 3 min
- Logging security eventsReading · 3 min
- Which packages need updating?Exercise · 10 min
- Final quizQuiz · 10 min
Reviews
No reviews yet.
Comments
Log in to join the conversation.
Loading comments...