mcp_authorization.cpp¶
src/mcp/mcp_authorization.cpp
@file mcp_authorization.cpp @brief MCPAuthorizationManager implementation.
Owners: @tvanfossen
check_access
bool entropic::MCPAuthorizationManager::check_access(const std::string &identity_name, const std::string &tool_name, MCPAccessLevel required_level) const
Check if a tool call is authorized for an identity.
src/mcp/mcp_authorization.cpp:108
Called by SCENARIO, TEST_CASE, TEST_CASE, check_mcp_authorization, entropic_check_mcp_key
Calls none
Source · 18 lines
bool MCPAuthorizationManager::check_access(
const std::string& identity_name,
const std::string& tool_name,
MCPAccessLevel required_level) const {
std::lock_guard<std::mutex> lock(auth_mutex_);
auto it = key_sets_.find(identity_name);
if (it == key_sets_.end()) {
logger->info("Auth ALLOW: {} on {} (no enforcement)",
identity_name, tool_name);
return true;
}
bool allowed = it->second.has_access(tool_name, required_level);
logger->info("Auth {}: {} on {} (required={})",
allowed ? "ALLOW" : "DENY",
identity_name, tool_name,
static_cast<int>(required_level));
return allowed;
}Activity · 8 steps
Requirements
is_enforced
bool entropic::MCPAuthorizationManager::is_enforced(const std::string &identity_name) const
Check if an identity has authorization enforcement enabled.
src/mcp/mcp_authorization.cpp:42
Source · 5 lines
bool MCPAuthorizationManager::is_enforced(
const std::string& identity_name) const {
std::lock_guard<std::mutex> lock(auth_mutex_);
return key_sets_.count(identity_name) > 0;
}