Someone pointed out to me this phrase on the OAuth website:
ID tokens should never be sent to an API.
(source)
We have 2 in-house applications, an ASP.NET back-end (the API), and a JavaScript front-end. They are separately deployed, but this is just the nature of modern front-end development I think. 10 years ago it would have been a single ASP.NET MVC application.
We need to secure it using single sing-on: only employees with a specific role should be allowed to use it.
So I think the front-end app should initiate authentication using OIDC, so with scope set to openid
and using the code
grant type (PKCE). When the front-end acquired the ID token, it can send it to the API and the API’s middleware will verify the signature and extract the role claims.
Back to the quote, and my question: if I should 'never' send an ID token to an API, then what am I supposed to do here?
To be clear, this question is about OIDC. There is no delegated authorization involving a 3rd-party, so I did not tag this question with the OAuth tag, because employees are not asked to consent to the front-end accessing 'their' resources on the back-end. The users simply must authenticate and have been assigned a role to be allowed to use the application.