#!/usr/bin/perl
+use OpenSRF::AppSession;
+
+# default ingress value for all Apache/mod_perl clients
+OpenSRF::AppSession->ingress('apache');
+
use OpenILS::WWW::Exporter qw( /openils/conf/opensrf_core.xml );
use OpenILS::WWW::SuperCat qw( /openils/conf/opensrf_core.xml );
use OpenILS::WWW::AddedContent qw( /openils/conf/opensrf_core.xml );
use OpenSRF::EX qw(:try);
use OpenSRF::System;
+use OpenSRF::AppSession;
my $bootstrap = '/openils/conf/opensrf_core.xml';
my $cgi = new CGI;
my $u = $cgi->param('user');
my $usrname = $cgi->param('usrname');
my $barcode = $cgi->param('barcode');
+my $agent = $cgi->param('agent'); # optional, but preferred
my $p = $cgi->param('passwd');
print $cgi->header(-type=>'text/html', -expires=>'-1d');
+OpenSRF::AppSession->ingress('remoteauth');
OpenSRF::System->bootstrap_client( config_file => $bootstrap );
if (!($u || $usrname || $barcode) || !$p) {
if ($seed) {
my $response = OpenSRF::AppSession
->create('open-ils.auth')
- ->request( 'open-ils.auth.authenticate.complete', { $nametype => $u, password => md5_hex($seed . md5_hex($p)), type => 'opac' })
+ ->request( 'open-ils.auth.authenticate.verify',
+ { $nametype => $u, password => md5_hex($seed . md5_hex($p)), type => 'opac', agent => $agent })
->gather(1);
- if ($response->{payload}->{authtoken}) {
- my $user = OpenSRF::AppSession
- ->create('open-ils.auth')
- ->request( 'open-ils.auth.session.retrieve', $response->{payload}->{authtoken} )
- ->gather(1);
- if (ref($user) eq 'HASH' && $user->{ilsevent} == 1001) {
- print '+NO';
- } else {
+ if ($response) {
+ if ($response->{ilsevent} == 0) {
print '+VALID';
+ } else {
+ print '+NO';
}
} else {
- print '+NO';
+ print '+BACKEND_ERROR';
}
} else {
print '+BACKEND_ERROR';
use OpenILS::SIP::Transaction::FeePayment;
use OpenSRF::System;
+use OpenSRF::AppSession;
use OpenILS::Utils::Fieldmapper;
use OpenSRF::Utils::SettingsClient;
use OpenILS::Application::AppUtils;
$target_encoding = $institution->{implementation_config}->{encoding} || 'ascii';
syslog('LOG_DEBUG', "OILS: loading bootstrap config: $bsconfig");
+
+ # ingress will persist throughout
+ OpenSRF::AppSession->ingress('sip2');
local $/ = "\n"; # why?
OpenSRF::System->bootstrap_client(config_file => $bsconfig);
my $args = {
username => $username,
password => md5_hex($seed . md5_hex($password)),
- type => ($persist) ? 'persist' : 'opac'
+ type => ($persist) ? 'persist' : 'opac',
+ agent => 'opac'
};
my $bc_regex = $ctx->{get_org_setting}->($org_unit, 'opac.barcode_regex');
my $response = OpenSRF::AppSession
->create("open-ils.auth")
->request( 'open-ils.auth.authenticate.complete',
- { $nametype => $username,
+ { $nametype => $username, agent => 'authproxy',
password => md5_hex($seed . md5_hex($password)),
type => $type })
->gather(1);
my $response = OpenSRF::AppSession
->create("open-ils.auth")
->request( 'open-ils.auth.authenticate.complete',
- { $nametype => $username,
+ { $nametype => $username, agent => 'authproxy',
password => md5_hex($seed . md5_hex($password)),
type => $type })
->gather(1);
# Bootstrap and load config settings
sub child_init {
$__inited = 1;
+ OpenSRF::AppSession->ingress('xmlrpc');
OpenSRF::System->bootstrap_client( config_file => $bs_config );
my $sclient = OpenSRF::Utils::SettingsClient->new();
my $idl = $sclient->config_value("IDL");
$logger->debug("XML-RPC: allowed services @$services");
OpenILS::Utils::Fieldmapper->require;
Fieldmapper->import(IDL => $idl);
+ OpenSRF::AppSession->ingress('apache');
}
sub run_request {
my( $service, $method, @args ) = @_;
+
+ # since multiple Perl clients run within mod_perl,
+ # we must set our ingress before each request.
+ OpenSRF::AppSession->ingress('xmlrpc');
+
my $ses = OpenSRF::AppSession->create( $service );
- #my $data = $ses->request($method, @args)->gather(1);
my $data = [];
my $req = $ses->request($method, @args);
push( @$data, $resp->content );
}
+ # recover the default Apache/http ingress to avoid
+ # polluting other mod_perl clients w/ our ingress value.
+ OpenSRF::AppSession->ingress('apache');
+
return [] if scalar(@$data) == 0;
return wrap_perl($$data[0])
if scalar(@$data) == 1 and $method !~ /.atomic$/og;
username : null,
passwd : null,
login_type : 'opac',
+ login_agent : null,
location : null,
authtoken : null,
authtime : null,
this.authtoken = kwargs.authtoken || openils.User.authtoken;
this.authtime = kwargs.authtime || openils.User.authtime;
this.login_type = kwargs.login_type;
+ this.login_agent = kwargs.login_agent || openils.User.default_login_agent || 'staffclient';
this.location = kwargs.location;
this.authcookie = kwargs.authcookie || openils.User.authcookie;
this.permOrgStoreCache = {}; /* permName => permOrgUnitStore map */
return req.recv().content();
}
},
+
+ /**
+ * Tests the given username and password. This version is async only.
+ */
+ auth_verify : function(args, onComplete) {
+ var _u = this;
+ if (!args) args = {};
+ if (!args.username) args.username = _u.username;
+ if (!args.passwd) args.passwd = _u.passwd;
+ if (!args.agent) args.agent = _u.login_agent;
+ if (!args.type) args.type = _u.type;
+
+ var initReq = OpenSRF.CachedClientSession('open-ils.auth').request('open-ils.auth.authenticate.init', args.username);
+
+ initReq.oncomplete = function(r) {
+ var seed = r.recv().content();
+ var loginInfo = {
+ type : args.type,
+ username : args.username,
+ barcode : args.barcode,
+ password : hex_md5(seed + hex_md5(args.passwd)),
+ agent : args.agent,
+ };
+
+ var authReq = OpenSRF.CachedClientSession('open-ils.auth').request('open-ils.auth.authenticate.verify', loginInfo);
+ authReq.oncomplete = function(rr) {
+ var data = rr.recv().content();
+ var evt = openils.Event.parse(data);
+ if (evt && evt.code == 0) onComplete(true);
+ else onComplete(false);
+ }
+ authReq.send();
+ }
+
+ initReq.send();
+ },
/**
if (!args.username) args.username = _u.username;
if (!args.passwd) args.passwd = _u.passwd;
if (!args.type) args.type = _u.login_type;
+ if (!args.agent) args.agent = _u.login_agent;
if (!args.location) args.location = _u.location;
var initReq = OpenSRF.CachedClientSession('open-ils.auth').request('open-ils.auth.authenticate.init', args.username);
username : args.username,
password : hex_md5(seed + hex_md5(args.passwd)),
type : args.type,
+ agent : args.agent,
org : args.location,
workstation : args.workstation
};
if (!args.username) args.username = _u.username;
if (!args.passwd) args.passwd = _u.passwd;
if (!args.type) args.type = _u.login_type;
+ if (!args.agent) args.agent = _u.login_agent;
if (!args.location) args.location = _u.location;
var seed = fieldmapper.standardRequest(
username : args.username,
password : hex_md5(seed + hex_md5(args.passwd)),
type : args.type,
+ agent : args.agent,
org : args.location,
workstation : args.workstation,
};
openils.User.authtoken = null;
openils.User.authtime = null;
openils.User.authcookie = null;
+ openils.User.default_login_agent = null; // global agent override
openils.User.localeStrings =
dojo.i18n.getLocalization("openils.User", "User");
// This setting only comes into play if COPY_NOT_AVAILABLE is in the SET_AUTO_OVERRIDE_EVENTS list
const SET_BLOCK_CHECKOUT_ON_COPY_STATUS = 'circ.selfcheck.block_checkout_on_copy_status';
+// set before the login dialog is rendered
+openils.User.default_login_agent = 'selfcheck';
+
function SelfCheckManager() {
this.cgi = new openils.CGI();
// patron password is required. Verify it.
- var res = fieldmapper.standardRequest(
- ['open-ils.actor', 'open-ils.actor.verify_user_password'],
- {params : [this.authtoken, barcode, usrname, hex_md5(passwd)]}
+ var self = this;
+ new openils.User().auth_verify(
+ { username : usrname, barcode : barcode,
+ type : 'opac', passwd : passwd, agent : 'selfcheck' },
+ function(OK) {
+ if (OK) {
+ self.fetchPatron(barcode, usrname);
+
+ } else {
+ // auth verify failed
+ self.handleAlert(
+ dojo.string.substitute(localeStrings.LOGIN_FAILED, [barcode_or_usrname]),
+ false, 'login-failure'
+ );
+ self.drawLoginPage();
+ }
+ }
);
- if(res == 0) {
- // user-not-found results in login failure
- this.handleAlert(
- dojo.string.substitute(localeStrings.LOGIN_FAILED, [barcode_or_usrname]),
- false, 'login-failure'
- );
- this.drawLoginPage();
- return;
- }
- }
+ } else {
+ this.fetchPatron(barcode, usrname);
+ }
+};
+
+SelfCheckManager.prototype.fetchPatron = function(barcode, usrname) {
var patron_id = fieldmapper.standardRequest(
['open-ils.actor', 'open-ils.actor.user.retrieve_id_by_barcode_or_username'],
if(evt || inactiveCard) {
this.handleAlert(
- dojo.string.substitute(localeStrings.LOGIN_FAILED, [barcode_or_usrname]),
+ dojo.string.substitute(localeStrings.LOGIN_FAILED, [barcode || usrname]),
false, 'login-failure'
);
this.drawLoginPage();
var args = {
password : hex_md5(seed + hex_md5(passwd)),
type : "opac",
- org : getOrigLocation()
+ org : getOrigLocation(),
+ agent : 'opac'
};
r = fetchOrgSettingDefault(globalOrgTree.id(), 'opac.barcode_regex');
)
),
'type' : 'temp',
+ 'agent' : 'staffclient'
};
if (data.ws_info[ this.view.server_prompt.value ]) {