Apache Guacamole TOTP 是一个开源的认证模块,它使用时间基础一次性密码(TOTP)来增强用户安全性。如需启用 TOTP 验证,可以在 Guacamole 连接中启用此模块,但日志中仅记录了通用日志消息,包括 TOTP 认证事件的成功或失败。 为确保实现安全性审计,可以轻松地增强 Guacamole TOTP 日志记录,将其与日志监控工具集成,并记录 TOTP 令牌的使用历史记录、异常行为和非法访问尝试。
以下是一个示例,用于记录 TOTP 认证成功和失败事件的指定日志记录器方法:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
public class TOTPLoggingHandler {
private static final Logger logger = LoggerFactory.getLogger("CUSTOM_TOTP_LOGGER");
public void logSuccess(String username) {
logger.info("TOTP authentication successful for user {}", username);
}
public void logFailure(String username) {
logger.info("TOTP authentication failed for user {}", username);
}
}
在完成 Guacamole TOTP 模块的安装和配置后,您只需创建 TOTPLoggingHandler Bean,并将其注入 Guacamole 配置文件中的身份验证模块即可:
authentication-provider: org.apache.guacamole.net.auth.authenticateduser.AuthenticatedUserAuthenticationProvider
authentication-provider-parameters: enable-mfa:true,mfa-provider-class:org.apache.guacamole.auth.totp.TOTPAuthenticationProvider,mfa-self-registration:true,mfa-required:true,mfa-handler-bean:tOTPLoggingHandler
然后您可以使用 Elastic Stack 或任何其他日志监控和解析工具来监听和分析记录的 TOTP 日志事件,以及快速自动化响应这些事件。