From bb1ef39d3d9c4e2130dca3cc8ee28dcc80f00392 Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Fri, 8 Feb 2019 12:08:51 -0800 Subject: [PATCH] AuthProxy: optionally use native login when using barcode --- .../perlmods/lib/OpenILS/Application/AuthProxy.pm | 17 +++++++++++++++++ Open-ILS/src/sql/Pg/950.data.seed-values.sql | 16 ++++++++++++++++ ...X.data.auth_proxy.native_login_with_barcode.sql | 22 ++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.auth_proxy.native_login_with_barcode.sql diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AuthProxy.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AuthProxy.pm index 1f7832c653..a52d022638 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AuthProxy.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AuthProxy.pm @@ -203,14 +203,31 @@ sub login { my @error_events; my $authenticated = 0; my $auths; + my $barcode_means_native; + + if ($args->{barcode} and $args->{org}) { + $barcode_means_native = $U->is_true( + $U->ou_ancestor_setting_value($args->{org}, 'auth_proxy.native_login_with_barcode') + ); + if ($barcode_means_native) { + if (exists $authenticators_by_name{'native'}) { + $auths = [$authenticators_by_name{'native'}]; + } else { + $logger->debug("Ignoring AuthProxy native login with barcode - native login is not configured"); + } + } # if they specify an authenticator by name, only try that one if ($args->{'name'}) { + if ($barcode_means_native and $args->{'name'} ne 'native') { + $logger->debug("Ignoring AuthProxy native login with barcode - request specified " . $args->{'name'}); + } $auths = [$authenticators_by_name{$args->{'name'}}]; } else { $auths = \@authenticators; } + foreach my $authenticator (@$auths) { # skip authenticators specified for a different login type # or org unit id diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 649ced5d83..516f19c74c 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -19494,4 +19494,20 @@ VALUES ( ); +INSERT into config.org_unit_setting_type (name, label, description, datatype) +VALUES ( + 'auth_proxy.native_login_with_barcode', + oils_i18n_gettext( + 'auth_proxy.native_login_with_barcode', + 'AuthProxy: Use native login with barcode', + 'coust', 'label' + ), + oils_i18n_gettext( + 'auth_proxy.native_login_with_barcode', + 'When using barcode to login, native EG login will be used instead of any configured authentication proxy, unless the login request specifies otherwise.', + 'coust', 'description' + ), + 'bool' +); + diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.auth_proxy.native_login_with_barcode.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.auth_proxy.native_login_with_barcode.sql new file mode 100644 index 0000000000..082859ba06 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.auth_proxy.native_login_with_barcode.sql @@ -0,0 +1,22 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +INSERT into config.org_unit_setting_type (name, label, description, datatype) +VALUES ( + 'auth_proxy.native_login_with_barcode', + oils_i18n_gettext( + 'auth_proxy.native_login_with_barcode', + 'AuthProxy: Use native login with barcode', + 'coust', 'label' + ), + oils_i18n_gettext( + 'auth_proxy.native_login_with_barcode', + 'When using barcode to login, native EG login will be used instead of any configured authentication proxy, unless the login request specifies otherwise.', + 'coust', 'description' + ), + 'bool' +); + +COMMIT; + -- 2.11.0