return $self->{authtoken} if ($self->fetch_session); # fetch the session
}
- my $nonce = rand($$);
- my $seed = $U->simplereq(
- 'open-ils.auth',
- 'open-ils.auth.authenticate.init', $username, $nonce );
-
- my $response = $U->simplereq(
- 'open-ils.auth',
- 'open-ils.auth.authenticate.complete',
- {
- username => $username,
- password => md5_hex($seed . md5_hex($password)),
- type => 'opac',
- nonce => $nonce
- }
- );
+ my $auth_proxy_enabled = 0;
+ eval {
+ $auth_proxy_enabled = $U->simplereq(
+ 'open-ils.auth_proxy',
+ 'open-ils.auth_proxy.enabled'
+ );
+ };
+
+ my $response;
+ if ($auth_proxy_enabled) {
+ $response = $U->simplereq(
+ 'open-ils.auth_proxy',
+ 'open-ils.auth_proxy.login',
+ {
+ username => $username,
+ password => $password,
+ type => 'sip',
+ }
+ );
+ } else {
+ my $nonce = rand($$);
+ my $seed = $U->simplereq(
+ 'open-ils.auth',
+ 'open-ils.auth.authenticate.init', $username, $nonce );
+
+ $response = $U->simplereq(
+ 'open-ils.auth',
+ 'open-ils.auth.authenticate.complete',
+ {
+ username => $username,
+ password => md5_hex($seed . md5_hex($password)),
+ type => 'opac',
+ nonce => $nonce
+ }
+ );
+ }
if( my $code = $U->event_code($response) ) {
my $txt = $response->{textcode};
my ($self, $pwd) = @_;
syslog('LOG_DEBUG', 'OILS: Patron->check_password()');
return 0 unless (defined $pwd and $self->{user});
- return md5_hex($pwd) eq $self->{user}->passwd;
+
+ my $auth_proxy_enabled = 0;
+ eval {
+ $auth_proxy_enabled = $U->simplereq(
+ 'open-ils.auth_proxy',
+ 'open-ils.auth_proxy.enabled'
+ );
+ };
+
+ if ($auth_proxy_enabled) {
+ my $response = $U->simplereq(
+ 'open-ils.auth_proxy',
+ 'open-ils.auth_proxy.login',
+ {
+ username => $self->{user}->usrname,
+ password => $pwd,
+ type => 'sip',
+ }
+ );
+ if ($U->event_code($response)) {
+ return 0;
+ } else {
+ # don't leave an extra session hanging around
+ # for this user
+ my $ses = $response->{payload}->{authtoken};
+ $U->simplereq(
+ 'open-ils.auth',
+ 'open-ils.auth.session.delete',
+ $ses
+ );
+ return 1;
+ }
+ } else {
+ return md5_hex($pwd) eq $self->{user}->passwd;
+ }
}
sub currency { # not really implemented