Following the chain of data from read_request in misc/bin/connexion_import_daemon.pl to the authentication code in handle_request, the username and password sent by the OCLC Connexion client are silently ignored. The user/password in connexion.cnf are used to connect to Koha. This means that, with knowledge of the Connexion protocol and a known host/port with a running Koha Connexion daemon, records can be created/modified (depending on the settings in connexion.cnf) without any valid Koha login on the target system. To reproduce, start connexion_import_daemon.pl, then run: echo -en 'U8fakeuserA9localuserP8fakepass00024 a2200024 4500\000' | nc -v HOST PORT
There are three possible ways to solve this: 1) Remove the user/password in connexion.cnf, and use the user/password sent by the Connexion client to log into Koha. 2) Require that the user/password sent by the Connexion client match the user/password in connexion.cnf. 3) Add new connexion_user/connexion_password options to connexion.cnf, and require that the user/password sent by the Connexion client match them. 1) has the advantage of matching what is currently documented (http://manual.koha-community.org/3.22/en/oclcdesktopsetup.html) and being very straightforward. However, both 1) and 2) mean that valid Koha staff logins are transmitted in plaintext. Thoughts?
Not an OCLC connexion user... but the plaintext problem seems like killer for 1) and 2) to me.
Srdjan, as the original author, I'd like your input. I prefer 3, personally, but it does mean that we'll have to roll out a bit of a jarring upgrade if we don't want to wait for 3.24.
Yes, that logic is flawed and does not authenticate with username/password sent by the Connexion client. The intention was to either have username/password in the config, or if missing force authenticaion sent by the Connexion client. Unfortunately I was not able to test it myself (I could not get a Connexion client) so I had to hand it out half baked, username/password in config worked, so no user/pass in config situation was not put to test. A quick idea what should be there: if ($self->{user}) { $user = $self->{user}; $password = $self->{password}; $ua = $self->{ua}; } else { $ua = _ua(); # fresh one, needs to authenticate $resp = $ua->post( $base_url.AUTH_URI, { userid => $user, password => $password } ); # XXX this was missing return $self->error_response("Invalid auth response") unless $resp->is_success; } ... if ($self->{user} && ($status == HTTP_UNAUTHORIZED || $status == HTTP_FORBIDDEN)) { # XXX only reauthenticate if cached ua # no need my $user = $self->{user}; # no need my $password = $self->{password}; This fix caters for option 1. 2/3 would give benefit in case all the Connexion clients use the same credentials. Then we have a persistent session cookie. Re plain text - well, short of using https, it is either authenticate in plain text, or let everyone connect. In case of http, 3 would probably be preferred over 2 obecause it is protects the Koha credentials.
Created attachment 110288 [details] [review] Bug 15720: Add connexion user and password options to connexion daemon Currently the connexion daemon does not utilize the user and password passed in the requests, it expects a user and password to be defined in the config file and for that user to be a valid Koha user with cataloging permissions. With that user in place all requests to the daemon are authorized. As the connections are over TCP we allow defining a new connexion user and password to protect Koha account information. If not defined current behaviour is preserved. Connexion user and password must both be set it either is set. Sample config file: host: port: 8888 koha:http://localhost:8081 log:/var/log/koha/kohadev/connexion.log match:ISBN user:kohauser password:kohapass overlay_action:replace nomatch_action:create_new item_action:always_add import_mode:redirect debug:1 To test: 1 - Create connexion file and save on the Koha serve 2 - perl misc/bin/connexion_import_daemon.pl -c /kohadevbox/koha/connexion.cnf 3 - Ensure the user specified above (connexuser) exists and has edit catalogue permissions 4 - In another terminal make a request to the server: echo -en 'U6turtleA9connexionP5shell00024 a62clear00024 4500' | nc -v localhost 8888 5 - The request should succeed and record added to batch (probably the import fails, but not important) 6 - Add to config file connexion_user:conuser 7 - Stop and restart the daemon - it should fail on missing connexion_password 8 - Comment out connexion_user and add connexion_password:conpass 9 - Stop and restart daemon, it fails on missing connexion_user 10 - Uncomment the user and restart 11 - Make another request echo -en 'U6turtleA9connexionP5shell00024 a62clear00024 4500' | nc -v localhost 8888 12 - It fails 'Unauthorized request' 13 - Make another request echo -en 'U7conuserA9connexionP7conpass00024 a62clear00024 4500' | nc -v localhost 8888 14 - It succeeds!
Created attachment 110762 [details] [review] Bug 15720: Add connexion user and password options to connexion daemon Currently the connexion daemon does not utilize the user and password passed in the requests, it expects a user and password to be defined in the config file and for that user to be a valid Koha user with cataloging permissions. With that user in place all requests to the daemon are authorized. As the connections are over TCP we allow defining a new connexion user and password to protect Koha account information. If not defined current behaviour is preserved. Connexion user and password must both be set it either is set. Sample config file: host: port: 8888 koha:http://localhost:8081 log:/var/log/koha/kohadev/connexion.log match:ISBN user:kohauser password:kohapass overlay_action:replace nomatch_action:create_new item_action:always_add import_mode:redirect debug:1 To test: 1 - Create connexion file and save on the Koha serve 2 - perl misc/bin/connexion_import_daemon.pl -c /kohadevbox/koha/connexion.cnf 3 - Ensure the user specified above (connexuser) exists and has edit catalogue permissions 4 - In another terminal make a request to the server: echo -en 'U6turtleA9connexionP5shell00024 a62clear00024 4500' | nc -v localhost 8888 5 - The request should succeed and record added to batch (probably the import fails, but not important) 6 - Add to config file connexion_user:conuser 7 - Stop and restart the daemon - it should fail on missing connexion_password 8 - Comment out connexion_user and add connexion_password:conpass 9 - Stop and restart daemon, it fails on missing connexion_user 10 - Uncomment the user and restart 11 - Make another request echo -en 'U6turtleA9connexionP5shell00024 a62clear00024 4500' | nc -v localhost 8888 12 - It fails 'Unauthorized request' 13 - Make another request echo -en 'U7conuserA9connexionP7conpass00024 a62clear00024 4500' | nc -v localhost 8888 14 - It succeeds!
Testing tips: Get windows (if you don't have it) https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ Get connexion: https://help.oclc.org/Librarian_Toolbox/Software_downloads/Cataloging_software_downloads Boot up the vm, install connexion Add a new local export Your host is your local ip The port is 8888 by default local user and pass should match your connexion user and pass in config To make port 8888 accessible in kohatesting docker add it to docker-compose.yml in the ports section: - "8888:8888" Launch server as below In connexion you create a new record, press Shift+F5 to get it verified and saved to local - in options set allow export of workforms, then you should be bale to press F5 to export the record to Koha There are some more fiddly bits I forgot I bet, but it's at least possible to do this without an OCLC connection
Created attachment 118215 [details] [review] Bug 15720: Add connexion user and password options to connexion daemon Currently the connexion daemon does not utilize the user and password passed in the requests, it expects a user and password to be defined in the config file and for that user to be a valid Koha user with cataloging permissions. With that user in place all requests to the daemon are authorized. As the connections are over TCP we allow defining a new connexion user and password to protect Koha account information. If not defined current behaviour is preserved. Connexion user and password must both be set it either is set. Sample config file: host: port: 8888 koha:http://localhost:8081 log:/var/log/koha/kohadev/connexion.log match:ISBN user:kohauser password:kohapass overlay_action:replace nomatch_action:create_new item_action:always_add import_mode:redirect debug:1 To test: 1 - Create connexion file and save on the Koha serve 2 - perl misc/bin/connexion_import_daemon.pl -c /kohadevbox/koha/connexion.cnf 3 - Ensure the user specified above (connexuser) exists and has edit catalogue permissions 4 - In another terminal make a request to the server: echo -en 'U6turtleA9connexionP5shell00024 a62clear00024 4500' | nc -v localhost 8888 5 - The request should succeed and record added to batch (probably the import fails, but not important) 6 - Add to config file connexion_user:conuser 7 - Stop and restart the daemon - it should fail on missing connexion_password 8 - Comment out connexion_user and add connexion_password:conpass 9 - Stop and restart daemon, it fails on missing connexion_user 10 - Uncomment the user and restart 11 - Make another request echo -en 'U6turtleA9connexionP5shell00024 a62clear00024 4500' | nc -v localhost 8888 12 - It fails 'Unauthorized request' 13 - Make another request echo -en 'U7conuserA9connexionP7conpass00024 a62clear00024 4500' | nc -v localhost 8888 14 - It succeeds! Signed-off-by: Allison Blanning <ablanning@hotchkiss.org>
I believe this is probably not testable without a connexion user (WorldCat)? Maybe we could get a second sign-off to help this along?
(In reply to Katrin Fischer from comment #9) > I believe this is probably not testable without a connexion user (WorldCat)? > > Maybe we could get a second sign-off to help this along? See comment 7 It requires some setup but is possible
Created attachment 120696 [details] [review] Bug 15720: Add connexion user and password options to connexion daemon Currently the connexion daemon does not utilize the user and password passed in the requests, it expects a user and password to be defined in the config file and for that user to be a valid Koha user with cataloging permissions. With that user in place all requests to the daemon are authorized. As the connections are over TCP we allow defining a new connexion user and password to protect Koha account information. If not defined current behaviour is preserved. Connexion user and password must both be set it either is set. Sample config file: host: port: 8888 koha:http://localhost:8081 log:/var/log/koha/kohadev/connexion.log match:ISBN user:kohauser password:kohapass overlay_action:replace nomatch_action:create_new item_action:always_add import_mode:redirect debug:1 To test: 1 - Create connexion file and save on the Koha serve 2 - perl misc/bin/connexion_import_daemon.pl -c /kohadevbox/koha/connexion.cnf 3 - Ensure the user specified above (connexuser) exists and has edit catalogue permissions 4 - In another terminal make a request to the server: echo -en 'U6turtleA9connexionP5shell00024 a62clear00024 4500' | nc -v localhost 8888 5 - The request should succeed and record added to batch (probably the import fails, but not important) 6 - Add to config file connexion_user:conuser 7 - Stop and restart the daemon - it should fail on missing connexion_password 8 - Comment out connexion_user and add connexion_password:conpass 9 - Stop and restart daemon, it fails on missing connexion_user 10 - Uncomment the user and restart 11 - Make another request echo -en 'U6turtleA9connexionP5shell00024 a62clear00024 4500' | nc -v localhost 8888 12 - It fails 'Unauthorized request' 13 - Make another request echo -en 'U7conuserA9connexionP7conpass00024 a62clear00024 4500' | nc -v localhost 8888 14 - It succeeds! Signed-off-by: Allison Blanning <ablanning@hotchkiss.org> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 120697 [details] [review] Bug 15720: Add connexion user and password options to connexion daemon Currently the connexion daemon does not utilize the user and password passed in the requests, it expects a user and password to be defined in the config file and for that user to be a valid Koha user with cataloging permissions. With that user in place all requests to the daemon are authorized. As the connections are over TCP we allow defining a new connexion user and password to protect Koha account information. If not defined current behaviour is preserved. Connexion user and password must both be set it either is set. Sample config file: host: port: 8888 koha:http://localhost:8081 log:/var/log/koha/kohadev/connexion.log match:ISBN user:kohauser password:kohapass overlay_action:replace nomatch_action:create_new item_action:always_add import_mode:redirect debug:1 To test: 1 - Create connexion file and save on the Koha serve 2 - perl misc/bin/connexion_import_daemon.pl -c /kohadevbox/koha/connexion.cnf 3 - Ensure the user specified above (connexuser) exists and has edit catalogue permissions 4 - In another terminal make a request to the server: echo -en 'U6turtleA9connexionP5shell00024 a62clear00024 4500' | nc -v localhost 8888 5 - The request should succeed and record added to batch (probably the import fails, but not important) 6 - Add to config file connexion_user:conuser 7 - Stop and restart the daemon - it should fail on missing connexion_password 8 - Comment out connexion_user and add connexion_password:conpass 9 - Stop and restart daemon, it fails on missing connexion_user 10 - Uncomment the user and restart 11 - Make another request echo -en 'U6turtleA9connexionP5shell00024 a62clear00024 4500' | nc -v localhost 8888 12 - It fails 'Unauthorized request' 13 - Make another request echo -en 'U7conuserA9connexionP7conpass00024 a62clear00024 4500' | nc -v localhost 8888 14 - It succeeds! Signed-off-by: Allison Blanning <ablanning@hotchkiss.org> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Applies on 19.11.x. if deemed to be worth the time, I can try to test it >_<
Pushed to master for 21.05, thanks to everybody involved!