I am implementing API accessible only for users with specific scope, classic scenario. However I quite don't understand some things about access tokens.
I think this is straightforward, I just receive JWT, verify it, read scopes.
But since access token format isn't normalized, that JWT could contain anything. Should I just assume that scopes are there every time? Does every IdP put them in it?
I need to call introspect
endpoint and retrieve data from it.
But RFC7662 section 2.2 says that literally only required data in the response is bool active
, the rest is optional.
What exactly does "optional" mean here?
or
I found this post on Auth0 forum explaining their opaque and JWT tokens.
Opaque Access Tokens issued by Auth0 can be used with the /userinfo endpoint to return a user’s profile.
and
In order to receive a JWT you must include an audience parameter with your token request.
In this case I don't see any way to get scopes since they don't support token introspection. What am I missing here?
So in case of my implementation to be conformant for every OIDC IdP:
Anything else I should need to know / worry about?
I don't think you should aim to support every possible IdP, as many libraries expects and assumes the token is using the JWT format and won't work if your IdP uses reference tokens instead of JWT.
For example, for ASP.NET Core, the default JWT Library for authentication does only support JWT tokens.
Typically, your API, that you build, will only authenticate and trust tokens from one provider, typically, the one that you control and own (Either inhouse or as a service).
If you want to support social login, where users can for example login using Google and FaceBook, then that is arranged through your own IdP and your IDP will never deal directly with tokens from those providers.
A typical setup will look like this