osu-tournament-rating / otr-api

API powering osu! Tournament Rating
https://otr.stagec.xyz/
GNU General Public License v3.0
8 stars 5 forks source link

Refactor usage of `claim` to `role` in the context of JWT #444

Closed myssto closed 1 month ago

myssto commented 1 month ago

We inconsistently (and incorrectly in most places) use the term claim to describe a user / client permission that we encode into JWTs for access control. The correct term for this would be role.

In the OAuthHandler we encode User.Scopes and Client.Scopes into the JWT as claims with a ClaimType of ClaimTypes.Role. In the JWT they appear as such:

{
  "role": [
     "whitelist",
     "admin",
     "user"
  ]
}

I know this is mostly semantics, but it helps cut confusion especially since there are spots where we do actually encode a custom ClaimType like rate limit overriding. This PR is just the refactoring for namespaces and naming convention. I will be updating some code for OAuth as well.