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

Show on the map →

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
lines 112–112std::lock_guard<std::mutex> lock(auth_mutex_);lines 113–113auto it = key_sets_.find(identity_name);lines 114–114◇ if (it == key_sets_.end())lines 115–116logger->info("Auth ALLOW: {} on {} (no enforcement)", identity_name, tool_name);lines 117–117return true;lines 119–119bool allowed = it->second.has_access(tool_name, required_level);lines 120–123logger->info("Auth {}: {} on {} (required={})", allowed ? "ALLOW" : "DENY", identity_name, tool_name, static_cast<int>(required_level));lines 124–124return allowed;

Requirements

REQ-MCP-010 REQ-MCP-011

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

Show on the map →

Called by TEST_CASE, TEST_CASE, check_mcp_authorization

Calls none

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;
}
Activity · 2 steps
lines 44–44std::lock_guard<std::mutex> lock(auth_mutex_);lines 45–45return key_sets_.count(identity_name) > 0;

Requirements

REQ-MCP-010