loopback
loopback copied to clipboard
auth with GET request to a remote server by REST connector?
I'd like to integrate with a legacy system, and it can only auth with http get request as below:
http://192.168.20.200/cgi-bin/cgi_api?API_NAME=Core.Login&user_id=adm&password=adm
How could I do? please suggest:
- user.login = function(credentials, include, callback) {...?
- user.afterRemoteError( 'login', function( ctx, modelInstance, next) {...?
- use loopback-passport and passport-http?
- create REST connector and overwrite auth method? how to overwrite auth method?
- create Oauth service for legacy system? Any other solution to auth with legacy system? Thanks.
@raymondfeng ^
My workaround solution: auth with legacy system on beforeRemote, if success, update password then call next()
user.beforeRemote( 'login', function( ctx, modelInstance, next) {
...
authLegacy(ctx, function(err){
if(!err){
...
user.find(whereFilter, function(err, foundObjs){
...
foundObjs[0].password=data.password;
foundObjs[0].save(function(err, savedObj){
...
}
}
next();//
});
});