feat: add a logging endpoint, cookie HTTP logging handler #467
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the prototype branch to add a protected endpoint for receiving logging data, and a logging handler design which is able to send requests to that endpoint. See src/proto/utils.py.
The handler has a general design which can send cookies with requests. That could include session cookies, but is not a requirement. With respect to the flask prototype though, it must include an authenticated session cookie since the endpoint is protected. If "strong" session protection is in use, one must also be careful to always use the same User-Agent header value, otherwise flask-login will reject the cookie. For that reason, the handler accepts a user_agent argument.
With respect to prototype authentication, it is up to the user of the logging handler to establish a login session. Any cookie(s) from that must be passed to the handler when it is set up (and possibly a correct user agent value too). The handler itself is agnostic to where the cookies come from.
The implementation uses only standard library APIs. That makes it simple to incorporate into other codebases (which is not the plan here, but still a nice thing to think about when designing software components).