[Bug 31050] New: Standardize session setup
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 Bug ID: 31050 Summary: Standardize session setup Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Authentication Assignee: koha-bugs@lists.koha-community.org Reporter: dcook@prosentient.com.au QA Contact: testopia@bugs.koha-community.org CC: dpavlin@rot13.org We should have 1 function that sets up the basics of a $session object which we can use across all our different authentication options. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |dcook@prosentient.com.au |ity.org | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 --- Comment #1 from David Cook <dcook@prosentient.com.au> --- Created attachment 136566 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=136566&action=edit Bug 31050: C4::Context->setup_session() standardizes user session setup Test plan: 0. Apply patch and koha-plack --restart kohadev 1. Log into http://localhost:8081/cgi-bin/koha/mainpage.pl using "koha" user 2. Note the login is successful 3. koha-mysql kohadev 3a. select * from sessions; Session in MySQL sets parameters like surname, flags, interface, ip, lasttime, etc 3b. select * from systempreferences where variable = 'Version'; 3c. update systempreferences set value = '<version which is 1 number less at the end>' where variable = 'Version'; 4. koha-plack --restart kohadev 5. echo 'flush_all' | nc -q 1 memcached 11211 6. Visit http://localhost:8081/ and do the upgrade 6b. Note that the authentication and upgrade works without a problem 7. curl http://localhost:8081/cgi-bin/koha/svc/authentication -d 'userid=<koha user>&password=<koha password>' 8. koha-mysql kohadev 8a. select * from sessions; Session in MySQL sets parameters like surname, flags, interface, ip, lasttime, etc -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 --- Comment #2 from David Cook <dcook@prosentient.com.au> --- As an aside, this would make it easier to write authentication extensions. Here is an example where the user is logged in with a new user session by supplying their cardnumber. use Modern::Perl; use CGI qw ( -utf8 ); use C4::Context; my $query = CGI->new; my $cardnumber = $query->param('cardnumber'); my $user = Koha::Patrons->find({ cardnumber => $cardnumber }); if ($user){ my $session = C4::Auth::get_session(); my $branch = $user->library; C4::Context->setup_session({ session => $session, data => { 'number', $user->borrowernumber, 'id', $user->userid, 'cardnumber', $user->cardnumber, 'firstname', $user->firstname, 'surname', $user->surname, 'branch', $branch->branchcode, 'branchname', $branch->branchname, 'flags', $user->flags, 'emailaddress', $user->email, 'interface', 'opac', }, }); my $cookie = $query->cookie( -name => 'CGISESSID', -value => $session->id, -HttpOnly => 1, -secure => ( C4::Context->https_enabled() ? 1 : 0 ), -sameSite => 'Lax' ); print $query->redirect( -uri => '/cgi-bin/koha/opac-main.pl', -cookie => $cookie, ); } -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 --- Comment #3 from David Cook <dcook@prosentient.com.au> --- *** Bug 28507 has been marked as a duplicate of this bug. *** -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #136566|0 |1 is obsolete| | --- Comment #4 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 138003 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=138003&action=edit Bug 31050: C4::Context->setup_session() standardizes user session setup Test plan: 0. Apply patch and koha-plack --restart kohadev 1. Log into http://localhost:8081/cgi-bin/koha/mainpage.pl using "koha" user 2. Note the login is successful 3. koha-mysql kohadev 3a. select * from sessions; Session in MySQL sets parameters like surname, flags, interface, ip, lasttime, etc 3b. select * from systempreferences where variable = 'Version'; 3c. update systempreferences set value = '<version which is 1 number less at the end>' where variable = 'Version'; 4. koha-plack --restart kohadev 5. echo 'flush_all' | nc -q 1 memcached 11211 6. Visit http://localhost:8081/ and do the upgrade 6b. Note that the authentication and upgrade works without a problem 7. curl http://localhost:8081/cgi-bin/koha/svc/authentication -d 'userid=<koha user>&password=<koha password>' 8. koha-mysql kohadev 8a. select * from sessions; Session in MySQL sets parameters like surname, flags, interface, ip, lasttime, etc Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off CC| |martin.renvoize@ptfs-europe | |.com --- Comment #5 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- This is a nice bit of code cleaning, thanks David.. as you suggested, it might be nice as a next step to allow just passing a Patron object and then constructing the various fields from that.. could have a nice reduction in line count again. Signing off. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart+koha@gmail. | |com Status|Signed Off |Failed QA --- Comment #6 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- New method, new tests, please. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=32178 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |DUPLICATE Status|Failed QA |RESOLVED --- Comment #7 from David Cook <dcook@prosentient.com.au> --- Bug 32178 implements enough of the functionality to close out this one I think *** This bug has been marked as a duplicate of bug 32178 *** -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Assignee|dcook@prosentient.com.au |koha-bugs@lists.koha-commun | |ity.org Resolution|DUPLICATE |--- --- Comment #8 from David Cook <dcook@prosentient.com.au> --- Then again... C4::Auth::create_basic_session() is only used for the OIDC auth, so I guess we still do have a ways to go... But I don't think I'll be working on it any time soon. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 Andreas Jonsson <andreas.jonsson@kreablo.se> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andreas.jonsson@kreablo.se -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 --- Comment #9 from David Cook <dcook@prosentient.com.au> --- I thought I had a bug somewhere for standardizing creation of "anon" sessions as well but can't find it now... -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 --- Comment #10 from David Cook <dcook@prosentient.com.au> --- Comment on attachment 138003 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=138003 Bug 31050: C4::Context->setup_session() standardizes user session setup Review of attachment 138003: --> (https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=31050&attachment=138003) ----------------------------------------------------------------- ::: C4/Context.pm @@ +1049,5 @@
+as a bare minimum. + +=cut + +sub setup_anon_session {
Oh it is this bug and there it is... -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31050 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=25362 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org