Commit 326890f
committed
Validate user login capability on each request.
Currently the login capability of a user is only ever checked on initial
sign in, and never again. So if a user logs in, and then the status or
permission level of the user is changed so that the user no longer has
the `allow_course_access` behavior or `login` permission level, then the
user's current session remains valid, and the user may continue to work
in the course (including submitting answers).
This changes that so that those things are checked on each request. So,
for example, if a user is dropped (status changed to "D"), then the next
thing the user tries to do in the course that involves a request to the
server will result in the user being logged out.
This was reported for the Shibboleth authentication module in issue #2827,
but really is an issue for all authentication modules. So this more
generally fixes issue #2827 for all authentication modules.
This has been tested for all functional authentication modules (i.e.,
for all but the `CAS` and `Moodle` authentication modules. If the `CAS`
module is fixed this should work for that as well. I plan to remove the
`Moodle` authentication module in another pull request.
Note that this is done in such a way that no new database queries are
needed. To make this happen the user record is cached in the
`check_user` call, and then can be used any time after that. Future
plans are to take this much further. There are many times in the code
that the database record for the current user is fetched from the
database, and now this cached user record from the current
authentication module could directly be used instead.1 parent 744e06a commit 326890f
3 files changed
+45
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
| 380 | + | |
381 | 381 | | |
382 | | - | |
| 382 | + | |
383 | 383 | | |
384 | 384 | | |
385 | 385 | | |
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
391 | 414 | | |
392 | 415 | | |
393 | 416 | | |
| |||
485 | 508 | | |
486 | 509 | | |
487 | 510 | | |
| 511 | + | |
488 | 512 | | |
489 | 513 | | |
490 | 514 | | |
| |||
494 | 518 | | |
495 | 519 | | |
496 | 520 | | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
| 521 | + | |
511 | 522 | | |
512 | 523 | | |
513 | 524 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
| 265 | + | |
266 | 266 | | |
267 | | - | |
| 267 | + | |
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
| 300 | + | |
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
356 | | - | |
357 | | - | |
| 355 | + | |
358 | 356 | | |
359 | 357 | | |
360 | 358 | | |
| |||
437 | 435 | | |
438 | 436 | | |
439 | 437 | | |
440 | | - | |
| 438 | + | |
441 | 439 | | |
442 | 440 | | |
443 | 441 | | |
| |||
576 | 574 | | |
577 | 575 | | |
578 | 576 | | |
| 577 | + | |
579 | 578 | | |
580 | 579 | | |
581 | 580 | | |
| |||
641 | 640 | | |
642 | 641 | | |
643 | 642 | | |
644 | | - | |
645 | 643 | | |
646 | 644 | | |
647 | 645 | | |
| |||
676 | 674 | | |
677 | 675 | | |
678 | 676 | | |
679 | | - | |
| 677 | + | |
680 | 678 | | |
681 | 679 | | |
682 | | - | |
| 680 | + | |
683 | 681 | | |
684 | 682 | | |
685 | 683 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
| 239 | + | |
240 | 240 | | |
241 | | - | |
242 | | - | |
| 241 | + | |
| 242 | + | |
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
295 | | - | |
296 | | - | |
| 294 | + | |
297 | 295 | | |
298 | | - | |
| 296 | + | |
299 | 297 | | |
300 | 298 | | |
301 | 299 | | |
| |||
416 | 414 | | |
417 | 415 | | |
418 | 416 | | |
| 417 | + | |
419 | 418 | | |
420 | 419 | | |
421 | 420 | | |
| |||
481 | 480 | | |
482 | 481 | | |
483 | 482 | | |
484 | | - | |
485 | 483 | | |
486 | 484 | | |
487 | 485 | | |
| |||
507 | 505 | | |
508 | 506 | | |
509 | 507 | | |
510 | | - | |
| 508 | + | |
511 | 509 | | |
512 | 510 | | |
513 | | - | |
| 511 | + | |
514 | 512 | | |
515 | 513 | | |
516 | 514 | | |
| |||
0 commit comments