forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7ac955b
committed
Allow SCRAM authentication, when pg_hba.conf says 'md5'.
If a user has a SCRAM verifier in pg_authid.rolpassword, there's no reasonwe cannot attempt to perform SCRAM authentication instead of MD5. The worstthat can happen is that the client doesn't support SCRAM, and theauthentication will fail. But previously, it would fail for sure, becausewe would not even try. SCRAM is strictly more secure than MD5, so there'sno harm in trying it. This allows for a more graceful transition from MD5passwords to SCRAM, as user passwords can be changed to SCRAM verifiersincrementally, without changing pg_hba.conf.Refactor the code in auth.c to support that better. Notably, we now have tolook up the user's pg_authid entry before sending the password challenge,also when performing MD5 authentication. Also simplify the concept of a"doomed" authentication. Previously, if a user had a password, but it hadexpired, we still performed SCRAM authentication (but always returned errorat the end) using the salt and iteration count from the expired password.Now we construct a fake salt, like we do when the user doesn't have apassword or doesn't exist at all. That simplifies get_role_password(), andwe can don't need to distinguish the "user has expired password", and"user does not exist" cases in auth.c.On second thoughts, also rename uaSASL to uaSCRAM. It refers to themechanism specified in pg_hba.conf, and while we use SASL for SCRAMauthentication at the protocol level, the mechanism should be called SCRAM,not SASL. As a comparison, we have uaLDAP, even though it looks like theplain 'password' authentication at the protocol level.Discussion:https://www.postgresql.org/message-id/6425.1489506016@sss.pgh.pa.usReviewed-by: Michael Paquier1 parent7887453 commit7ac955b
File tree
9 files changed
+214
-165
lines changed- doc/src/sgml
- src
- backend/libpq
- include/libpq
- test/authentication/t
9 files changed
+214
-165
lines changedLines changed: 18 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
412 | 412 |
| |
413 | 413 |
| |
414 | 414 |
| |
415 |
| - | |
| 415 | + | |
416 | 416 |
| |
417 | 417 |
| |
418 |
| - | |
419 |
| - | |
420 |
| - | |
| 418 | + | |
| 419 | + | |
421 | 420 |
| |
422 | 421 |
| |
423 | 422 |
| |
424 | 423 |
| |
425 | 424 |
| |
426 |
| - | |
| 425 | + | |
427 | 426 |
| |
428 | 427 |
| |
429 |
| - | |
430 |
| - | |
431 |
| - | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
432 | 431 |
| |
433 | 432 |
| |
434 | 433 |
| |
| |||
689 | 688 |
| |
690 | 689 |
| |
691 | 690 |
| |
692 |
| - | |
693 |
| - | |
694 |
| - | |
695 |
| - | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
696 | 694 |
| |
697 | 695 |
| |
698 |
| - | |
| 696 | + | |
699 | 697 |
| |
700 | 698 |
| |
701 | 699 |
| |
| |||
949 | 947 |
| |
950 | 948 |
| |
951 | 949 |
| |
952 |
| - | |
953 |
| - | |
954 |
| - | |
955 |
| - | |
956 |
| - | |
957 |
| - | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
958 | 957 |
| |
959 | 958 |
| |
960 | 959 |
| |
|
Lines changed: 58 additions & 46 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
130 | 130 |
| |
131 | 131 |
| |
132 | 132 |
| |
133 |
| - | |
134 |
| - | |
135 |
| - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
136 | 136 |
| |
137 | 137 |
| |
138 |
| - | |
| 138 | + | |
139 | 139 |
| |
140 | 140 |
| |
141 |
| - | |
| 141 | + | |
142 | 142 |
| |
143 | 143 |
| |
144 | 144 |
| |
145 | 145 |
| |
146 | 146 |
| |
147 | 147 |
| |
148 |
| - | |
149 |
| - | |
150 |
| - | |
151 |
| - | |
| 148 | + | |
152 | 149 |
| |
| 150 | + | |
| 151 | + | |
| 152 | + | |
153 | 153 |
| |
154 |
| - | |
155 |
| - | |
156 |
| - | |
157 |
| - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
158 | 176 |
| |
159 |
| - | |
160 |
| - | |
161 |
| - | |
162 |
| - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
163 | 186 |
| |
164 | 187 |
| |
165 |
| - | |
166 |
| - | |
| 188 | + | |
| 189 | + | |
167 | 190 |
| |
168 |
| - | |
169 |
| - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
170 | 194 |
| |
171 | 195 |
| |
172 |
| - | |
| 196 | + | |
173 | 197 |
| |
174 |
| - | |
175 |
| - | |
176 | 198 |
| |
177 |
| - | |
178 |
| - | |
179 |
| - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
180 | 202 |
| |
181 |
| - | |
182 |
| - | |
183 |
| - | |
184 |
| - | |
185 |
| - | |
| 203 | + | |
186 | 204 |
| |
187 |
| - | |
188 |
| - | |
189 | 205 |
| |
190 |
| - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
191 | 213 |
| |
192 |
| - | |
193 |
| - | |
194 |
| - | |
195 |
| - | |
196 |
| - | |
197 |
| - | |
198 |
| - | |
199 |
| - | |
200 |
| - | |
201 |
| - | |
202 | 214 |
| |
203 | 215 |
| |
| 216 | + | |
204 | 217 |
| |
205 |
| - | |
206 | 218 |
| |
207 | 219 |
| |
208 | 220 |
| |
|
0 commit comments
Comments
(0)