Search code examples
oauth-2.0google-oauth

OAuth2 authorization for project and custom project-specific user role


I'm new to OAuth2 and trying to figure out what is the best practice for the following scenario:

  • I'm implementing 'ToDo' web service (CRUD for 'tasks')
  • I'm using OAuth2 and Google as auth provider to get user details (email, name)
  • Now I need to implement project-specific roles for users ('admin', 'user')

Speaking in terms of OAuth2 - Google doesn't 'own' my service, so it cannot help me with storing/providing 'ToDo'-specific roles, is it correct?

What is the common/best approach to implement it, do I need to create my own authorization service where I'll need to store relations like userinfo -> project-specific role?


Solution

  • Well, it depends what, exactly, you're looking to do.

    If you have users, and those users have specific roles that you have assigned to them already, then you're just using Google's OAuth service as an identity service. You don't need to implement your own authorization service, but you will need to keep track (typically in your own database) a relationship between the userid and the roles for that users.

    If the goal is to create a service where the user can delegate specific permissions they have to a third-party service, then you will certainly need to implement your own OAuth server. This will allow the user to limit the scopes that are necessary for the third-party service to do its job.