You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ka...@apache.org on 2016/04/26 19:26:54 UTC
[03/13] mesos git commit: Added authentication to `/logging/toggle`
endpoint.
Added authentication to `/logging/toggle` endpoint.
This patch adds authentication to the `/logging/toggle`
HTTP endpoint on the master and agent.
Review: https://reviews.apache.org/r/46258/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7b87dd58
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7b87dd58
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7b87dd58
Branch: refs/heads/master
Commit: 7b87dd5861e3df94be41aa0210a1e81eab8459d0
Parents: 23bff54
Author: Greg Mann <gr...@mesosphere.io>
Authored: Tue Apr 26 10:42:48 2016 -0400
Committer: Kapil Arya <ka...@mesosphere.io>
Committed: Tue Apr 26 10:42:48 2016 -0400
----------------------------------------------------------------------
3rdparty/libprocess/include/process/logging.hpp | 23 ++++++++++++++++----
3rdparty/libprocess/src/logging.cpp | 4 +++-
3rdparty/libprocess/src/process.cpp | 2 +-
3 files changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/7b87dd58/3rdparty/libprocess/include/process/logging.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/logging.hpp b/3rdparty/libprocess/include/process/logging.hpp
index 0c07746..651cb37 100644
--- a/3rdparty/libprocess/include/process/logging.hpp
+++ b/3rdparty/libprocess/include/process/logging.hpp
@@ -25,9 +25,10 @@ namespace process {
class Logging : public Process<Logging>
{
public:
- Logging()
+ Logging(Option<std::string> _authenticationRealm)
: ProcessBase("logging"),
- original(FLAGS_v)
+ original(FLAGS_v),
+ authenticationRealm(_authenticationRealm)
{
// Make sure all reads/writes can be done atomically (i.e., to
// make sure VLOG(*) statements don't read partial writes).
@@ -41,11 +42,21 @@ public:
protected:
virtual void initialize()
{
- route("/toggle", TOGGLE_HELP(), &This::toggle);
+ if (authenticationRealm.isSome()) {
+ route("/toggle", authenticationRealm.get(), TOGGLE_HELP(), &This::toggle);
+ } else {
+ route("/toggle",
+ TOGGLE_HELP(),
+ [this](const http::Request& request) {
+ return This::toggle(request, None());
+ });
+ }
}
private:
- Future<http::Response> toggle(const http::Request& request);
+ Future<http::Response> toggle(
+ const http::Request& request,
+ const Option<std::string>& /* principal */);
void set(int v)
{
@@ -74,6 +85,10 @@ private:
Timeout timeout;
const int32_t original; // Original value of FLAGS_v.
+
+ // The authentication realm that the `/logging/toggle` endpoint will be
+ // installed into.
+ const Option<std::string> authenticationRealm;
};
} // namespace process {
http://git-wip-us.apache.org/repos/asf/mesos/blob/7b87dd58/3rdparty/libprocess/src/logging.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/logging.cpp b/3rdparty/libprocess/src/logging.cpp
index bdbf716..1cb0f4a 100644
--- a/3rdparty/libprocess/src/logging.cpp
+++ b/3rdparty/libprocess/src/logging.cpp
@@ -25,7 +25,9 @@
namespace process {
-Future<http::Response> Logging::toggle(const http::Request& request)
+Future<http::Response> Logging::toggle(
+ const http::Request& request,
+ const Option<std::string>& /* principal */)
{
Option<std::string> level = request.url.query.get("level");
Option<std::string> duration = request.url.query.get("duration");
http://git-wip-us.apache.org/repos/asf/mesos/blob/7b87dd58/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index d1d924c..327ee43 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -970,7 +970,7 @@ bool initialize(
help = spawn(new Help(delegate), true);
// Create the global logging process.
- spawn(new Logging(), true);
+ spawn(new Logging(authenticationRealm), true);
// Create the global profiler process.
spawn(new Profiler(), true);