mardi 23 février 2016

Custom user provider in laravel using OAuth2

I want to use an external OAuth2 server under my control to authenticate users for my Laravel 5.2 application. As client library I want to use the package league/oauth2-client As far as I understood need to implement a custom user provider but I'm uncertain about the big picture of all required steps.

The idea is that the user provides the credentials to my Laravel application, with other words the client credentials method is used. Then the bearer-token and the refresh-token is stored on the client side. Every time a client makes a request, the token must be validated by the OAuth server. The OAuth server also provides some basic user information like email and name. So in my application there must be some kind of link between the local user and the OAuth user. This is accomplished with a simple table like

+-------------------+
|       Users       |
+-------------------+
| id      | int(10) |
| oauthId | int(10) |
+---------+---------+

First I followed this guide at laravel.io to create a basic provider skeleton. But at this point I have several questions:

  1. Is the method retrieveById supposed to return any user from the OAuth service or only the users which is the issuer of the request allowed to see?

  2. My OAuth server already has permission checking for each user. If retrieveById is supposed to return any existing user, is my permission check on the OAuth server worthless? This would be a flaw in my architecture.

  3. Some methods must return an implementation of the \Illuminate\Contracts\Auth\Authenticatable interface. Where do I have to implement this? Is this supposed to be the representation of the user which is trying to authenticate? If this should represent a user in my model I have the problem that I don't know the return value for getAuthPassword since this information is on my OAuth server. How can I solve this?

As you can see I have problems to understand how things working together in the whole authentication process. Your help is very appreciated.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1PUVNXS
via IFTTT

Aucun commentaire:

Enregistrer un commentaire