Package io.jenkins.plugins.auditlogger
Class RequestHolder
java.lang.Object
io.jenkins.plugins.auditlogger.RequestHolder
Thread-local holder for the current HTTP request, plus a cross-request
pending-auth-entry map for deferred User-Agent enrichment.
The pending map is needed because form/SSO logins trigger authenticated2()
inside Spring Security's filter chain, which then sends a 302 redirect
without continuing to PluginServletFilter. The browser follows the redirect,
and THAT request goes through AuditRequestCapture where we can read User-Agent.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcacheUserIp(String username, String ip) Cache a user's IP address from a known request context.static voidclear()static AuditLogEntryconsumePendingAuthEntry(String username) Consume (get and remove) the pending auth entry for a given username.static List<AuditLogEntry> Drain all expired pending entries so they can be written to the log even without enrichment.static jakarta.servlet.http.HttpServletRequestget()static StringGet the pre-chain authenticated username (survives SYSTEM impersonation).static StringgetCachedUserIp(String username) Get the last-known IP for a user (from login/request).static voidset(jakarta.servlet.http.HttpServletRequest request) static voidsetAuthenticatedUser(String username) Store the authenticated username before filter chain processing.static voidsetPendingAuthEntry(String username, AuditLogEntry entry) Store an auth event entry for later enrichment, keyed by username.
-
Method Details
-
set
public static void set(jakarta.servlet.http.HttpServletRequest request) -
get
public static jakarta.servlet.http.HttpServletRequest get() -
clear
public static void clear() -
setAuthenticatedUser
Store the authenticated username before filter chain processing. -
getAuthenticatedUser
Get the pre-chain authenticated username (survives SYSTEM impersonation). -
cacheUserIp
Cache a user's IP address from a known request context. -
getCachedUserIp
Get the last-known IP for a user (from login/request). Returns null if unknown. -
setPendingAuthEntry
Store an auth event entry for later enrichment, keyed by username. -
consumePendingAuthEntry
Consume (get and remove) the pending auth entry for a given username. Returns null if none/expired. -
drainExpiredEntries
Drain all expired pending entries so they can be written to the log even without enrichment. This prevents data loss when enrichment never happens (e.g., form login where the redirect follow doesn't reach AuditRequestCapture).
-