Compare commits

...
2 Commits
Author SHA1 Message Date
warkanum 0261f121e8 fix(security): change types for template and hasBlock
Tests / Unit Tests (push) Failing after 19s
Tests / Integration Tests (push) Failing after 30s
Build , Vet Test, and Lint / Run Vet Tests (1.23.x) (push) Failing after 39s
Build , Vet Test, and Lint / Lint Code (push) Successful in 3m45s
Build , Vet Test, and Lint / Run Vet Tests (1.24.x) (push) Successful in 3m47s
Build , Vet Test, and Lint / Build (push) Successful in 3m47s
2026-08-10 20:46:40 +02:00
warkanum 93dc1008ee fix(security): unwrap userRef for non-DB providers 2026-08-10 20:34:06 +02:00
+16 -4
View File
@@ -912,8 +912,20 @@ func (p *DatabaseRowSecurityProvider) GetRowSecurity(ctx context.Context, userRe
return RowSecurity{}, ErrDirectModeUnsupported return RowSecurity{}, ErrDirectModeUnsupported
} }
var template string // resolvespec_row_security's p_user_id is a scalar integer. GetUserRef() may
var hasBlock bool // hand back the full *UserContext so non-DB providers can inspect claims;
// unwrap it here before it reaches the SQL args.
switch v := userRef.(type) {
case *UserContext:
if v != nil {
userRef = v.UserID
}
case UserContext:
userRef = v.UserID
}
var template sql.NullString
var hasBlock sql.NullBool
runQuery := func() error { runQuery := func() error {
query := fmt.Sprintf(`SELECT p_template, p_block FROM %s($1, $2, $3)`, p.sqlNames.RowSecurity) query := fmt.Sprintf(`SELECT p_template, p_block FROM %s($1, $2, $3)`, p.sqlNames.RowSecurity)
@@ -933,8 +945,8 @@ func (p *DatabaseRowSecurityProvider) GetRowSecurity(ctx context.Context, userRe
Schema: schema, Schema: schema,
Tablename: table, Tablename: table,
UserID: userRef, UserID: userRef,
Template: template, Template: template.String,
HasBlock: hasBlock, HasBlock: hasBlock.Bool,
}, nil }, nil
} }