library: login for everything - public catalogue off, read-only guest for Find a book
- the public catalogue is bound to the machine itself by default (OPAC_BIND) and, if ever exposed, requires a library-card login (OpacPublic=0) - a read-only guest login (VIEWER_USER/VIEWER_PASSWORD) in Quick Add: it may load the page, read state and search; every other endpoint is admin-only (403); the page shows only Find a book - the guest deliberately has NO Koha account: Koha's 'catalogue' permission, the only one that allows searching, also allows creating/editing label layouts and templates (tested: a guest created a layout), so it cannot be read-only - koha/ensure.pl (every start): staff-home 'Library tools' block, and removal of a guest account an earlier version created - kiosk add-on shows Find a book signed in as the guest; the admin login never goes into the kiosk config (tested, incl. a mutation check); old public-catalogue tabs are cleaned up - existing installs keep their current public-catalogue behaviour on update Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013wi3ZSot4XbUViwRFgLpRf
This commit is contained in:
@@ -39,7 +39,7 @@ RUN for c in koha-create koha-plack koha-zebra koha-rebuild-zebra koha-upgrade-s
|
||||
command -v "$c" >/dev/null || { echo "BUILD ERROR: $c is missing from the image" >&2; exit 1; }; \
|
||||
done
|
||||
|
||||
COPY bootstrap.pl entrypoint.sh /opt/koha-init/
|
||||
COPY bootstrap.pl ensure.pl entrypoint.sh /opt/koha-init/
|
||||
COPY seed/ /opt/koha-init/seed/
|
||||
RUN chmod 0755 /opt/koha-init/entrypoint.sh && chmod -R a+rX /opt/koha-init
|
||||
|
||||
|
||||
@@ -153,19 +153,6 @@ Koha::CirculationRules->set_rules({
|
||||
},
|
||||
});
|
||||
|
||||
# ---- Staff home page: a "Library tools" block with a link to the Add books page ----
|
||||
# (Koha 26.05 stores these in the HTML customizations tool, not in a preference.)
|
||||
{
|
||||
my $html = '<div class="main-heading"><h3>Library tools</h3></div><ul class="list-unstyled">'
|
||||
. '<li><a class="btn btn-primary" href="/add/">Add books (scan an ISBN)</a></li>'
|
||||
. '<li><a href="/add/#find">Find a book</a></li></ul>';
|
||||
$dbh->do(q{INSERT INTO additional_contents (category, code, location, branchcode, published_on, number)
|
||||
VALUES ('html_customizations', 'library_tools', 'IntranetmainUserblock', NULL, CURDATE(), 1)});
|
||||
my $id = $dbh->last_insert_id( undef, undef, 'additional_contents', 'id' );
|
||||
$dbh->do( q{INSERT INTO additional_contents_localizations (additional_content_id, title, content, lang)
|
||||
VALUES (?, 'Library tools', ?, 'default')}, undef, $id, $html );
|
||||
}
|
||||
|
||||
# ---- Preferences ----------------------------------------------------------
|
||||
my %prefs = (
|
||||
autoBarcode => 'OFF', # barcodes are assigned by Quick Add (zero-padded, or none/scanned on request)
|
||||
@@ -173,11 +160,11 @@ my %prefs = (
|
||||
finesMode => 'off', # a home library does not charge overdue fines
|
||||
itemcallnumber => '082ab', # Dewey call number copied from the MARC record
|
||||
RESTBasicAuth => 1, # lets the quick-add page use the REST API
|
||||
OpacPublic => 0, # the public catalogue, if ever exposed, asks for a login
|
||||
OpenLibraryCovers => 1, # cover images in the catalogue
|
||||
OPACSearchForTitleIn => '',
|
||||
BiblioDefaultView => 'normal',
|
||||
OpacPublic => 1,
|
||||
opacuserlogin => 0, # catalogue is browse-only; no patron logins needed
|
||||
opacuserlogin => 1,
|
||||
OpacMaintenance => 0,
|
||||
ExpireReservesMaxPickUpDelay => 0,
|
||||
AllowOfflineCirculation => 0,
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/perl
|
||||
# Idempotent housekeeping, run on EVERY container start (after the first-time install or
|
||||
# the schema upgrade), so existing installs pick these up too:
|
||||
# * removal of the Koha guest account an earlier version created (the guest login is Quick Add only)
|
||||
# * the "Library tools" block on the staff home page
|
||||
use Modern::Perl;
|
||||
use C4::Context;
|
||||
use Koha::Patrons;
|
||||
use Koha::Patron::Categories;
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
# The read-only "guest" login lives in Quick Add only (the Find a book page), NOT in Koha:
|
||||
# Koha's own "catalogue" permission also allows editing label layouts and templates, so a
|
||||
# Koha account cannot be made truly read-only. Remove any guest account an earlier version created.
|
||||
for my $p ( Koha::Patrons->search( { categorycode => 'VIEWER' } )->as_list ) {
|
||||
say "ensure: removing the old Koha guest account '" . $p->userid . "'";
|
||||
$p->delete;
|
||||
}
|
||||
if ( my $cat = Koha::Patron::Categories->find('VIEWER') ) {
|
||||
$cat->delete unless Koha::Patrons->search( { categorycode => 'VIEWER' } )->count;
|
||||
}
|
||||
|
||||
# Staff home page block (Koha 26.05 keeps these in the HTML customizations tool).
|
||||
my ($have) = $dbh->selectrow_array(q{SELECT COUNT(*) FROM additional_contents WHERE code = 'library_tools'});
|
||||
unless ($have) {
|
||||
my $html = '<div class="main-heading"><h3>Library tools</h3></div><ul class="list-unstyled">'
|
||||
. '<li><a class="btn btn-primary" href="/add/#find">Find a book</a></li>'
|
||||
. '<li><a href="/add/">Add books (scan an ISBN)</a></li></ul>';
|
||||
$dbh->do(q{INSERT INTO additional_contents (category, code, location, branchcode, published_on, number)
|
||||
VALUES ('html_customizations', 'library_tools', 'IntranetmainUserblock', NULL, CURDATE(), 1)});
|
||||
my $id = $dbh->last_insert_id( undef, undef, 'additional_contents', 'id' );
|
||||
$dbh->do( q{INSERT INTO additional_contents_localizations (additional_content_id, title, content, lang)
|
||||
VALUES (?, 'Library tools', ?, 'default')}, undef, $id, $html );
|
||||
say "ensure: added the staff home 'Library tools' block";
|
||||
}
|
||||
@@ -108,6 +108,11 @@ else
|
||||
FIRST_RUN=0
|
||||
fi
|
||||
|
||||
# --- 4b. housekeeping that must hold on every start (staff home block, old guest account cleanup)
|
||||
runuser -u "$INST-koha" -- env KOHA_CONF="/etc/koha/sites/$INST/koha-conf.xml" PERL5LIB=/usr/share/koha/lib \
|
||||
perl /opt/koha-init/ensure.pl \
|
||||
|| log "WARNING: ensure.pl reported a problem (see above)"
|
||||
|
||||
# --- 5. background services (their `daemon` processes die with the container,
|
||||
# so they are started explicitly on every start) ------------------------
|
||||
if [ "$FIRST_RUN" = 1 ] || [ ! -e "/var/lib/koha/$INST/biblios/register" ]; then
|
||||
|
||||
Reference in New Issue
Block a user