This adds a new restrict_by_home_ou setting to auth_proxy. When enabled,
if the login request includes an org param, auth_proxy will refuse to
authenticate a user unless their home OU matches or is a descendant of
that org.
Signed-off-by: Jeff Davis <jeff.davis@bc.libraries.coop>
<unit>103</unit>
<unit>104</unit>
</org_units>
+ <restrict_by_home_ou>false</restrict_by_home_ou>
</authenticator>
-->
<!-- 'native' is a proxied version of Evergreen's standard authentication -->
$logger->debug("Authenticated username '" . $args->{'username'} . "' has no Evergreen account, aborting");
return OpenILS::Event->new( 'LOGIN_FAILED' );
} else {
+ my $restrict_by_ou = $authenticator->{restrict_by_home_ou};
+ if ($args->{org} and defined($restrict_by_ou) and $restrict_by_ou =~ /^t/i) {
+ my $descendants = $U->get_org_descendants($args->{org});
+ unless (grep $user->[0]->home_ou, @$descendants) {
+ $logger->debug("Matching user does not belong to this org, aborting");
+ return OpenILS::Event->new( 'LOGIN_FAILED' );
+ }
+ }
$args->{user_id} = $user->[0]->id;
}