Enable http digest authentication for CURL
This commit is contained in:
parent
c5b06dc1ff
commit
0a932ebfe3
5 changed files with 50 additions and 3 deletions
1
deps/deps-linux.cmake
vendored
1
deps/deps-linux.cmake
vendored
|
@ -80,7 +80,6 @@ ExternalProject_Add(dep_libcurl
|
||||||
--disable-smb
|
--disable-smb
|
||||||
--disable-smtp
|
--disable-smtp
|
||||||
--disable-gopher
|
--disable-gopher
|
||||||
--disable-crypto-auth
|
|
||||||
--without-gssapi
|
--without-gssapi
|
||||||
--without-libpsl
|
--without-libpsl
|
||||||
--without-libidn2
|
--without-libidn2
|
||||||
|
|
1
deps/deps-macos.cmake
vendored
1
deps/deps-macos.cmake
vendored
|
@ -67,7 +67,6 @@ ExternalProject_Add(dep_libcurl
|
||||||
--disable-smb
|
--disable-smb
|
||||||
--disable-smtp
|
--disable-smtp
|
||||||
--disable-gopher
|
--disable-gopher
|
||||||
--disable-crypto-auth
|
|
||||||
--without-gssapi
|
--without-gssapi
|
||||||
--without-libpsl
|
--without-libpsl
|
||||||
--without-libidn2
|
--without-libidn2
|
||||||
|
|
|
@ -448,6 +448,15 @@ Http& Http::auth_digest(const std::string &user, const std::string &password)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Http& Http::auth_basic(const std::string &user, const std::string &password)
|
||||||
|
{
|
||||||
|
curl_easy_setopt(p->curl, CURLOPT_USERNAME, user.c_str());
|
||||||
|
curl_easy_setopt(p->curl, CURLOPT_PASSWORD, password.c_str());
|
||||||
|
curl_easy_setopt(p->curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
Http& Http::ca_file(const std::string &name)
|
Http& Http::ca_file(const std::string &name)
|
||||||
{
|
{
|
||||||
if (p && priv::ca_file_supported(p->curl)) {
|
if (p && priv::ca_file_supported(p->curl)) {
|
||||||
|
|
|
@ -67,6 +67,8 @@ public:
|
||||||
Http& remove_header(std::string name);
|
Http& remove_header(std::string name);
|
||||||
// Authorization by HTTP digest, based on RFC2617.
|
// Authorization by HTTP digest, based on RFC2617.
|
||||||
Http& auth_digest(const std::string &user, const std::string &password);
|
Http& auth_digest(const std::string &user, const std::string &password);
|
||||||
|
// Basic HTTP authorization
|
||||||
|
Http& auth_basic(const std::string &user, const std::string &password);
|
||||||
// Sets a CA certificate file for usage with HTTPS. This is only supported on some backends,
|
// Sets a CA certificate file for usage with HTTPS. This is only supported on some backends,
|
||||||
// specifically, this is supported with OpenSSL and NOT supported with Windows and OS X native certificate store.
|
// specifically, this is supported with OpenSSL and NOT supported with Windows and OS X native certificate store.
|
||||||
// See also ca_file_supported().
|
// See also ca_file_supported().
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "slic3r/Utils/Http.hpp"
|
#include "slic3r/Utils/Http.hpp"
|
||||||
|
|
||||||
TEST_CASE("Http", "[Http][NotWorking]") {
|
TEST_CASE("Check SSL certificates paths", "[Http][NotWorking]") {
|
||||||
|
|
||||||
Slic3r::Http g = Slic3r::Http::get("https://github.com/");
|
Slic3r::Http g = Slic3r::Http::get("https://github.com/");
|
||||||
|
|
||||||
|
@ -20,3 +20,41 @@ TEST_CASE("Http", "[Http][NotWorking]") {
|
||||||
REQUIRE(status == 200);
|
REQUIRE(status == 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Http digest authentication", "[Http][NotWorking]") {
|
||||||
|
Slic3r::Http g = Slic3r::Http::get("https://jigsaw.w3.org/HTTP/Digest/");
|
||||||
|
|
||||||
|
g.auth_digest("guest", "guest");
|
||||||
|
|
||||||
|
unsigned status = 0;
|
||||||
|
g.on_error([&status](std::string, std::string, unsigned http_status) {
|
||||||
|
status = http_status;
|
||||||
|
});
|
||||||
|
|
||||||
|
g.on_complete([&status](std::string /* body */, unsigned http_status){
|
||||||
|
status = http_status;
|
||||||
|
});
|
||||||
|
|
||||||
|
g.perform_sync();
|
||||||
|
|
||||||
|
REQUIRE(status == 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Http basic authentication", "[Http][NotWorking]") {
|
||||||
|
Slic3r::Http g = Slic3r::Http::get("https://jigsaw.w3.org/HTTP/Basic/");
|
||||||
|
|
||||||
|
g.auth_basic("guest", "guest");
|
||||||
|
|
||||||
|
unsigned status = 0;
|
||||||
|
g.on_error([&status](std::string, std::string, unsigned http_status) {
|
||||||
|
status = http_status;
|
||||||
|
});
|
||||||
|
|
||||||
|
g.on_complete([&status](std::string /* body */, unsigned http_status){
|
||||||
|
status = http_status;
|
||||||
|
});
|
||||||
|
|
||||||
|
g.perform_sync();
|
||||||
|
|
||||||
|
REQUIRE(status == 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue