52 std::string sysvar_auth_url;
54 Auth_http(std::string name_arg,
const std::string &url_arg) :
56 sysvar_auth_url(url_arg)
61 curl_handle= curl_easy_init();
64 rv= curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 0);
65 rv= curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1);
66 rv= curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
69 rv= curl_easy_setopt(curl_handle, CURLOPT_NOBODY, 1);
72 rv= curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, curl_cb_read);
75 std::string& getAuthURL()
77 return sysvar_auth_url;
80 bool setAuthURL(std::string& new_auth_url)
82 if (new_auth_url.empty())
84 errmsg_printf(error::ERROR, _(
"auth url cannot be an empty string"));
87 sysvar_auth_url= new_auth_url;
93 curl_easy_cleanup(curl_handle);
94 curl_global_cleanup();
97 virtual bool authenticate(
const identifier::User &sctx,
const string &password)
99 long http_response_code;
101 assert(sctx.username().c_str());
104 rv= curl_easy_setopt(curl_handle, CURLOPT_URL, sysvar_auth_url.c_str());
106 rv= curl_easy_setopt(curl_handle, CURLOPT_USERNAME,
107 sctx.username().c_str());
108 rv= curl_easy_setopt(curl_handle, CURLOPT_PASSWORD, password.c_str());
112 rv= curl_easy_perform(curl_handle);
115 rv= curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &http_response_code);
123 if (http_response_code == 401)
175 context.registerVariable(
new sys_var_std_string(
"url", auth->getAuthURL(), NULL, &updateAuthURL));