From fec939adca333e03751f3989ac3496d583cd3a95 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 19 Aug 2013 09:24:17 -0400 Subject: [PATCH] Safe auth token activity logging Expand safe token generation to include user user ID in the cached data, which can be retrieved later for activity logging. Add activity logging directly to the open-ils.actor.safe_token.home_lib.shortname API. --- .../src/perlmods/lib/OpenILS/Application/Actor.pm | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index dde8f4a8fe..ca66e50b57 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -2770,14 +2770,15 @@ sub session_safe_token { $cache ||= OpenSRF::Utils::Cache->new("global", 0); - # Add more like the following if needed... - $cache->put_cache( - "safe-token-home_lib-shortname-$safe_token", - $e->retrieve_actor_org_unit( - $e->requestor->home_ou - )->shortname, - 60 * 60 - ); + # add more user fields as needed + $cache->put_cache( + "safe-token-user-$safe_token", { + id => $e->requestor->id, + home_ou_shortname => $e->retrieve_actor_org_unit( + $e->requestor->home_ou)->shortname, + }, + 60 * 60 + ); return $safe_token; } @@ -2795,10 +2796,14 @@ __PACKAGE__->register_method( ); sub safe_token_home_lib { - my( $self, $conn, $safe_token ) = @_; + my( $self, $conn, $safe_token, $who ) = @_; + $cache ||= OpenSRF::Utils::Cache->new("global", 0); - $cache ||= OpenSRF::Utils::Cache->new("global", 0); - return $cache->get_cache( 'safe-token-home_lib-shortname-'. $safe_token ); + my $blob = $cache->get_cache("safe-token-user-$safe_token"); + return unless $blob; + + $U->log_user_activity($blob->{id}, $who, 'verify'); + return $blob->{home_ou_shortname}; } -- 2.11.0