I've read through RFC6749 for OAuth 2.0 as well as quite a few SO questions and blog posts but I'm still unclear on how to implement some of the things.
Currently, users log in through a form on a web page and use the application which makes database calls to fetch and manipulate resources. The goal is to abstract out the resources from the application.
In the context of OAuth 2.0, I've identified that:
- The users are resource owners
- My web application is the client, specifically a confidential client
- My API is the resource server
I also understand that OAuth 2.0 works by authorization grants and access tokens (at the minimum). I'd like to support the password and client credentials grant types in my authorization server. Lets also assume that my web application is the only authorized application to access the API.
Questions regarding implementation with resource owner authorization grant type:
- Does every user receive their own access token? I'm assuming yes because I need to distinguish between different users for additional purposes (e.g. authorization)
- Can a user receive more than one access token? (e.g. if they log in to the application at more than 1 user-agent/computer)
- What do I send in the
Authorization
HTTP header to the authorization server? (Remember I only have one client) - How do I get the identity of the user from the access token? (e.g. user ID/username)
- Is it safe to store the access token and refresh token in
$_SESSION
in the web application?