-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass auth header from client to loopback rest-connector #89
Comments
Have you tried to use connector observer - https://github.com/strongloop/loopback-connector-rest/blob/master/test/rest-loopback.test.js#L180? It allows you to intercept the http req/res for the outbound REST call. |
Hi Raymond, Yes I have (I think). I have a connector,js boot script that has the following, JBConnector.observe('before execute', function(ctx, next) The ctx object does not have the Authorisation header in it although I am sending it in the http.post request. |
Please note the For your case, maybe the best option is as follows:
We'll probably come up a better solution in LoopBack.next |
Hi Raymond, Thanks for the info re the ctx object. Please see this is for my attempt http://stackoverflow.com/questions/41573433/pass-basic-auth-from-angular-client-to-loopback-rest-connector which is wrong. I understand your steps as this is similar logic to what I was trying to do. The question really is how does this work. Best, |
Hello both, Did you guys get anywhere with an example of best practice for this issue? Best, |
I think we may be able to leverage http://loopback.io/doc/en/lb3/Using-current-context.html to implement this feature:
@raymondfeng thoughts? |
Thanks for the input @bajtos. @raymondfeng are you able to weigh in with your thoughts on this? Best, |
@bajtos +1. Let's create a user story to implement such enhancements (probably for all http related connectors). |
Hi @bajtos @raymondfeng. There context for why I am trying to do this is to allow the api to enable multi tenancy. As well as providing "local" models the api talks to another independent system. This system uses basic auth. The api may have to communicate with various instances of this independent system and hence requires the auth header to be dynamically created through the rest connector. Does that make sense? I can work with a work around if you guys can provide a code example of this? Best, |
Hi @raymondfeng, Is there any possibility to give include, filter options in the rest-connector template? |
@NudgeTech - I was able to do this using the
|
Thank you @kreegr |
How to do this on loopback 4? |
Hi, is there a "non-hacky" way to do this in LB4? Would really appreciate... |
@kreegr Hi Any ideas on implementing this for loopback 4 |
I’m sorry - I don’t (I haven’t tried because I haven’t used it yet) |
I suggest we move the discussion to loopbackio/loopback-next#2381. |
Feature request
Description of feature (or steps to reproduce if bug)
Data can be passed to the rest-connector but it seems headers cannot. It would be useful to pass the Authorization header to the rest-connector for multi tenanted systems. Here is a link to what I am trying to do which promoted this request.
http://stackoverflow.com/questions/41573433/pass-basic-auth-from-angular-client-to-loopback-rest-connector
http://stackoverflow.com/questions/29899682/loopback-io-rest-connector-how-to-pass-through-oauth-token?
@bajtos
The text was updated successfully, but these errors were encountered: