Ciao,
I'm working with IdentityServer4 with the goal of protecting an resource api and exposing an identity server inside my organization.
So actually I have this elements:
- Authorization Server
- API Resources
- Client (SPA application)
I want to protect my API using scope and single actions accessed by user's roles. So for example I have this apis:
- API 1 (Scope API 1)
- Action1.1 <-- Only admin
- Action1.2 <-- Only manager
- Action1.3 <-- Only manager
- API 2 (Scope API 2)
- Action2.1 <-- Admin and manager
- Action2.2 <-- Only users
- Action2.3 <-- Only users
I know that OAuth2 protocol is for authorization (with its access_token) and OpenID Connect enriches OAuth2 protocol supporting authentication (with its identity_token).
I would know what is the best practices to achieve my goal. I've found two options:
- Send to API Resource identity_token and authorization_token (so that I can view user's role by identity_token and is can access to the scope).
- Adding role to access_token.
What is the best practice? Any advice is welcome
Thanks