[open-ils-commits] [GIT] Evergreen ILS branch master updated. b2958a8bb6145c5aa2eee8aa0b7b6a306732785a

Evergreen Git git at git.evergreen-ils.org
Mon Oct 31 16:33:02 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  b2958a8bb6145c5aa2eee8aa0b7b6a306732785a (commit)
      from  9c54bcb71017d3679841b51457069bbfd4b55c75 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b2958a8bb6145c5aa2eee8aa0b7b6a306732785a
Author: Jason Stephenson <jstephenson at mvlc.org>
Date:   Mon Oct 31 15:48:38 2011 -0400

    Add authentication capability to OpenILS::Utils::Cronscript.
    
    This allows the client script to call authenticate with a hash ref of
    user information so that the user can login and get an authtoken if
    needed.
    
    It also stores the authtoken and authtime values for later retrieval.
    
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
    Signed-off-by: Dan Scott <dscott at laurentian.ca>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/Cronscript.pm.in b/Open-ILS/src/perlmods/lib/OpenILS/Utils/Cronscript.pm.in
index 73281fb..9e5e8e5 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/Cronscript.pm.in
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/Cronscript.pm.in
@@ -38,6 +38,9 @@ use File::Basename qw/fileparse/;
 use Data::Dumper;
 use Carp;
 
+# Added for authentication
+use Digest::MD5 qw/md5_hex/;
+
 our @extra_opts = (     # additional keys are stored here
     # 'addlopt'
 );
@@ -282,6 +285,52 @@ sub editor {
     return new_editor(@_);
 }
 
+# Authenticate with the open-ils.auth module.
+# Takes a hash ref of arguments:
+# {
+#   username => username to authenticate as,
+#   password => the user's password,
+#   workstation => the workstation to use (optional),
+#   type => the type of login (optional, but defaults to staff)
+# }
+#
+# returns the authtoken or undef on failure.
+# Also stores the authtoken and authtime as fields on the object.
+sub authenticate {
+    my $self = shift or return;
+    my $args = shift or return;
+    if ($args && ref($args) eq 'HASH') {
+        my $session = $self->session('open-ils.auth');
+        my $seed = $session->request('open-ils.auth.authenticate.init',
+                                    $args->{'username'})->gather(1);
+        $args->{password} = md5_hex($seed . md5_hex($args->{password}));
+        my $req = $session->request('open-ils.auth.authenticate.complete',
+                                    $args);
+        my $response = $req->gather(1);
+        if ($response && ref($response) eq 'HASH' && $response->{payload}) {
+            $self->{authtoken} = $response->{payload}->{authtoken};
+            $self->{authtime} = $response->{payload}->{authtime};
+        } else {
+            $self->{authtoken} = undef;
+            $self->{authtime} = undef;
+        }
+        $session->disconnect();
+        return $self->authtoken;
+    } else {
+        return undef;
+    }
+}
+
+sub authtoken {
+    my $self = shift;
+    return $self->{authtoken};
+}
+
+sub authtime {
+    my $self = shift;
+    return $self->{authtime};
+}
+
 1;
 __END__
 

-----------------------------------------------------------------------

Summary of changes:
 .../perlmods/lib/OpenILS/Utils/Cronscript.pm.in    |   49 ++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list