Pre Authentication Process

Hi There

Right now I am using DSP with an Angularjs app and everything is working fine as the users are checked against the DSP user table but I would like to do the following:

  1. User enters the email and password
  2. Instead of checking against the DSP user database it should send an http request to a password protected URL which takes in the email and password and returns code 200 if it is good.
  3. Then update the password in the DSP account and login in the user using the regular DSP user database credentials.

This is the equivalent code using PHP CURL:

$curl = curl_init('https://mail.google.com/mail/feed/atom');
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->params->get('verifypeer', 1));
                curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($curl, CURLOPT_USERPWD, $credentials['username'] . ':' . $credentials['password']);
                curl_exec($curl);
                $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);

                switch ($code)
                {
                    case 200:
                        $message = 'ACCESS_GRANTED';
                        $success = 1;
                        break;

                    case 401:
                        $message = 'ACCESS_DENIED';
                        break;     
                                   
                    default:       
                        $message = 'UNKNOWN_ACCESS_DENIED';
                        break;
                }

I would really appreciate any help. I am thinking I have to edit the DSP angular-user-module to get the desired results.

I don’t think adding and then editing the source code of the angular_dreamfactory_user_management_module should be necessary to accomplish this. You should be able to add a script to POST /user/session that makes the external authentication call, then allows the login to proceed if good, and prevents it if not.

Thanks @jeffreystables

I will give it a try and will post my response when I tackle it.

1 Like

All these links are not working anymore, could you please update it? Thanks

https://wiki.dreamfactory.com/DreamFactory/Tutorials#Scripting

All documentation is now at https://wiki.dreamfactory.com