<field name="allow_inactive" reporter:datatype="bool"/>
<field name="allow_expired" reporter:datatype="bool"/>
<field name="block_list" reporter:datatype="text"/>
+ <field name="usr_activity_type" reporter:datatype="link"/>
</fields>
<links>
<link field="context_org" reltype="has_a" key="id" map="" class="aou"/>
<link field="perm" reltype="has_a" key="id" map="" class="ppl"/>
+ <link field="usr_activity_type" reltype="has_a" key="id" map="" class="cuat"/>
</links>
<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
<actions>
my $handler = $module->new;
$stat = $handler->process($r);
} catch Error with {
- $logger->error("processing RemoteAuth handler failed: @_");
+ my $err = shift;
+ $logger->error("processing RemoteAuth handler failed: $err");
$stat = Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
};
return $self->backend_error unless $e->checkauth;
- # XXX
my $args = {
- type => 'opac',
+ type => 'opac', # XXX
org => $org_unit,
identifier => $id,
- password => $password,
- agent => 'remoteauth'
+ password => $password
};
+ my $cuat = $e->retrieve_config_usr_activity_type($config->usr_activity_type);
+ if ($cuat) {
+ $args->{agent} = $cuat->ewho;
+ }
+
my $response = $U->simplereq(
'open-ils.auth',
'open-ils.auth.login', $args);
#!perl
-use Test::More tests => 9; # XXX
+use Test::More tests => 10; # XXX
diag("Tests RemoteAuth patron auth/retrieval");
);
is($staff_login->{textcode}, 'SUCCESS', 'Staff login OK');
my $e = new_editor( authtoken => $staff_login->{payload}->{authtoken} );
+$e->init;
my $client = LWP::UserAgent->new;
$client->ssl_opts( verify_hostname => 0 );
# - response: "+VALID" if auth succeeds
-# TODO: verify user activity based on the above tests
-
+# verify user activity based on the above tests
+my $user = $U->fetch_user_by_barcode( $valid->{barcode} );
+my $basic_activity = $e->search_actor_usr_activity([{usr => $user->id, etype => 1001}]);
+ok(scalar(@$basic_activity) > 0, 'Basic request for valid patron is recorded in user activity');
restrict_to_org BOOLEAN NOT NULL DEFAULT TRUE,
allow_inactive BOOL NOT NULL DEFAULT FALSE,
allow_expired BOOL NOT NULL DEFAULT FALSE,
- block_list TEXT
+ block_list TEXT,
+ usr_activity_type INT REFERENCES config.usr_activity_type(id) ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY DEFERRED
);
CREATE OR REPLACE FUNCTION actor.permit_remoteauth (profile_name TEXT, userid BIGINT) RETURNS TEXT AS $func$
+INSERT INTO config.usr_activity_type (id, ewho, ewhat, ehow, egroup, label) VALUES
+ ( 1001, 'basicauth', 'login', 'apache', 'authen',
+ oils_i18n_gettext(1001, 'RemoteAuth Login: HTTP Basic Authentication', 'cuat', 'label'));
+
-- config for Basic HTTP Authentication (SYS1)
INSERT INTO config.remoteauth_profile
(name, description, context_org, enabled, perm,
- restrict_to_org, allow_inactive, allow_expired, block_list)
+ restrict_to_org, allow_inactive, allow_expired, block_list, usr_activity_type)
VALUES ('Basic', 'Basic HTTP Authentication for SYS1', 2, TRUE, 1,
- TRUE, FALSE, FALSE, NULL);
+ TRUE, FALSE, FALSE, NULL, 1001);