Custom JWT Claims in Spring Security

Sometimes, JWT tokens contain custom claims. And sometimes, those custom claims contain the user roles, instead of the default scope claim. What if we could teach Spring Security about these fields and map them to the Principal object? Here’s how.