Biometric: Fingerprint, Face ID, voice recognition.
# OAuth 2.0 Authorization Code Flow
User clicks "Login with Google" → redirected to Google
Google asks for consent → Google redirects to app with code
Backend exchanges code + client_secret for access_token
Backend uses access_token to fetch user profile from Google API
Authorization
Authorization determines what a user can do after authentication.
Model
Description
Example
RBAC
Role-Based Access Control
Admin, Editor, Viewer roles
ABAC
Attribute-Based Access Control
"Can edit documents created in the last 30 days"
PBAC/PBAC
Policy-Based Access Control
IAM policies (AWS)
ACL
Access Control Lists
Per-object permissions (file systems)
# RBAC Policy (Pseudocode)
roles:
admin: [read, write, delete, manage_users]
editor: [read, write]
viewer: [read]
def authorize(user, action, resource):
user_roles = get_roles(user)
return any(action in role.permissions for role in user_roles)
Data Protection
Encryption
In Transit: TLS/SSL encrypts data flowing between client and server. Use HTTPS everywhere.
At Rest: Encrypt data stored on disk. Database encryption (AES-256), file-level encryption, disk encryption.
End-to-End: Data encrypted on client, decrypted only on destination client. Servers cannot read the content.
Data Masking
Replace sensitive data (PII, credit card numbers) with masked versions in logs, dev databases, and UI: ****-****-****-1234.
Key Management
Use a Key Management Service (AWS KMS, Azure Key Vault, HashiCorp Vault) to store, rotate, and audit encryption keys. Never hardcode keys in source code.
Infrastructure Security
Network Segmentation: VPC, subnets, security groups, firewalls. Separate public-facing tiers from private data tiers.
Exercise: Design an authentication and authorization system for a healthcare API. Requirements: patients can view their own records, doctors can view/edit assigned patients, admins can manage users. All access must be logged. Data must be encrypted at rest and in transit. Describe your auth model, encryption strategy, and audit approach.