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:27:00 UTC

[09/13] mesos git commit: Added authentication to the '/profiler/*' endpoints.

Added authentication to the '/profiler/*' endpoints.

Review: https://reviews.apache.org/r/46497/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/36aeb17e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/36aeb17e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/36aeb17e

Branch: refs/heads/master
Commit: 36aeb17e0bf41e630e6020af9832dfb853817b68
Parents: 0956ce8
Author: Greg Mann <gr...@mesosphere.io>
Authored: Tue Apr 26 10:43:42 2016 -0400
Committer: Kapil Arya <ka...@mesosphere.io>
Committed: Tue Apr 26 10:44:23 2016 -0400

----------------------------------------------------------------------
 .../libprocess/include/process/profiler.hpp     | 42 +++++++++++++++++---
 3rdparty/libprocess/src/process.cpp             |  2 +-
 3rdparty/libprocess/src/profiler.cpp            |  8 +++-
 3 files changed, 44 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/36aeb17e/3rdparty/libprocess/include/process/profiler.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/profiler.hpp b/3rdparty/libprocess/include/process/profiler.hpp
index b305f11..f6fccfb 100644
--- a/3rdparty/libprocess/include/process/profiler.hpp
+++ b/3rdparty/libprocess/include/process/profiler.hpp
@@ -24,15 +24,39 @@ namespace process {
 class Profiler : public Process<Profiler>
 {
 public:
-  Profiler() : ProcessBase("profiler"), started(false) {}
+  Profiler(const Option<std::string>& _authenticationRealm)
+    : ProcessBase("profiler"),
+      started(false),
+      authenticationRealm(_authenticationRealm) {}
 
   virtual ~Profiler() {}
 
 protected:
   virtual void initialize()
   {
-    route("/start", START_HELP(), &Profiler::start);
-    route("/stop", STOP_HELP(), &Profiler::stop);
+    if (authenticationRealm.isSome()) {
+      route("/start",
+            authenticationRealm.get(),
+            START_HELP(),
+            &Profiler::start);
+
+      route("/stop",
+            authenticationRealm.get(),
+            STOP_HELP(),
+            &Profiler::stop);
+    } else {
+      route("/start",
+            START_HELP(),
+            [this](const http::Request& request) {
+              return Profiler::start(request, None());
+            });
+
+      route("/stop",
+            STOP_HELP(),
+            [this](const http::Request& request) {
+              return Profiler::stop(request, None());
+            });
+    }
   }
 
 private:
@@ -42,14 +66,22 @@ private:
   // HTTP endpoints.
 
   // Starts the profiler. There are no request parameters.
-  Future<http::Response> start(const http::Request& request);
+  Future<http::Response> start(
+      const http::Request& request,
+      const Option<std::string>& /* principal */);
 
   // Stops the profiler. There are no request parameters.
   // This returns the profile output, it will also remain present
   // in the working directory.
-  Future<http::Response> stop(const http::Request& request);
+  Future<http::Response> stop(
+      const http::Request& request,
+      const Option<std::string>& /* principal */);
 
   bool started;
+
+  // The authentication realm that the profiler's HTTP endpoints will be
+  // installed into.
+  Option<std::string> authenticationRealm;
 };
 
 } // namespace process {

http://git-wip-us.apache.org/repos/asf/mesos/blob/36aeb17e/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index ef27b66..dcaa646 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -979,7 +979,7 @@ bool initialize(
   spawn(new Logging(authenticationRealm), true);
 
   // Create the global profiler process.
-  spawn(new Profiler(), true);
+  spawn(new Profiler(authenticationRealm), true);
 
   // Create the global system statistics process.
   spawn(new System(), true);

http://git-wip-us.apache.org/repos/asf/mesos/blob/36aeb17e/3rdparty/libprocess/src/profiler.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/profiler.cpp b/3rdparty/libprocess/src/profiler.cpp
index 397d7b9..9b2f106 100644
--- a/3rdparty/libprocess/src/profiler.cpp
+++ b/3rdparty/libprocess/src/profiler.cpp
@@ -56,7 +56,9 @@ const std::string Profiler::STOP_HELP()
 }
 
 
-Future<http::Response> Profiler::start(const http::Request& request)
+Future<http::Response> Profiler::start(
+    const http::Request& request,
+    const Option<std::string>& /* principal */)
 {
 #ifdef ENABLE_GPERFTOOLS
   const Option<std::string>
@@ -99,7 +101,9 @@ Future<http::Response> Profiler::start(const http::Request& request)
 }
 
 
-Future<http::Response> Profiler::stop(const http::Request& request)
+Future<http::Response> Profiler::stop(
+    const http::Request& request,
+    const Option<std::string>& /* principal */)
 {
 #ifdef ENABLE_GPERFTOOLS
   if (!started) {