In Google Cloud, when I create a service account, I give it roles to access certain APIs. Then later, when I load credentials for that service account, I specify scopes for the APIs it will use. Often, the roles given at account creation time are similar to the scopes specified at credential loading time. For example, I might create a service account with permission to access cloud storage and pub/sub, then specify scopes for, again, cloud storage and pub/sub.
Why, conceptually, is it like this? Specifically, what is the design goal for having to update both roles and scopes when I give my service account access to a new API?
(FWIW it's no problem for me to update both roles and scopes in this way, and I'm not really looking for a workaround, I'm just interested in why things are this way.)
I found some previous questions related to this but none really satisfied my curiosity about why things are set up this way
- OAuth-2.0/JWT - guidance about when to use scope vs roles -- answers the question for user accounts but doesn't really make sense to me for service accounts
- Oauth2, scopes and user roles -- a lot of technical info about Oauth2 that I couldn't fully make sense of
- GCP permissions: access scopes and custom IAM service account roles -- answers how to solve a certain auth issue but doesn't really say why things are this way