Further integration between oAuth 2.0 and LoopBack
- Unify the access token model between oAuth 2.0 and User.login
- Integrate scope with ACL
+1
+1
+1
+1
+1
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.
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:
- Created my own application model which extends Application model
- 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
- I need to pass this clientid and Client secret to 'ClientCredentials' grant type to get accesstoken from authorization server, right?
- 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
+1
+1, some code examples and instruction walking through would be much helpful.
+1
+1
+1
+1 this would be awesome! Thanks for all the effort that goes into this.
+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.
Hey guys, I was able to get a working example with oAuth2, passport, and ACL.
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
Is this still in the pipeline or is it better to create our own solution?
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
Any update ? I can't use OAuth2 at all with those ACL issues :(
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.