fix(security): skip loading security rules if disabled

This commit is contained in:
2026-09-20 15:52:25 +02:00
parent 87eaa9e18c
commit 817b781c88
2 changed files with 12 additions and 0 deletions
+3
View File
@@ -25,6 +25,9 @@ func RegisterSecurityHooks(handler *Handler, securityList *security.SecurityList
// Hook 1: BeforeRead - Load security rules // Hook 1: BeforeRead - Load security rules
handler.Hooks().Register(BeforeRead, func(hookCtx *HookContext) error { handler.Hooks().Register(BeforeRead, func(hookCtx *HookContext) error {
secCtx := newSecurityContext(hookCtx) secCtx := newSecurityContext(hookCtx)
if security.IsModelSecurityDisabled(secCtx) {
return nil
}
return security.LoadSecurityRules(secCtx, securityList) return security.LoadSecurityRules(secCtx, securityList)
}) })
+9
View File
@@ -254,6 +254,15 @@ func ShouldSkipRowSecurity(secCtx SecurityContext, operation string) bool {
return rules.SecurityDisabled || (operation == "read" && rules.CanPublicRead) return rules.SecurityDisabled || (operation == "read" && rules.CanPublicRead)
} }
// IsModelSecurityDisabled reports whether all model-level security processing
// is disabled for the model. This is distinct from ShouldSkipRowSecurity:
// CanPublicRead skips row filtering for reads but must still allow other read
// security, such as column masking, to be loaded.
func IsModelSecurityDisabled(secCtx SecurityContext) bool {
rules, ok := resolveModelRules(secCtx)
return ok && rules.SecurityDisabled
}
// ApplyColumnSecurity is a public wrapper for applyColumnSecurity that accepts a SecurityContext // ApplyColumnSecurity is a public wrapper for applyColumnSecurity that accepts a SecurityContext
// This allows other packages to apply column-level security using the generic interface // This allows other packages to apply column-level security using the generic interface
func ApplyColumnSecurity(secCtx SecurityContext, securityList *SecurityList) error { func ApplyColumnSecurity(secCtx SecurityContext, securityList *SecurityList) error {