Bird
0
0

Which policy condition correctly enforces this?

hard📝 Application Q8 of 15
PostgreSQL - Roles and Security
You want to allow users to SELECT rows from tasks table only if they are assigned to the task or if they are an admin. The tasks table has columns assigned_user and is_admin (boolean). Which policy condition correctly enforces this?
AUSING (assigned_user = current_user)
BUSING (assigned_user = current_user AND is_admin = true)
CUSING (is_admin = true)
DUSING (assigned_user = current_user OR is_admin = true)
Step-by-Step Solution
Solution:
  1. Step 1: Understand access requirements

    Users can access rows if assigned_user matches or if they are admin.
  2. Step 2: Translate to condition

    Condition must allow either assigned_user = current_user OR is_admin = true.
  3. Final Answer:

    USING (assigned_user = current_user OR is_admin = true) -> Option D
  4. Quick Check:

    Use OR to allow either condition = USING (assigned_user = current_user OR is_admin = true) [OK]
Quick Trick: Use OR to combine multiple access conditions in policy. [OK]
Common Mistakes:
  • Using AND instead of OR
  • Allowing only assigned_user without admin check
  • Allowing only admin without assigned_user

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes