@@ -, +, @@ connexion daemon 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 echo -en 'U6turtleA9connexionP5shell00024 a62clear00024 4500' | nc -v localhost 8888 echo -en 'U7conuserA9connexionP7conpass00024 a62clear00024 4500' | nc -v localhost 8888 --- misc/bin/connexion_import_daemon.pl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) --- a/misc/bin/connexion_import_daemon.pl +++ a/misc/bin/connexion_import_daemon.pl @@ -60,6 +60,11 @@ Config file format: add_only_for_matches, add_only_for_new or ignore import_mode - stage or direct framework - to be used if import_mode is direct + connexion_user - User sent from connexion client + connexion_password - Password sent from connexion client + + Note: If connexion parameters are not defined request authentication will not be checked + You should specify a different user for connexion to protect the Koha credentials All process related parameters (all but ip and port) have default values as per Koha import process. @@ -141,6 +146,14 @@ sub parse_config { $self->{password} = delete( $param{password} ) or die "No koha user password in config file"; + if( defined $param{connexion_user} || defined $param{connexion_password}){ + # If either is defined we expect both + $self->{connexion_user} = delete( $param{connexion_user} ) + or die "No koha connexion_user in config file"; + $self->{connexion_password} = delete( $param{connexion_password} ) + or die "No koha user connexion_password in config file"; + } + $self->{host} = delete( $param{host} ); $self->{port} = delete( $param{port} ) or die "Port not specified"; @@ -323,6 +336,13 @@ sub handle_request { my ($data, $user, $password) = $self->read_request($io) or return $self->error_response("Bad request"); + unless( + !(defined $self->{connexion_user}) || + ($user eq $self->{connexion_user} && $password eq $self->{connexion_password}) + ){ + return $self->error_response("Unauthorized request"); + } + my $ua; if ($self->{user}) { $user = $self->{user}; --