forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit491c029
committed
Row-Level Security Policies (RLS)
Building on the updatable security-barrier views work, add theability to define policies on tables to limit the set of rowswhich are returned from a query and which are allowed to be addedto a table. Expressions defined by the policy for filtering areadded to the security barrier quals of the query, while expressionsdefined to check records being added to a table are added to thewith-check options of the query.New top-level commands are CREATE/ALTER/DROP POLICY and arecontrolled by the table owner. Row Security is able to be enabledand disabled by the owner on a per-table basis usingALTER TABLE .. ENABLE/DISABLE ROW SECURITY.Per discussion, ROW SECURITY is disabled on tables by default andmust be enabled for policies on the table to be used. If nopolicies exist on a table with ROW SECURITY enabled, a default-denypolicy is used and no records will be visible.By default, row security is applied at all times except for thetable owner and the superuser. A new GUC, row_security, is addedwhich can be set to ON, OFF, or FORCE. When set to FORCE, rowsecurity will be applied even for the table owner and superusers.When set to OFF, row security will be disabled when allowed and anerror will be thrown if the user does not have rights to bypass rowsecurity.Per discussion, pg_dump sets row_security = OFF by default to ensurethat exports and backups will have all data in the table or willerror if there are insufficient privileges to bypass row security.A new option has been added to pg_dump, --enable-row-security, toask pg_dump to export with row security enabled.A new role capability, BYPASSRLS, which can only be set by thesuperuser, is added to allow other users to be able to bypass rowsecurity using row_security = OFF.Many thanks to the various individuals who have helped with thedesign, particularly Robert Haas for his feedback.Authors include Craig Ringer, KaiGai Kohei, Adam Brightwell, DeanRasheed, with additional changes and rework by me.Reviewers have included all of the above, Greg Smith,Jeff McCormick, and Robert Haas.1 parente5603a2 commit491c029
File tree
82 files changed
+7279
-152
lines changed- doc/src/sgml
- ref
- src
- backend
- catalog
- commands
- executor
- nodes
- optimizer/plan
- parser
- rewrite
- tcop
- utils
- adt
- cache
- misc
- bin
- pg_dump
- psql
- include
- catalog
- commands
- nodes
- optimizer
- parser
- rewrite
- utils
- test/regress
- expected
- sql
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
82 files changed
+7279
-152
lines changedLines changed: 100 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
238 | 238 |
| |
239 | 239 |
| |
240 | 240 |
| |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
241 | 246 |
| |
242 | 247 |
| |
243 | 248 |
| |
| |||
1935 | 1940 |
| |
1936 | 1941 |
| |
1937 | 1942 |
| |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
1938 | 1952 |
| |
1939 | 1953 |
| |
1940 | 1954 |
| |
| |||
5328 | 5342 |
| |
5329 | 5343 |
| |
5330 | 5344 |
| |
| 5345 | + | |
| 5346 | + | |
| 5347 | + | |
| 5348 | + | |
| 5349 | + | |
| 5350 | + | |
| 5351 | + | |
| 5352 | + | |
| 5353 | + | |
| 5354 | + | |
| 5355 | + | |
| 5356 | + | |
| 5357 | + | |
| 5358 | + | |
| 5359 | + | |
| 5360 | + | |
| 5361 | + | |
| 5362 | + | |
| 5363 | + | |
| 5364 | + | |
| 5365 | + | |
| 5366 | + | |
| 5367 | + | |
| 5368 | + | |
| 5369 | + | |
| 5370 | + | |
| 5371 | + | |
| 5372 | + | |
| 5373 | + | |
| 5374 | + | |
| 5375 | + | |
| 5376 | + | |
| 5377 | + | |
| 5378 | + | |
| 5379 | + | |
| 5380 | + | |
| 5381 | + | |
| 5382 | + | |
| 5383 | + | |
| 5384 | + | |
| 5385 | + | |
| 5386 | + | |
| 5387 | + | |
| 5388 | + | |
| 5389 | + | |
| 5390 | + | |
| 5391 | + | |
| 5392 | + | |
| 5393 | + | |
| 5394 | + | |
| 5395 | + | |
| 5396 | + | |
| 5397 | + | |
| 5398 | + | |
| 5399 | + | |
| 5400 | + | |
| 5401 | + | |
| 5402 | + | |
| 5403 | + | |
| 5404 | + | |
| 5405 | + | |
| 5406 | + | |
| 5407 | + | |
| 5408 | + | |
| 5409 | + | |
| 5410 | + | |
| 5411 | + | |
| 5412 | + | |
| 5413 | + | |
| 5414 | + | |
| 5415 | + | |
| 5416 | + | |
| 5417 | + | |
| 5418 | + | |
| 5419 | + | |
| 5420 | + | |
| 5421 | + | |
| 5422 | + | |
| 5423 | + | |
| 5424 | + | |
5331 | 5425 |
| |
5332 | 5426 |
| |
5333 | 5427 |
| |
| |||
9133 | 9227 |
| |
9134 | 9228 |
| |
9135 | 9229 |
| |
| 9230 | + | |
| 9231 | + | |
| 9232 | + | |
| 9233 | + | |
| 9234 | + | |
| 9235 | + | |
9136 | 9236 |
| |
9137 | 9237 |
| |
9138 | 9238 |
| |
|
Lines changed: 40 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5429 | 5429 |
| |
5430 | 5430 |
| |
5431 | 5431 |
| |
| 5432 | + | |
| 5433 | + | |
| 5434 | + | |
| 5435 | + | |
| 5436 | + | |
| 5437 | + | |
| 5438 | + | |
| 5439 | + | |
| 5440 | + | |
| 5441 | + | |
| 5442 | + | |
| 5443 | + | |
| 5444 | + | |
| 5445 | + | |
| 5446 | + | |
| 5447 | + | |
| 5448 | + | |
| 5449 | + | |
| 5450 | + | |
| 5451 | + | |
| 5452 | + | |
| 5453 | + | |
| 5454 | + | |
| 5455 | + | |
| 5456 | + | |
| 5457 | + | |
| 5458 | + | |
| 5459 | + | |
| 5460 | + | |
| 5461 | + | |
| 5462 | + | |
| 5463 | + | |
| 5464 | + | |
| 5465 | + | |
| 5466 | + | |
| 5467 | + | |
| 5468 | + | |
| 5469 | + | |
| 5470 | + | |
| 5471 | + | |
5432 | 5472 |
| |
5433 | 5473 |
| |
5434 | 5474 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
195 | 195 |
| |
196 | 196 |
| |
197 | 197 |
| |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
198 | 204 |
| |
199 | 205 |
| |
200 | 206 |
| |
| |||
351 | 357 |
| |
352 | 358 |
| |
353 | 359 |
| |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
354 | 366 |
| |
355 | 367 |
| |
356 | 368 |
| |
| |||
525 | 537 |
| |
526 | 538 |
| |
527 | 539 |
| |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
528 | 546 |
| |
529 | 547 |
| |
530 | 548 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3422 | 3422 |
| |
3423 | 3423 |
| |
3424 | 3424 |
| |
| 3425 | + | |
| 3426 | + | |
| 3427 | + | |
| 3428 | + | |
| 3429 | + | |
| 3430 | + | |
| 3431 | + | |
3425 | 3432 |
| |
3426 | 3433 |
| |
3427 | 3434 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
| 28 | + | |
28 | 29 |
| |
29 | 30 |
| |
30 | 31 |
| |
| |||
69 | 70 |
| |
70 | 71 |
| |
71 | 72 |
| |
| 73 | + | |
72 | 74 |
| |
73 | 75 |
| |
74 | 76 |
| |
| |||
110 | 112 |
| |
111 | 113 |
| |
112 | 114 |
| |
| 115 | + | |
113 | 116 |
| |
114 | 117 |
| |
115 | 118 |
| |
|
Lines changed: 135 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + |
0 commit comments
Comments
(0)