- Notifications
You must be signed in to change notification settings - Fork4.9k
Commita99a32e
committed
libpq: Handle asynchronous actions during SASL
This adds the ability for a SASL mechanism to signal PQconnectPoll()that some arbitrary work, external to the Postgres connection, isrequired for authentication to continue. There is no consumer forthis capability as part of this commit, it is infrastructure whichis required for future work on supporting the OAUTHBEARER mechanism.To ensure that threads are not blocked waiting for the SASL mechanismto make long-running calls, the mechanism communicates with the top-level client via the "altsock": a file or socket descriptor, opaque tothis layer of libpq, which is signaled when work is ready to be doneagain. The altsock temporarily replaces the regular connectiondescriptor, so existing PQsocket() clients should continue to operatecorrectly using their existing polling implementations.For a mechanism to use this it should set an authentication callback,conn->async_auth(), and a cleanup callback, conn->cleanup_async_auth(),and return SASL_ASYNC during the exchange. It should then assignconn->altsock during the first call to async_auth(). When the cleanupcallback is called, either because authentication has succeeded orbecause the connection is being dropped, the altsock must be releasedand disconnected from the PGconn object.This was extracted from the larger OAUTHBEARER patchset which hasbeen developed, and reviewed by many, over several years and it isthus likely that some reviewer credit of much earlier versions hasbeen accidentally omitted.Author: Jacob Champion <jacob.champion@enterprisedb.com>Reviewed-by: Daniel Gustafsson <daniel@yesql.se>Reviewed-by: Peter Eisentraut <peter@eisentraut.org>Reviewed-by: Antonin Houska <ah@cybertec.at>Discussion:https://postgr.es/m/CAOYmi+kJqzo6XsR9TEhvVfeVNQ-TyFM5LATypm9yoQVYk=4Wrw@mail.gmail.com1 parent44ec095 commita99a32e
File tree
8 files changed
+227
-49
lines changed- src/interfaces/libpq
8 files changed
+227
-49
lines changedLines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
| 33 | + | |
33 | 34 |
| |
34 | 35 |
| |
35 | 36 |
| |
| |||
77 | 78 |
| |
78 | 79 |
| |
79 | 80 |
| |
| 81 | + | |
| 82 | + | |
80 | 83 |
| |
81 | 84 |
| |
82 | 85 |
| |
| |||
101 | 104 |
| |
102 | 105 |
| |
103 | 106 |
| |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
104 | 112 |
| |
105 | 113 |
| |
106 | 114 |
| |
107 | 115 |
| |
108 | 116 |
| |
109 |
| - | |
| 117 | + | |
| 118 | + | |
110 | 119 |
| |
111 | 120 |
| |
112 | 121 |
| |
|
Lines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
24 | 24 |
| |
25 | 25 |
| |
26 | 26 |
| |
27 |
| - | |
| 27 | + | |
| 28 | + | |
28 | 29 |
| |
29 | 30 |
| |
30 | 31 |
| |
| |||
205 | 206 |
| |
206 | 207 |
| |
207 | 208 |
| |
208 |
| - | |
| 209 | + | |
| 210 | + | |
209 | 211 |
| |
210 | 212 |
| |
211 | 213 |
| |
|
Lines changed: 89 additions & 31 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
430 | 430 |
| |
431 | 431 |
| |
432 | 432 |
| |
433 |
| - | |
| 433 | + | |
434 | 434 |
| |
435 | 435 |
| |
436 | 436 |
| |
| |||
448 | 448 |
| |
449 | 449 |
| |
450 | 450 |
| |
451 |
| - | |
| 451 | + | |
452 | 452 |
| |
453 | 453 |
| |
454 | 454 |
| |
| |||
607 | 607 |
| |
608 | 608 |
| |
609 | 609 |
| |
610 |
| - | |
611 |
| - | |
612 |
| - | |
613 |
| - | |
614 |
| - | |
615 |
| - | |
616 |
| - | |
617 |
| - | |
618 |
| - | |
619 | 610 |
| |
620 |
| - | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
621 | 633 |
| |
622 | 634 |
| |
623 |
| - | |
| 635 | + | |
624 | 636 |
| |
625 | 637 |
| |
626 | 638 |
| |
627 | 639 |
| |
628 | 640 |
| |
629 | 641 |
| |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
630 | 658 |
| |
631 | 659 |
| |
632 | 660 |
| |
| |||
671 | 699 |
| |
672 | 700 |
| |
673 | 701 |
| |
674 |
| - | |
| 702 | + | |
675 | 703 |
| |
676 | 704 |
| |
677 | 705 |
| |
| |||
701 | 729 |
| |
702 | 730 |
| |
703 | 731 |
| |
704 |
| - | |
| 732 | + | |
705 | 733 |
| |
706 | 734 |
| |
707 | 735 |
| |
708 | 736 |
| |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
709 | 751 |
| |
710 | 752 |
| |
711 | 753 |
| |
| |||
1013 | 1055 |
| |
1014 | 1056 |
| |
1015 | 1057 |
| |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
1016 | 1062 |
| |
1017 | 1063 |
| |
1018 |
| - | |
| 1064 | + | |
1019 | 1065 |
| |
1020 | 1066 |
| |
1021 | 1067 |
| |
| 1068 | + | |
| 1069 | + | |
1022 | 1070 |
| |
1023 | 1071 |
| |
1024 | 1072 |
| |
| |||
1176 | 1224 |
| |
1177 | 1225 |
| |
1178 | 1226 |
| |
1179 |
| - | |
| 1227 | + | |
1180 | 1228 |
| |
1181 | 1229 |
| |
1182 | 1230 |
| |
| |||
1185 | 1233 |
| |
1186 | 1234 |
| |
1187 | 1235 |
| |
1188 |
| - | |
1189 | 1236 |
| |
1190 |
| - | |
1191 |
| - | |
1192 |
| - | |
1193 |
| - | |
1194 |
| - | |
1195 |
| - | |
1196 |
| - | |
1197 |
| - | |
1198 |
| - | |
1199 |
| - | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
1200 | 1241 |
| |
1201 |
| - | |
1202 |
| - | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
1203 | 1262 |
| |
1204 |
| - | |
1205 | 1263 |
| |
1206 | 1264 |
| |
1207 | 1265 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
22 |
| - | |
| 22 | + | |
| 23 | + | |
23 | 24 |
| |
24 | 25 |
| |
25 | 26 |
| |
|
0 commit comments
Comments
(0)