mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-08-13 21:06:07 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0261f121e8 | ||
|
|
93dc1008ee |
@@ -912,8 +912,20 @@ func (p *DatabaseRowSecurityProvider) GetRowSecurity(ctx context.Context, userRe
|
||||
return RowSecurity{}, ErrDirectModeUnsupported
|
||||
}
|
||||
|
||||
var template string
|
||||
var hasBlock bool
|
||||
// resolvespec_row_security's p_user_id is a scalar integer. GetUserRef() may
|
||||
// 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 {
|
||||
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,
|
||||
Tablename: table,
|
||||
UserID: userRef,
|
||||
Template: template,
|
||||
HasBlock: hasBlock,
|
||||
Template: template.String,
|
||||
HasBlock: hasBlock.Bool,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user