depends on my pull request to snap-core.
Log user from basic authentication header
Just a few remarks:
I only implemented basic authentication since that's what I use in a REST application (the requests are over SSL).
If one is worried about content in the log file, doesn't one also need to sanitize the other elements? For example, control characters in the user agent or the url are passed through to the log.
I'm not sure we want to add this overhead to every request, no. If you're going to make every thread pay a tax here, at least make it a cheaper tax -- add a field rqUser to the Request type (and a setRqUser :: ByteString -> Request -> Request) and update this field when you authenticate the user.
setRqUser :: ByteString -> Request -> Request
If you do it that way, logging the user name is a Maybe decons (and other authentication methods can reuse the field) instead of a HashMap lookup that usually fails + a bunch of http-basic-auth-specific string twiddling we probably did once already.
Limit size of http headers to 256kB
Revert obviously busted "Limit size of http headers to 256kB"
This reverts commit a522c4c.
Fix bug in 'Limit size of http headers to 256kB'
Upgrade lower bound dependency of enumerator to 0.4.15 (we need Data.…
@gregorycollins I could add the rqUser field, but then I would want to change the semantics of logging in Snap.Internal.Http.Server.httpSession. Currently, it logs the unmodified request, and not the request returned by the handler. Apart from a semantic change, it means holding on to the unmodified request until after the response has been served. I don't know if this could change the space behavior. What do you think?
More problematic is that at least Snap.Internal.Routing.route runs the handler in localRequest, which means that all changes to the request are thrown away.
It would a lot easier to put a user field in the Response, although it might seem a bit counter-intuitive. How would you feel about that?
@carlssonia I'd have no problem with changing the way anything is logged inside snap-server, logging is something we haven't spent a lot of time on in here. Space behaviour is not an issue here, Request objects are relatively small (and we don't hold on to the request body itself in there, of course).
After reading your message, I actually agree that it might be easier to put a user field in the Response, but I'm not sure it makes semantic sense to do this. We probably want to do some thinking about this before moving in any particular direction; until it feels like we have the right design, I'm not sure that we should move forward.
@gregorycollins - Sorry for letting this sit for this long unattended!
Any chance that a patch with a user field in Response would be acceptable? I would love to get something working here since it's difficult to replicate the logging function outside Snap.Internal.Http.Server. This is because stuff like response content length is only available there.
Another approach could be to add a Response field that is a custom logging function, say with the signature of System.Fastlogger.combinedLogEntry. If Snap.Internal.Http.Server.logA' abstracted out its use of combinedLogEntry and used the one in the response (which would default to combinedLogEntry), client code could add arbitrary information to the access log, so it would be more generally useful.
Would you prefer this more general approach?