mirror of https://github.com/Icinga/icinga2.git
AuthenticatedApiUser name refactor
This commit is contained in:
parent
08c6e9bc42
commit
b07471d803
|
@ -689,11 +689,11 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
|
||||||
return ApiActions::CreateResult(404, "Can't find a valid notification for '" + resolved_notification + "'.");
|
return ApiActions::CreateResult(404, "Can't find a valid notification for '" + resolved_notification + "'.");
|
||||||
|
|
||||||
/* Get author */
|
/* Get author */
|
||||||
if (!ActionsHandler::authenticatedApiUser)
|
if (!ActionsHandler::AuthenticatedApiUser)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Can't find API user."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Can't find API user."));
|
||||||
|
|
||||||
cmd->Execute(notification, user, cr, NotificationType::NotificationCustom,
|
cmd->Execute(notification, user, cr, NotificationType::NotificationCustom,
|
||||||
ActionsHandler::authenticatedApiUser->GetName(), "", execMacros, false);
|
ActionsHandler::AuthenticatedApiUser->GetName(), "", execMacros, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
thread_local ApiUser::Ptr ActionsHandler::authenticatedApiUser;
|
thread_local ApiUser::Ptr ActionsHandler::AuthenticatedApiUser;
|
||||||
|
|
||||||
REGISTER_URLHANDLER("/v1/actions", ActionsHandler);
|
REGISTER_URLHANDLER("/v1/actions", ActionsHandler);
|
||||||
|
|
||||||
|
@ -74,9 +74,9 @@ bool ActionsHandler::HandleRequest(
|
||||||
|
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
|
|
||||||
ActionsHandler::authenticatedApiUser = user;
|
ActionsHandler::AuthenticatedApiUser = user;
|
||||||
Defer a ([&]() {
|
Defer a ([]() {
|
||||||
ActionsHandler::authenticatedApiUser = nullptr;
|
ActionsHandler::AuthenticatedApiUser = nullptr;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (params)
|
if (params)
|
||||||
|
|
|
@ -13,7 +13,7 @@ class ActionsHandler final : public HttpHandler
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(ActionsHandler);
|
DECLARE_PTR_TYPEDEFS(ActionsHandler);
|
||||||
|
|
||||||
static thread_local ApiUser::Ptr authenticatedApiUser;
|
static thread_local ApiUser::Ptr AuthenticatedApiUser;
|
||||||
|
|
||||||
bool HandleRequest(
|
bool HandleRequest(
|
||||||
AsioTlsStream& stream,
|
AsioTlsStream& stream,
|
||||||
|
|
Loading…
Reference in New Issue