17 #ifndef __COMMON_HTTP_HPP__
18 #define __COMMON_HTTP_HPP__
78 const google::protobuf::Message& message);
83 template <
typename Message>
86 const std::string& body)
88 switch (contentType) {
91 if (!message.ParseFromString(body)) {
92 return Error(
"Failed to parse body into a protobuf object");
99 return Error(
"Failed to parse body into JSON: " + value.
error());
102 return ::protobuf::parse<Message>(value.
get());
105 return Error(
"Deserializing a RecordIO stream is not supported");
141 namespace authorization {
174 const authorization::Action& action);
176 template <
typename... Args>
182 LOG(WARNING) <<
"Error during authorization: " << approved.
error();
186 return approved.
get();
205 template <
typename T>
213 targetId_.set_value(
id.
get());
214 targetId = targetId_;
218 bool accept(
const T& candidateId)
const
220 if (targetId.isNone()) {
224 return candidateId.value() == targetId->value();
234 const FrameworkInfo& frameworkInfo);
239 const ExecutorInfo& executorInfo,
240 const FrameworkInfo& frameworkInfo);
245 const TaskInfo& taskInfo,
246 const FrameworkInfo& frameworkInfo);
252 const FrameworkInfo& frameworkInfo);
266 const std::string& endpoint,
267 const std::string& method,
274 const std::string& role);
281 const Resource& resource,
298 const std::string& realm,
299 const std::vector<std::string>& httpAuthenticatorNames,
310 #endif // __COMMON_HTTP_HPP__
bool approveViewTask(const process::Owned< ObjectApprover > &tasksApprover, const Task &task, const FrameworkInfo &frameworkInfo)
ContentType
Definition: http.hpp:43
Definition: errorbase.hpp:35
virtual Try< bool > approved(const Option< ObjectApprover::Object > &object) const noexceptoverride
NOTE: As this function can be used synchronously by actors it is essential that it does not block! ...
Definition: http.hpp:159
Future< Response > request(const Request &request, bool streamedResponse=false)
Asynchronously sends an HTTP request to the process and returns the HTTP response once the entire res...
const Option< authorization::Subject > createSubject(const Option< process::http::authentication::Principal > &principal)
Definition: authorizer.hpp:46
bool streamingMediaType(ContentType contentType)
const process::Owned< ObjectApprover > objectApprover
Definition: http.hpp:196
bool accept(Args &...args)
Definition: http.hpp:177
constexpr char DEFAULT_BASIC_HTTP_AUTHENTICATEE[]
Definition: http.hpp:52
Result< ProcessStatus > status(pid_t pid)
Definition: proc.hpp:166
Definition: resources.hpp:79
Definition: hashmap.hpp:38
constexpr char DEFAULT_JWT_HTTP_AUTHENTICATOR[]
Definition: http.hpp:55
This interface is used to enable an identity service or any other back end to check authorization pol...
Definition: authorizer.hpp:243
void logRequest(const process::http::Request &request)
Used to filter results for API handlers.
Definition: http.hpp:206
Try< Message > deserialize(ContentType contentType, const std::string &body)
Definition: http.hpp:84
bool approveViewExecutorInfo(const process::Owned< ObjectApprover > &executorsApprover, const ExecutorInfo &executorInfo, const FrameworkInfo &frameworkInfo)
bool approveViewFlags(const process::Owned< ObjectApprover > &flagsApprover)
JSON::Object model(const Resources &resources)
void json(JSON::ObjectWriter *writer, const Task &task)
Definition: jsonify.hpp:418
Option< Error > quotaInfo(const mesos::quota::QuotaInfo "aInfo)
hashset< std::string > AUTHORIZABLE_ENDPOINTS
Try< Value > parse(const std::string &s)
Returns the OCI v1 descriptor, image index, image manifest and image configuration from the given str...
Definition: json.hpp:884
Try< int_fd > accept(int_fd s)
Definition: network.hpp:31
static Try error(const E &e)
Definition: try.hpp:42
Try< Nothing > initializeHttpAuthenticators(const std::string &realm, const std::vector< std::string > &httpAuthenticatorNames, const Option< Credentials > &credentials=None(), const Option< std::string > &jwtSecretKey=None())
Helper function to create HTTP authenticators for a given realm and register in libprocess.
#define UNREACHABLE()
Definition: unreachable.hpp:22
void json(JSON::ObjectWriter *writer, const Attributes &attributes)
const process::http::authorization::AuthorizationCallbacks createAuthorizationCallbacks(Authorizer *authorizer)
constexpr char DEFAULT_BASIC_HTTP_AUTHENTICATOR[]
Definition: http.hpp:49
bool authorizeResource(const Resource &resource, const Option< process::Owned< AuthorizationAcceptor >> &acceptor)
bool approveViewFrameworkInfo(const process::Owned< ObjectApprover > &frameworksApprover, const FrameworkInfo &frameworkInfo)
bool isError() const
Definition: try.hpp:71
bool approveViewRole(const process::Owned< ObjectApprover > &rolesApprover, const std::string &role)
std::string serialize(ContentType contentType, const google::protobuf::Message &message)
process::Future< bool > authorizeEndpoint(const std::string &endpoint, const std::string &method, const Option< Authorizer * > &authorizer, const Option< process::http::authentication::Principal > &principal)
This interface represents a function object returned by the authorizer which can be used locally (and...
Definition: authorizer.hpp:40
const T & get() const
Definition: try.hpp:73
static process::Future< process::Owned< AuthorizationAcceptor > > create(const Option< process::http::authentication::Principal > &principal, const Option< Authorizer * > &authorizer, const authorization::Action &action)
AuthorizationAcceptor(const process::Owned< ObjectApprover > &approver)
Definition: http.hpp:193
bool approveViewTaskInfo(const process::Owned< ObjectApprover > &tasksApprover, const TaskInfo &taskInfo, const FrameworkInfo &frameworkInfo)
Definition: jsonify.hpp:384
Definition: future.hpp:57
Definition: attributes.hpp:32