Kiến trúc: một Authorization Server trung tâm (dùng Spring Authorization Server) đóng vai identity provider — phát JWT.
Nhiều Resource Server (microservices) validate token cục bộ (không cần network call đến auth server mỗi request).
Flow:
- Client lấy token từ
/oauth2/tokenvới client credentials hoặc authorization code. - Client gửi request với header
Authorization: Bearer <JWT>. - Resource Server verify JWT signature, kiểm tra claims (issuer, expiration, scope)
OAuth 2.1 loại bỏ các grant type nguy hiểm của 2.0: không còn Implicit Grant, Password Grant (credential phishing).
PKCE bắt buộc với Authorization Code.
Spring Security 6: @EnableMethodSecurity thay thế @EnableGlobalMethodSecurity, lambda DSL thay XML.