Apache Mesos
authentication.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License
16 
17 #ifndef __MESOS_ZOOKEEPER_AUTHENTICATION_HPP__
18 #define __MESOS_ZOOKEEPER_AUTHENTICATION_HPP__
19 
20 #include <zookeeper.h>
21 
22 #ifdef __WINDOWS__
23 // NOTE: We need to undefine this macro to prevent it from bleeding
24 // into our code and thereby break compilation of our namespaced ACLs.
25 // This macro is defined in zookeeper/src/c/include/winconfig.h.
26 #undef ACL
27 #endif // __WINDOWS__
28 
29 #include <string>
30 
31 #include <glog/logging.h>
32 
33 namespace zookeeper {
34 
36 {
38  const std::string& _scheme,
39  const std::string& _credentials)
40  : scheme(_scheme),
41  credentials(_credentials)
42  {
43  // TODO(benh): Fix output operator below once this changes.
44  CHECK_EQ(scheme, "digest") << "Unsupported authentication scheme";
45  }
46 
47  const std::string scheme;
48  const std::string credentials;
49 };
50 
51 
52 // An ACL that ensures we're the only authenticated user to mutate our
53 // nodes - others are welcome to read.
54 extern const ACL_vector EVERYONE_READ_CREATOR_ALL;
55 
56 // An ACL that allows others to create child nodes and read nodes, but
57 // we're the only authenticated user to mutate our nodes.
58 extern const ACL_vector EVERYONE_CREATE_AND_READ_CREATOR_ALL;
59 
60 
61 inline std::ostream& operator<<(
62  std::ostream& stream,
63  const Authentication& authentication)
64 {
65  // TODO(benh): Fix this once we support more than just 'digest'.
66  CHECK_EQ(authentication.scheme, "digest");
67  return stream << authentication.credentials;
68 }
69 
70 } // namespace zookeeper {
71 
72 #endif // __MESOS_ZOOKEEPER_AUTHENTICATION_HPP__
std::ostream & operator<<(std::ostream &stream, const Authentication &authentication)
Definition: authentication.hpp:61
const std::string credentials
Definition: authentication.hpp:48
Definition: authentication.hpp:33
Definition: authentication.hpp:35
const ACL_vector EVERYONE_READ_CREATOR_ALL
const ACL_vector EVERYONE_CREATE_AND_READ_CREATOR_ALL
const std::string scheme
Definition: authentication.hpp:47
Authentication(const std::string &_scheme, const std::string &_credentials)
Definition: authentication.hpp:37