AuthProxy: optionally use native login when using barcode user/jeffdavis/auth_proxy_native_login_with_barcode
authorJeff Davis <jeff.davis@bc.libraries.coop>
Fri, 8 Feb 2019 20:08:51 +0000 (12:08 -0800)
committerJeff Davis <jeff.davis@bc.libraries.coop>
Fri, 8 Feb 2019 20:08:51 +0000 (12:08 -0800)
Open-ILS/src/perlmods/lib/OpenILS/Application/AuthProxy.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.auth_proxy.native_login_with_barcode.sql [new file with mode: 0644]

index 1f7832c..a52d022 100644 (file)
@@ -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
index 649ced5..516f19c 100644 (file)
@@ -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 (file)
index 0000000..082859b
--- /dev/null
@@ -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;
+