As per an email to koha-devel, I'm going to take the core Mojolicious code from Bug 26791, and try implementing it with a much simpler controller to replace tools-home.pl. The key prerequisites for the controller are authentication, authorization, and template rendering. It may be necessary to split out other bug reports to focus on refactoring Koha's existing code, rather than bolting an alternative onto Koha, which could just create maintenance woes.
Test plan: 1. cp debian/templates/plack.psgi /etc/koha/sites/kohadev/plack.psgi 2. koha-plack --restart kohadev 3. koha-translate -i fr-FR 4. Update "language" system preference to include French 5. Go to http://localhost:8081/cgi-bin/koha/staff/tools/home 6. Note that it looks the same as http://localhost:8081/cgi-bin/koha/tools/tools-home.pl 7. Choose "Français" from the language bar 8. Go to http://localhost:8081/cgi-bin/koha/staff/tools/home 9. Note that it looks the same (in French) as http://localhost:8081/cgi-bin/koha/tools/tools-home.pl NOTES: - You cannot login at http://localhost:8081/cgi-bin/koha/staff/tools/home. It will redirect you to index.html where you will be prompted to login. You'll then have to navigate back to http://localhost:8081/cgi-bin/koha/staff/tools/home.
Created attachment 120857 [details] [review] Bug 28235: Build core functionality for Mojolicious controllers WIP
Created attachment 120858 [details] [review] Bug 28235: Build core functionality for Mojolicious controllers
While this looks like it works, I'm getting weird errors in the Plack logs: 172.21.0.1 - - [12/May/2021:08:54:59 +0000] "GET /intranet/staff/tools/home HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36" 172.21.0.1 - - [12/May/2021:08:54:59 +0000] "GET /intranet/errors/404.pl HTTP/1.1" 200 18833 "http://localhost:8081/cgi-bin/koha/staff/tools/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/9 0.0.4430.93 Safari/537.36" I have no idea what's going on with that 404. I'd also get the following: [2021/05/12 09:22:22] [WARN] no query in gettemplate at /kohadevbox/koha/C4/Templates.pm line 206. [2021/05/12 09:22:22] [WARN] no query in themelanguage at /kohadevbox/koha/C4/Templates.pm line 266. [2021/05/12 09:22:22] [WARN] no query in themelanguage at /kohadevbox/koha/C4/Templates.pm line 266. [2021/05/12 09:22:22] [WARN] Use of uninitialized value $interface in string eq at /kohadevbox/koha/C4/Templates.pm line 279. [2021/05/12 09:22:22] [WARN] Use of uninitialized value $interface in string eq at /kohadevbox/koha/C4/Templates.pm line 280. [2021/05/12 09:22:22] [WARN] Use of uninitialized value $interface in string eq at /kohadevbox/koha/C4/Templates.pm line 282. [2021/05/12 09:22:22] [WARN] Use of uninitialized value $lang in concatenation (.) or string at /kohadevbox/koha/C4/Templates.pm line 296. [2021/05/12 09:22:22] [WARN] Use of uninitialized value $lang in concatenation (.) or string at /kohadevbox/koha/C4/Templates.pm line 296. [2021/05/12 09:22:22] [WARN] Use of uninitialized value $lang in concatenation (.) or string at /kohadevbox/koha/C4/Templates.pm line 296. Some of that I might expect because I'm not handling Templates quite right, but a certain amount of that is coming from the 404 handling it seems...
I'm getting the following in the Plack error logs, but that's because C4::Templates is the worst, and I need to refactor it so it's not so tightly coupled to CGI. [2021/05/12 09:24:37] [WARN] no query in gettemplate at /kohadevbox/koha/C4/Templates.pm line 206. [2021/05/12 09:24:37] [WARN] no query in themelanguage at /kohadevbox/koha/C4/Templates.pm line 266. [2021/05/12 09:24:37] [WARN] no query in themelanguage at /kohadevbox/koha/C4/Templates.pm line 266. [2021/05/12 09:24:37] [WARN] Use of uninitialized value $interface in string eq at /kohadevbox/koha/C4/Templates.pm line 279. [2021/05/12 09:24:37] [WARN] Use of uninitialized value $interface in string eq at /kohadevbox/koha/C4/Templates.pm line 280. [2021/05/12 09:24:37] [WARN] Use of uninitialized value $interface in string eq at /kohadevbox/koha/C4/Templates.pm line 282. [2021/05/12 09:24:37] [WARN] Use of uninitialized value $lang in concatenation (.) or string at /kohadevbox/koha/C4/Templates.pm line 296. [2021/05/12 09:24:37] [WARN] Use of uninitialized value $lang in concatenation (.) or string at /kohadevbox/koha/C4/Templates.pm line 296. [2021/05/12 09:24:37] [WARN] Use of uninitialized value $lang in concatenation (.) or string at /kohadevbox/koha/C4/Templates.pm line 296.
Bug 15204 makes me think that a Koha::Session module would be a good idea. It could be a good idea to actually have authentication in Koha::AuthN and authorization in Koha::AuthZ as well. After all, there are many ways to authenticate with Koha, but there's only one way to authorize. They're two separate activities, so they probably should be separate modules.
The patch is outdated and realistically we're not moving in this direction anyway