How do authentication and authorization differ, and what about 401 vs 403?
Short answer
Authentication answers "who are you", authorization answers "what may you do", and AuthN always comes first. Identity unknown → 401; known but not allowed → 403.
3 points to say:
- AuthN checks credentials (password, JWT, certificate); AuthZ checks permission on a specific resource.
- 401: the client logs in again or refreshes and retries; 403: refreshing will not help.
- Spring:
AuthenticationEntryPoint→ 401,AccessDeniedHandler→ 403; for someone else's resource consider returning 404.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.