You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ti...@apache.org on 2017/10/10 18:59:30 UTC

[4/4] mesos git commit: Added HTTP authenticatee interface definition.

Added HTTP authenticatee interface definition.

Defines an interface for the scheduler library authentication,
providing the means of an HTTP authenticatee. This interface allows
consumers of HTTP APIs to use replaceable authentication mechanisms.

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


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

Branch: refs/heads/master
Commit: 185b64fa05194b4350fcadc1fce6c9b9620ed34b
Parents: a3faf6c
Author: Till Toenshoff <to...@me.com>
Authored: Tue Oct 10 20:17:31 2017 +0200
Committer: Till Toenshoff <to...@me.com>
Committed: Tue Oct 10 20:59:13 2017 +0200

----------------------------------------------------------------------
 .../mesos/authentication/http/authenticatee.hpp | 77 ++++++++++++++++++++
 src/Makefile.am                                 | 11 ++-
 2 files changed, 85 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/185b64fa/include/mesos/authentication/http/authenticatee.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/authentication/http/authenticatee.hpp b/include/mesos/authentication/http/authenticatee.hpp
new file mode 100644
index 0000000..00676fe
--- /dev/null
+++ b/include/mesos/authentication/http/authenticatee.hpp
@@ -0,0 +1,77 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __MESOS_AUTHENTICATION_HTTP_AUTHENTICATEE_HPP__
+#define __MESOS_AUTHENTICATION_HTTP_AUTHENTICATEE_HPP__
+
+#include <mesos/v1/mesos.hpp>
+
+#include <process/future.hpp>
+#include <process/http.hpp>
+
+#include <stout/option.hpp>
+
+namespace mesos {
+namespace http {
+namespace authentication {
+
+/**
+ * An abstraction enabling any HTTP API consumer to authenticate.
+ */
+class Authenticatee
+{
+public:
+  virtual ~Authenticatee() = default;
+
+  /**
+   * Reset the authenticatee to its initial state.
+   *
+   * Allows the implementation to invalidate possibly cached state.
+   * This is useful if for example token-based authentication is
+   * performed and the authenticator signaled an expired token.
+   */
+  virtual void reset() {};
+
+  /**
+   * Name of the authentication scheme implemented.
+   *
+   * @return Authentication scheme.
+   */
+  virtual std::string scheme() const = 0;
+
+  /**
+   * Create an HTTP request for authentication.
+   *
+   * Used for mutating a provided `Request` with any means of
+   * authentication-related headers or other additions and changes.
+   *
+   * @param request The HTTP payload intended to be sent to an
+   *     authenticated endpoint.
+   * @param credential The principal and secret optionally used to
+   *     create the authentication request.
+   * @return The mutated HTTP request object containing all information
+   *     needed for authenticating.
+   */
+  virtual process::Future<process::http::Request> authenticate(
+      const process::http::Request& request,
+      const Option<mesos::v1::Credential>& credential) = 0;
+};
+
+} // namespace authentication {
+} // namespace http {
+} // namespace mesos {
+
+#endif // __MESOS_AUTHENTICATION_HTTP_AUTHENTICATEE_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/185b64fa/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index da8af91..edfc16d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -627,13 +627,18 @@ authentication_HEADERS =						\
   $(top_srcdir)/include/mesos/authentication/authentication.hpp		\
   $(top_srcdir)/include/mesos/authentication/authentication.proto	\
   $(top_srcdir)/include/mesos/authentication/authenticator.hpp		\
-  $(top_srcdir)/include/mesos/authentication/secret_generator.hpp	\
-  $(top_srcdir)/include/mesos/authentication/http/basic_authenticator_factory.hpp	\
-  $(top_srcdir)/include/mesos/authentication/http/combined_authenticator.hpp
+  $(top_srcdir)/include/mesos/authentication/secret_generator.hpp
 
 nodist_authentication_HEADERS =						\
   ../include/mesos/authentication/authentication.pb.h
 
+httpauthenticationdir = $(pkgincludedir)/authentication/http
+
+httpauthentication_HEADERS =						\
+  $(top_srcdir)/include/mesos/authentication/http/authenticatee.hpp	\
+  $(top_srcdir)/include/mesos/authentication/http/basic_authenticator_factory.hpp	\
+  $(top_srcdir)/include/mesos/authentication/http/combined_authenticator.hpp
+
 authorizerdir = $(pkgincludedir)/authorizer
 
 authorizer_HEADERS =							\