LP#1715396: optionally run auth_proxy for specified orgs only user/jeffdavis/lp1715396-non-inclusive-authproxy
authorJeff Davis <jeff.davis@bc.libraries.coop>
Sat, 9 Feb 2019 01:25:55 +0000 (17:25 -0800)
committerJeff Davis <jeff.davis@bc.libraries.coop>
Sat, 9 Feb 2019 01:25:55 +0000 (17:25 -0800)
Signed-off-by: Jeff Davis <jeff.davis@bc.libraries.coop>
Open-ILS/examples/opensrf.xml.example
Open-ILS/src/perlmods/lib/OpenILS/Application/AuthProxy.pm

index 156562b..1f6dac5 100644 (file)
@@ -554,6 +554,7 @@ vim:et:ts=4:sw=4:
                                 <unit>103</unit>
                                 <unit>104</unit>
                             </org_units>
+                            <restrict_to_orgs>false</restrict_to_orgs>
                         </authenticator>
                         -->
                         <!-- 'native' is a proxied version of Evergreen's standard authentication -->
index 1f7832c..5658125 100644 (file)
@@ -213,12 +213,24 @@ sub login {
 
     foreach my $authenticator (@$auths) {
         # skip authenticators specified for a different login type
-        # or org unit id
         if ($authenticator->login_types and $args->{'type'}) {
             next unless grep(/^(all|$args->{'type'})$/, @{$authenticator->{'login_types'}});
         }
-        if ($authenticator->org_units and $args->{'org'}) {
-            next unless grep(/^(all|$args->{'org'})$/, @{$authenticator->{'org_units'}});
+
+        if ($authenticator->org_units) {
+            if ($args->{'org'}) {
+                # We have a context org. Skip this authenticator unless it's
+                # configured to run for that org.
+                next unless grep(/^(all|$args->{'org'})$/, @{$authenticator->{'org_units'}});
+            } else {
+                # By default, when we don't have a context org, configured org
+                # units are ignored and we run this authenticator for everybody.
+                # But if restrict_to_orgs is enabled, we should skip this
+                # authenticator (unless it runs for all orgs).
+                if (exists $authenticator->{restrict_to_orgs} and $authenticator->{restrict_to_orgs} =~ /^t/i) {
+                    next unless grep(/^all$/, @{$authenticator->{'org_units'}});
+                }
+            }
         }
 
         my $event;