loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Further integration between oAuth 2.0 and LoopBack

Open raymondfeng opened this issue 12 years ago • 20 comments

  1. Unify the access token model between oAuth 2.0 and User.login
  2. Integrate scope with ACL

raymondfeng avatar Nov 14 '14 17:11 raymondfeng

+1

jkernech avatar Nov 26 '14 10:11 jkernech

+1

XinV avatar Dec 04 '14 06:12 XinV

+1

gagan-bansal avatar Jan 15 '15 13:01 gagan-bansal

+1

robotiko avatar Feb 16 '15 18:02 robotiko

+1

zetflo avatar Mar 05 '15 16:03 zetflo

I did some basic testing. The oAuth 2.0 token based authentication is already working with ACLs if you enable the middleware on your resource/api server that serves the model endpoints.

raymondfeng avatar Mar 05 '15 16:03 raymondfeng

Hi raymondfeng , My scenario is using 'ClientCredentials' grant type to be able to generate accesstoken based on Client id and Client secret as we don't have any resource owner conept. Here are steps that I have done so fat:

  1. Created my own application model which extends Application model
  2. Registered my client application into application model from which I got Client Id and Client secret(restapikey)

Here are my questions and can you please direct me (code base) on how to achieve this

  1. I need to pass this clientid and Client secret to 'ClientCredentials' grant type to get accesstoken from authorization server, right?
  2. Based on accesstoken if my client tries to access restapi how does ACL know which user he is being looged in? as my accesstoken does not have userid

archana09 avatar Mar 12 '15 16:03 archana09

+1

skyserpent avatar Apr 10 '15 03:04 skyserpent

+1, some code examples and instruction walking through would be much helpful.

XinV avatar Apr 11 '15 05:04 XinV

+1

SkyBone42 avatar May 04 '15 14:05 SkyBone42

+1

ghost avatar May 20 '15 16:05 ghost

+1

danielrvt avatar May 25 '15 20:05 danielrvt

+1 this would be awesome! Thanks for all the effort that goes into this.

luksch avatar May 27 '15 11:05 luksch

+1 I am working on an application that need throttling and autentication to get access to my api. I need information because maybe i missunderstood the concept. If I create ACL and roles in the api server, the gateway doent know anything about this users and this roles. the access_token is only to pass through the proxy and if you need an access_token to this end point its not the same.

By the way, i want to know if there are any chance to autenticate with oauth2 as an anonymous user, because in our use case makes sense to keep some state or session to a gest that doesnt have account yet.

I need to get working my application quickly so by the moment i am deleting all the gateway stuff and implement the autentication directly in the api server.

Thank you for your job because is a great framework to create apis really quick but some features are not yet ready to be in production.

mercuriete avatar May 27 '15 11:05 mercuriete

Hey guys, I was able to get a working example with oAuth2, passport, and ACL.

https://github.com/qbanguy/loopback-gateway2

asanchezdelc avatar Jun 03 '15 17:06 asanchezdelc

The oAuth 2.0 token based authentication is already working with ACLs if you enable the middleware on your resource/api server that serves the model endpoints

@raymondfeng Which middleware are you referring to ?

Does this mean that we can store OAuth tokens directly inside LB's AccessToken model, using node api equivalent of POST /User/{id}/accessTokens ? And still benefit from entire loopback ACL system ? That would be ideal

Overdrivr avatar Jul 20 '16 13:07 Overdrivr

Is this still in the pipeline or is it better to create our own solution?

JonnyBGod avatar Dec 13 '16 01:12 JonnyBGod

I've added an option for oauth2 and loopback to live side by side. If you're interested, it's all available: https://github.com/crownstone/loopback-component-oauth2

AlexDM0 avatar Mar 21 '17 13:03 AlexDM0

Any update ? I can't use OAuth2 at all with those ACL issues :(

Yaty avatar Dec 12 '17 12:12 Yaty

The approach I would use is similar to what Gitlab does, use OAuth2 for first connection to acquire user email, then let the user generate a password. It's not exactly the full OAuth2 flow, but at least in the end you can create a regular User with Loopback, and benefit from ACL/Authentication/etc.

Eventually, if you need interaction with the OAuth provider, then you might be able to store credentials/token/whatever inside the Loopback User and pass those credentials to the OAuth provider when you need to.

I haven't completely tested this approach so I might be missing something here, but my guess is this should work.

Overdrivr avatar Dec 15 '17 07:12 Overdrivr