Added the SecretGenerator module interface. This interface will be used by agents to create credentials for the default executor.
Review: https://reviews.apache.org/r/56757/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/686733dd Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/686733dd Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/686733dd Branch: refs/heads/master Commit: 686733dd7b97b2d0623eabbb49242d4900baa523 Parents: b4a1603 Author: Jan Schlicht <j...@mesosphere.io> Authored: Mon Mar 13 16:46:09 2017 +0100 Committer: Vinod Kone <vinodk...@gmail.com> Committed: Mon Mar 13 16:46:09 2017 +0100 ---------------------------------------------------------------------- .../mesos/authentication/secret_generator.hpp | 49 +++++++++++++++ include/mesos/module/secret_generator.hpp | 64 ++++++++++++++++++++ src/Makefile.am | 4 +- 3 files changed, 116 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/686733dd/include/mesos/authentication/secret_generator.hpp ---------------------------------------------------------------------- diff --git a/include/mesos/authentication/secret_generator.hpp b/include/mesos/authentication/secret_generator.hpp new file mode 100644 index 0000000..f2fb0e7 --- /dev/null +++ b/include/mesos/authentication/secret_generator.hpp @@ -0,0 +1,49 @@ +// 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_SECRET_GENERATOR_HPP__ +#define __MESOS_AUTHENTICATION_SECRET_GENERATOR_HPP__ + +#include <mesos/mesos.hpp> + +#include <process/future.hpp> +#include <process/http.hpp> + +namespace mesos { +namespace http { +namespace authentication { + +/** + * The SecretGenerator interface represents a mechanism to create a secret + * from a principal. The secret is meant to contain a token (for example, + * an HTTP 'Authorization' header) that can be used to authenticate. If + * used that way, an authenticator will yield the same principal that + * was passed to the `generate` method of this module. + */ +class SecretGenerator +{ +public: + virtual ~SecretGenerator() {} + + virtual process::Future<Secret> generate( + const process::http::authentication::Principal& principal) = 0; +}; + +} // namespace authentication { +} // namespace http { +} // namespace mesos { + +#endif // __MESOS_AUTHENTICATION_SECRET_GENERATOR_HPP__ http://git-wip-us.apache.org/repos/asf/mesos/blob/686733dd/include/mesos/module/secret_generator.hpp ---------------------------------------------------------------------- diff --git a/include/mesos/module/secret_generator.hpp b/include/mesos/module/secret_generator.hpp new file mode 100644 index 0000000..c8b7d8c --- /dev/null +++ b/include/mesos/module/secret_generator.hpp @@ -0,0 +1,64 @@ +// 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_MODULE_SECRET_GENERATOR_HPP__ +#define __MESOS_MODULE_SECRET_GENERATOR_HPP__ + +#include <mesos/mesos.hpp> +#include <mesos/module.hpp> + +#include <mesos/authentication/secret_generator.hpp> + +namespace mesos { +namespace modules { + +template <> +inline const char* kind<mesos::http::authentication::SecretGenerator>() +{ + return "SecretGenerator"; +} + + +template <> +struct Module<mesos::http::authentication::SecretGenerator> : ModuleBase +{ + Module( + const char* _moduleApiVersion, + const char* _mesosVersion, + const char* _authorName, + const char* _authorEmail, + const char* _description, + bool (*_compatible)(), + mesos::http::authentication::SecretGenerator* (*_create)( + const Parameters& parameters)) + : ModuleBase( + _moduleApiVersion, + _mesosVersion, + mesos::modules::kind<mesos::http::authentication::SecretGenerator>(), + _authorName, + _authorEmail, + _description, + _compatible), + create(_create) {} + + mesos::http::authentication::SecretGenerator* (*create)( + const Parameters& parameters); +}; + +} // namespace modules { +} // namespace mesos { + +#endif // __MESOS_MODULE_SECRET_GENERATOR_HPP__ http://git-wip-us.apache.org/repos/asf/mesos/blob/686733dd/src/Makefile.am ---------------------------------------------------------------------- diff --git a/src/Makefile.am b/src/Makefile.am index bb917c5..9be578b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -560,6 +560,7 @@ 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 nodist_authentication_HEADERS = \ @@ -653,7 +654,8 @@ module_HEADERS = \ $(top_srcdir)/include/mesos/module/qos_controller.hpp \ $(top_srcdir)/include/mesos/module/resource_estimator.hpp \ $(top_srcdir)/include/mesos/module/contender.hpp \ - $(top_srcdir)/include/mesos/module/detector.hpp + $(top_srcdir)/include/mesos/module/detector.hpp \ + $(top_srcdir)/include/mesos/module/secret_generator.hpp nodist_module_HEADERS = \ ../include/mesos/module/hook.pb.h \