-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that SSL support is enabled in HttpClient
The http-check tool was working fine with HTTPS because it enabled the support before it included httplib.h. However, the HttpClient implementation did not, which mean that the whole of the shared library was not supporting HTTPS. When using the API over HTTPS, this was silently crashing the module because of an uncaught exception. This would normally produce stdout or stderr output, but it is squelched by the Apache process management. We add an additional api-check binary that enables a cursory check of using the Authorizer against an HTTP or HTTPS API instance from the command line.
- Loading branch information
Showing
4 changed files
with
75 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <exception> | ||
#include <iostream> | ||
#include <map> | ||
#include <memory> | ||
|
||
#include <lauth/authorizer.hpp> | ||
#include <lauth/logging.hpp> | ||
|
||
using namespace mlibrary::lauth; | ||
|
||
int main(int argc, char **argv) { | ||
if (argc != 6) { | ||
std::cout << "Usage: api-check <host> <token> <uri> <ip> <username>" << std::endl; | ||
return -1; | ||
} | ||
|
||
auto host = std::string(argv[1]); | ||
auto token = std::string(argv[2]); | ||
auto uri = std::string(argv[3]); | ||
auto ip = std::string(argv[4]); | ||
auto user = std::string(argv[5]); | ||
std::cout << "Authorizing (via " << host << ") -- uri: " << uri << ", ip: " << ip << ", user: " << user << std::endl; | ||
|
||
Logger::set(std::make_shared<Logger>(std::make_unique<StdOut>())); | ||
auto auth = Authorizer(host, token); | ||
Request req = Request { | ||
.ip = ip, | ||
.uri = uri, | ||
.user = user | ||
}; | ||
|
||
auto result = auth.authorize(req); | ||
std::cout << "Authorizer worked... determination: " << result["determination"] << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters