feat: add runtime override for ACL enabled flag in security handler

This commit is contained in:
GitHub Actions
2025-12-01 02:17:38 +00:00
parent b45ac58f10
commit 5717941d45

View File

@@ -63,6 +63,19 @@ func (h *SecurityHandler) GetStatus(c *gin.Context) {
apiURL = ""
}
// Allow runtime override for ACL enabled flag via settings table
aclEnabled := h.cfg.ACLMode == "enabled"
if h.db != nil {
var a struct{ Value string }
if err := h.db.Raw("SELECT value FROM settings WHERE key = ? LIMIT 1", "security.acl.enabled").Scan(&a).Error; err == nil {
if strings.EqualFold(a.Value, "true") {
aclEnabled = true
} else if strings.EqualFold(a.Value, "false") {
aclEnabled = false
}
}
}
c.JSON(http.StatusOK, gin.H{
"cerberus": gin.H{"enabled": enabled},
"crowdsec": gin.H{
@@ -80,7 +93,7 @@ func (h *SecurityHandler) GetStatus(c *gin.Context) {
},
"acl": gin.H{
"mode": h.cfg.ACLMode,
"enabled": h.cfg.ACLMode == "enabled",
"enabled": aclEnabled,
},
})
}