loopback icon indicating copy to clipboard operation
loopback copied to clipboard

auth with GET request to a remote server by REST connector?

Open makersu opened this issue 11 years ago • 2 comments

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:

  1. user.login = function(credentials, include, callback) {...?
  2. user.afterRemoteError( 'login', function( ctx, modelInstance, next) {...?
  3. use loopback-passport and passport-http?
  4. create REST connector and overwrite auth method? how to overwrite auth method?
  5. create Oauth service for legacy system? Any other solution to auth with legacy system? Thanks.

makersu avatar Sep 09 '15 08:09 makersu

@raymondfeng ^

superkhau avatar Sep 09 '15 21:09 superkhau

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();//
        });
    });

makersu avatar Sep 14 '15 10:09 makersu