Class MaskingRequestLog
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
com.iizix.jetty.MaskingRequestLog
- All Implemented Interfaces:
RequestLog, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle
A request log that masks secrets before another request log writes the line (work order CC-PWA-V5F-APPURL-LEGACY, design CC-DESIGN-APP-URL-V2 section 3.2, decision AU-7): the VALUE of every query member named
pw, password, prt, v, epw or hash is replaced by ***, for every request - the legacy page, the page under /app/, the WebSocket upgrade and iiziRun's app.json alike. The names are the password members of the legacy URL, the password reset token and the e-mail verification token of SignIn, the Diffie-Hellman-encrypted password of iiziRun, and the reconnection hash. Everything else of the line - the application, the language, the session ID - is written as it came, which is why the log format keeps its query.The query of the Referer header is masked the same way: a Browser sends the whole URL of the page as the Referer of every same-origin request the page makes, so a secret in the address bar would otherwise be logged once per resource of the page.
The wrapped log is a bean of this one: it is started and stopped with it, as the server starts and stops the request log it is given.
maskQuery(String) is the one masking helper of the server: every other line that writes a raw query to a log calls it.
- Author:
- Christopher Mindus
Nested Class Summary
Nested classes/interfaces inherited from class AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface Dumpable
Dumpable.DumpableContainer, Dumpable.DumpAppendableNested classes/interfaces inherited from interface LifeCycle
LifeCycle.ListenerNested classes/interfaces inherited from interface RequestLog
RequestLog.Collection, RequestLog.WriterField Summary
FieldsModifier and TypeFieldDescriptionstatic final StringWhat replaces the value of a masked query member.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionstatic booleanisMaskedName(String name) Tests whether the name of a query member is one whose value is masked: for a caller that holds the members apart and writes them to a log itself.voidLogs a request through the wrapped log, which sees the request with its secrets masked.static StringMasks the secrets of a raw query string: the value of every member namedpw,password,prt,v,epworhashis replaced byMASK.static StringMasks the secrets of the query of a URL, asmaskQuery(String)does: for theRefererheader.Methods inherited from class ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, addManaged, contains, destroy, doStart, doStop, dump, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeansMethods inherited from class AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Container
getCachedBeans, getEventListenersMethods inherited from interface Dumpable.DumpableContainer
isDumpable
Field Details
MASK
Constructor Details
MaskingRequestLog
Wraps a request log.- Parameters:
log- The request log that writes the line, nevernull.
Method Details
log
Logs a request through the wrapped log, which sees the request with its secrets masked.- Specified by:
login interfaceRequestLog- Parameters:
request- The request.response- The response.
maskQuery
Masks the secrets of a raw query string: the value of every member namedpw,password,prt,v,epworhashis replaced byMASK. A name is compared decoded and without regard to case; a member without'='has no value and is kept. Nothing else is changed: the members stay in their order, encoded as they came.- Parameters:
query- The query, without the question mark,nullfor none.- Returns:
- The query to write to a log: the same string when it has nothing to mask,
nullfornull.
maskURL
Masks the secrets of the query of a URL, asmaskQuery(String)does: for theRefererheader. The fragment, if any, is kept.- Parameters:
url- The URL,nullfor none.- Returns:
- The URL to write to a log: the same string when it has nothing to mask,
nullfornull.
isMaskedName
Tests whether the name of a query member is one whose value is masked: for a caller that holds the members apart and writes them to a log itself.- Parameters:
name- The name, encoded as it came or decoded.- Returns:
- true when masked.