Reputation: 3026
I'm fairly new to setting up an Oath2 server, and was hoping that someone could help me shed some light on a couple things.
This is the package that I am implementing:
https://github.com/lucadegasperi/oauth2-server-laravel
From what I've read about this package, Im pretty sure that the 'password' / 'Resource Ownner' grant_type is what I should be using for setting up a mobile app's API access much like a mobile banking app (sensitive data)
Referencing the OAuth2 spec:
https://www.rfc-editor.org/rfc/rfc6749#section-4.3
The OAth2 spec states that the client must already be authenticated, so there are 5 total parameters that must be passed to be granted an access token:
I have 2 questions regarding this:
Ultimately, I'm trying to figure out best practices for getting records in the 'oath_clients' table and if those entries should be unique per device.
Thanks for you help!
Upvotes: 5
Views: 1661
Reputation: 19011
Whether all devices should share the same pair of client_id and client_secret or whether each device should have a different pair of client_id and client_secret is up to you. From a viewpoint of OAuth 2.0, there is no difference between them because OAuth 2.0 does not care about how each application instance obtains a pair of client_id and client_secret. You may
If you wanted to assign a different pair of client_id and client_secret to each device, the flow would be like the following.
If you want to identify a device by a client_id, you need to associate each client_id with each device. However, if you just want to know which device is accessing protected resources, it may be enough to require 'device_id' parameter or something similar when a client application accesses endpoints of protected resources. To be concrete:
GET /protected_resource?access_token=.....&device_id=.....
Finally, as for your first question. OAuth 2.0 does not think native applications can keep client credentials confidential. Below is an excerpt from "9. Native Applications".
Native applications that use the authorization code grant type
SHOULD do so without using client credentials, due to the native
application's inability to keep client credentials confidential.
Upvotes: 8