Bug 32208 - Re-login without enough permissions needs attention
Summary: Re-login without enough permissions needs attention
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low major
Assignee: Marcel de Rooy
QA Contact: Testopia
URL:
Keywords:
Depends on: 31908
Blocks:
  Show dependency treegraph
 
Reported: 2022-11-15 13:54 UTC by Marcel de Rooy
Modified: 2024-08-15 13:20 UTC (History)
13 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.01,22.05.08
Circulation function:


Attachments
Bug 32208: Extend Auth.t (3.12 KB, patch)
2022-11-15 15:43 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 32208: Adjust Auth.pm for relogin without perms (1.82 KB, patch)
2022-11-15 15:44 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 32208: Extend Auth.t (3.14 KB, patch)
2022-11-16 10:52 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 32208: Adjust Auth.pm for relogin without perms (1.83 KB, patch)
2022-11-16 10:52 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 32208: Extend Auth.t (3.19 KB, patch)
2022-11-16 20:32 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 32208: Adjust Auth.pm for relogin without perms (1.89 KB, patch)
2022-11-16 20:32 UTC, Chris Cormack
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2022-11-15 13:54:34 UTC
More info follows
Comment 1 Marcel de Rooy 2022-11-15 15:43:56 UTC
Created attachment 143914 [details] [review]
Bug 32208: Extend Auth.t

Test plan:
Without follow-up patch, Auth.t should fail:
    not ok 5 - No permission response
    not ok 6 - checkauth returned failure

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 2 Marcel de Rooy 2022-11-15 15:44:01 UTC
Created attachment 143915 [details] [review]
Bug 32208: Adjust Auth.pm for relogin without perms

If a second login on top of a current session fails on
permissions, we should not grant access without context.

Test plan:
[1] Run t/db../Auth.t, it should pass now.
[2] Test interface with/without this patch:
    Pick two users: A has perms, B has not.
    Put two staff login forms in two tabs.
    Login as A in tab1. Login as B in tab2.
    Without this patch, B gets in and crashes.
    With this patch, B does not get in ('no perms').
    Bonus: Go to opac if on same domain. You are still
    logged in as B.

NOTE: I added a FIXME here, since you could argue about filling
the session info or otoh deleting the session. We present an
authorization failure; people may not realize that they are
still logged in (see test plan - bonus).

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 3 Marcel de Rooy 2022-11-15 15:47:44 UTC
This is just like 31908 a very small fix for a kind of edge case in regular Auth patterns. But it makes me wonder if similar things like here might be possible with all the Auth variations like CAS, Shibboleth, 2FA ?
Comment 4 Nick Clemens (kidclamp) 2022-11-16 10:52:34 UTC
Created attachment 143946 [details] [review]
Bug 32208: Extend Auth.t

Test plan:
Without follow-up patch, Auth.t should fail:
    not ok 5 - No permission response
    not ok 6 - checkauth returned failure

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 5 Nick Clemens (kidclamp) 2022-11-16 10:52:39 UTC
Created attachment 143947 [details] [review]
Bug 32208: Adjust Auth.pm for relogin without perms

If a second login on top of a current session fails on
permissions, we should not grant access without context.

Test plan:
[1] Run t/db../Auth.t, it should pass now.
[2] Test interface with/without this patch:
    Pick two users: A has perms, B has not.
    Put two staff login forms in two tabs.
    Login as A in tab1. Login as B in tab2.
    Without this patch, B gets in and crashes.
    With this patch, B does not get in ('no perms').
    Bonus: Go to opac if on same domain. You are still
    logged in as B.

NOTE: I added a FIXME here, since you could argue about filling
the session info or otoh deleting the session. We present an
authorization failure; people may not realize that they are
still logged in (see test plan - bonus).

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 6 Marcel de Rooy 2022-11-16 12:09:55 UTC
(In reply to Nick Clemens from comment #5)
> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Thanks!
Comment 7 Marcel de Rooy 2022-11-16 13:05:21 UTC
This patch can be applied on current 22.05.x branch too.
Comment 8 Marcel de Rooy 2022-11-16 13:12:36 UTC
This patch is not relevant for 21.11.x (in contrast with 31908 btw).
We are still checking $logged_in and not the new $auth_state.
Comment 9 Chris Cormack 2022-11-16 20:32:23 UTC
Created attachment 143970 [details] [review]
Bug 32208: Extend Auth.t

Test plan:
Without follow-up patch, Auth.t should fail:
    not ok 5 - No permission response
    not ok 6 - checkauth returned failure

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Comment 10 Chris Cormack 2022-11-16 20:32:48 UTC
Created attachment 143971 [details] [review]
Bug 32208: Adjust Auth.pm for relogin without perms

If a second login on top of a current session fails on
permissions, we should not grant access without context.

Test plan:
[1] Run t/db../Auth.t, it should pass now.
[2] Test interface with/without this patch:
    Pick two users: A has perms, B has not.
    Put two staff login forms in two tabs.
    Login as A in tab1. Login as B in tab2.
    Without this patch, B gets in and crashes.
    With this patch, B does not get in ('no perms').
    Bonus: Go to opac if on same domain. You are still
    logged in as B.

NOTE: I added a FIXME here, since you could argue about filling
the session info or otoh deleting the session. We present an
authorization failure; people may not realize that they are
still logged in (see test plan - bonus).

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Comment 11 David Cook 2022-11-16 22:11:50 UTC
(In reply to Marcel de Rooy from comment #3)
> This is just like 31908 a very small fix for a kind of edge case in regular
> Auth patterns. But it makes me wonder if similar things like here might be
> possible with all the Auth variations like CAS, Shibboleth, 2FA ?

All the more reason to make a group project of streamlining our AuthN/AuthZ code I reckon.
Comment 12 Marcel de Rooy 2022-11-17 06:37:06 UTC
(In reply to Chris Cormack from comment #10)
> Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Thanks!
Comment 13 Marcel de Rooy 2022-11-17 06:38:20 UTC
(In reply to David Cook from comment #11)
> (In reply to Marcel de Rooy from comment #3)
> > This is just like 31908 a very small fix for a kind of edge case in regular
> > Auth patterns. But it makes me wonder if similar things like here might be
> > possible with all the Auth variations like CAS, Shibboleth, 2FA ?
> 
> All the more reason to make a group project of streamlining our AuthN/AuthZ
> code I reckon.

Sure. Our community needs to improve on that skill. This would be a nice opportunity :)
Comment 14 Marcel de Rooy 2022-11-28 07:46:28 UTC
What is the status of this patch?
Comment 15 Wainui Witika-Park 2022-12-19 00:24:54 UTC
Does this need to be backported to 21.05.x for security?
Comment 16 Martin Renvoize (ashimema) 2022-12-19 15:27:08 UTC
Pushed to 22.11.x-security on the security repo for 22.11.01 release.
Comment 17 Wainui Witika-Park 2022-12-20 02:33:23 UTC
Pushed to 21.05.x-security on the security repo for 21.05.22 release.
Comment 18 Arthur Suzuki 2022-12-22 18:45:33 UTC
This patch depends on 31908, which I didn't succeed to backport on 21.11.x.
Will retry after 31908 is available on 21.11.
Comment 19 Martin Renvoize (ashimema) 2023-01-05 12:20:03 UTC
(In reply to Arthur Suzuki from comment #18)
> This patch depends on 31908, which I didn't succeed to backport on 21.11.x.
> Will retry after 31908 is available on 21.11.

I have 31908 working OK, but this patch relies on some Auth refactoring that has taken place in 22.05 and beyond.. The new test fails for 21.11.x but the fix doesn't work.

Tomas and I are working through it now.
Comment 20 Marcel de Rooy 2023-01-12 07:28:51 UTC
(In reply to wainuiwitikapark from comment #17)
> Pushed to 21.05.x-security on the security repo for 21.05.22 release.

This patch is not meant for 21.05 and 21.11.
See comment8.
Comment 21 Arthur Suzuki 2023-01-13 14:11:21 UTC
reverted on 21.11.x