functions_googleoauth.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /* Copyright (C) 2007-2013 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2007-2009 Regis Houssin <regis.houssin@inodbox.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/core/login/functions_googleoauth.php
  20. * \ingroup core
  21. * \brief Authentication functions for Google OAuth mode using "Server flow"
  22. * Another method could be to use the "Implicit flow" using Google-Signin library.
  23. */
  24. //include_once DOL_DOCUMENT_ROOT.'/core/class/openid.class.php';
  25. /**
  26. * Check validity of user/password/entity
  27. * If test is ko, reason must be filled into $_SESSION["dol_loginmesg"]
  28. *
  29. * @param string $usertotest Login
  30. * @param string $passwordtotest Password
  31. * @param int $entitytotest Number of instance (always 1 if module multicompany not enabled)
  32. * @return string Login if OK, '' if KO
  33. */
  34. function check_user_password_googleoauth($usertotest, $passwordtotest, $entitytotest)
  35. {
  36. global $_POST, $db, $conf, $langs;
  37. dol_syslog("functions_googleoauth::check_user_password_googleoauth usertotest=".$usertotest);
  38. $login = '';
  39. // Get identity from user and redirect browser to Google OAuth Server
  40. if (GETPOSTISSET('username')) {
  41. /*$openid = new SimpleOpenID();
  42. $openid->SetIdentity(GETPOST('username'));
  43. $protocol = ($conf->file->main_force_https ? 'https://' : 'http://');
  44. $openid->SetTrustRoot($protocol . $_SERVER["HTTP_HOST"]);
  45. $openid->SetRequiredFields(array('email','fullname'));
  46. $_SESSION['dol_entity'] = $_POST["entity"];
  47. //$openid->SetOptionalFields(array('dob','gender','postcode','country','language','timezone'));
  48. if ($openid->sendDiscoveryRequestToGetXRDS())
  49. {
  50. $openid->SetApprovedURL($protocol . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]); // Send Response from OpenID server to this script
  51. $openid->Redirect(); // This will redirect user to OpenID Server
  52. }
  53. else
  54. {
  55. $error = $openid->GetError();
  56. return false;
  57. }
  58. return false;*/
  59. }
  60. return $login;
  61. }