Created
February 27, 2024 15:18
-
-
Save jesusbagpuss/fb4c01825f5da53ac5ddb2d6a6fa69d3 to your computer and use it in GitHub Desktop.
EPrints: Add user to Apache request object so it gets logged in Apache access logfile (as %u).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ADD THIS FILE TO e.g. [EPRINT_ROOT]/archives/[ARCHIVE_ID]/cfg/cfg.d/ | |
# | |
# Add username to Apache Request object so it gets added to Apache access.log file | |
# NB This will not cause the username to be logged in the EPrints access dataset. | |
use EPrints::Const; | |
$c->add_trigger( EP_TRIGGER_URL_REWRITE, sub { | |
my( %args ) = @_; | |
my( $r, $repo ) = @args{qw( request repository )}; | |
if( defined $repo->current_user && !defined $r->user ) | |
{ | |
$r->user( $repo->current_user->get_value( "username" ) ); | |
} | |
# No return value - so next URL_REWRITE trigger will be run | |
}, priority => 50); | |
# priority needs to be lower than other REWRITE triggers so it gets run sooner in the request handling. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment