-
Notifications
You must be signed in to change notification settings - Fork 1
How can we programatically terminate a session? #13
Comments
The following comments were pulled from an internal issue I opened elsewhere to log some thoughts. Transferring here as they're relevant and (AFAICT) not particularly sensitive in nature. EDIT: As of this writing, I have yet to hear back from OCLC Support. I have to assume that the outcome will be that we're on our own to come up with a solution. |
Does blocking an IP require restarting EZproxy? Perhaps we can write to a config file to block further sessions, but match existing sessions to their IPs and block those IPs? |
If nothing else, the |
https://help.oclc.org/Library_Management/EZproxy/Configure_resources/RejectIP Perhaps have the main EZproxy config file pull in an include file of rejected IP Address entries? The logic could perhaps check to see when a user was blocked and if it was X minutes past, add a |
Workflow (scratch notes, some logic debugging needed):
At this point legitimate users (other than the blocked user account) are mostly unaffected as we no longer have temporary IP blocks for the specific user account in place. |
@auadamw How does the workflow in #13 (comment) sound? We would potentially need to ingest +1 more files in order to handle this, and would probably want to add an ingest for one more file past that (so +2 overall). We might also drop the The assumption there is that the bulk of the unauthorized behavior would occur during early morning or off-hours and any IP block triggered would minimally impact legitimate users. |
I gave this some more thought and I think we can use an existing tool to lighten the development time/costs for the initial implementation: Modified workflow below.
This allows the brick web app to focus exclusively on:
Direct/measurable upsides:
|
Further refinement:
This workflow should allow for the live sessions to timeout, the user account to be blocked and new sessions to be blocked. |
I missed a response from OCLC Support on April 28th (just found it). Snippet of that response (leaving out the support tech's information):
My response back:
|
Leaving out some emails in the thread, but received one back today confirming that the recommended |
Note to self: Unfortunately I don't recall why I suggested two log files; fail2ban is perfectly capable of (and is intended for) monitoring log files based on patterns. We log to one log file and fail2ban parses the entries looking for a pattern that it has been configured to take action on. When it finds the pattern, it extracts the IP Address and blocks it (temporarily, or "permanently") as indicated previously. At this point I'm trying to figure out exactly how the log messages will be recorded. I've got the templates setup, I figured out when logging occurs, but now I'm trying to figure out when fail2ban will be triggered. Some misc notes below as I think out loud. Every payload received ...
It is tempting to have fail2ban look at the reported log entries, but that removes the ability to ignore specific usernames or IP Addresses and still log that the payload was received. |
Reminder to self: fail2ban requires a timestamp in the source file to determine when the event occurred. This is needed (if I recall correctly) so that it can tell where it last processed. I don't recall if this is also so it can tell when an IP was last blocked (I believe that this state is tracked elsewhere in case the origin log file rotates, etc). Regardless, a list of bare IPs for fail2ban to process is probably not advisable for numerous reasons, though it could be useful to sysadmins who wish to quickly remove a blocked IP. I think for that we'll need to use Ansible or become comfortable using "recipes" to unblock fail2ban-blocked IPs as needed (which is doable to begin with). |
Finished giving a demo earlier to our team where we were given the "go ahead" to install this application on our test EZproxy server for real world testing. After I happened to search GitHub for "ezproxy" and found this project: https://github.com/calvinm/ezproxy-abuse-checker which has a Perl script named if ($block_session) {
system("/opt/ezproxy/ezproxy kill $block_session");
} Strange, but that looks like they're able to terminate a user session using built-in EZproxy functionality. This is the support that the OCLC Support rep told me wasn't available. I suspect the tech I spoke with honestly didn't know about the feature, and it's possible that it's not even documented well. Will dig further. |
OCLC Support misunderstood what I wrote back, so I took our test EZproxy instance and did some testing. The net result is that I was able to retrieve my own login session ID from two different locations:
Further testing would be needed to determine if both files can provide the session ID reliably. I then went through the steps to confirm that I could terminate my session using the retrieved ID: $ sudo ./ezproxy kill
Session must be specified
$ sudo grep -E '^S ' ezproxy.hst
S SESSION_ID_HERE REDACTED
$ sudo ./ezproxy kill SESSION_ID_HERE
Session SESSION_ID_HERE terminated
|
Wrapping up initial release for v0.1.0 today/tomorrow. Going to leave this issue open for further research/testing with the goal of deciding on a "final" (as much as anything can be final) direction for the next release. |
Features of the initial prototype release: - Highly configurable (with more configuration choices to be exposed in the future) - Supports configuration settings from multiple sources - command-line flags - environment variables - configuration file - reasonable default settings - Ignore individual usernames (i.e., prevent disabling listed accounts) - Ignore individual IP Addresses (i.e., prevent disabling associated account) - User configurable logging settings - levels, format and output - Microsoft Teams notifications - generated for multiple events - alert received - disabled user - ignored user - ignored IP Address - error occurred - configurable retries - configurable notifications delay in order to respect remote API limits - Logging - Payload receipt from monitoring system - Action taken due to payload - username ignored - due to username inclusion in ignore file for usernames - due to IP Address inclusion in ignore file for IP Addresses - username disabled - contrib files/content provided to allow for spinning up a demo environment in order to provide a hands-on sense of what this project can do - fail2ban - postfix - docker - Maildev container - brick - rsyslog - systemd - sample JSON payloads for use with curl or other http/API clients - demo environment doc - slides from group presentation/demo Worth noting: - Go modules (vs classic GOPATH setup) - GitHub Actions Workflows which apply linting and build checks - Makefile for general use cases (including local linting) - Note: See README first if building on Windows refs: - GH-26 - GH-21 - GH-16 - GH-15 - GH-13 - GH-12 - GH-11 - GH-7 - GH-6 - GH-4 - GH-1
Features of the initial prototype release: - Highly configurable (with more configuration choices to be exposed in the future) - Supports configuration settings from multiple sources - command-line flags - environment variables - configuration file - reasonable default settings - Ignore individual usernames (i.e., prevent disabling listed accounts) - Ignore individual IP Addresses (i.e., prevent disabling associated account) - User configurable logging settings - levels, format and output - Microsoft Teams notifications - generated for multiple events - alert received - disabled user - ignored user - ignored IP Address - error occurred - configurable retries - configurable notifications delay in order to respect remote API limits - Logging - Payload receipt from monitoring system - Action taken due to payload - username ignored - due to username inclusion in ignore file for usernames - due to IP Address inclusion in ignore file for IP Addresses - username disabled - contrib files/content provided to allow for spinning up a demo environment in order to provide a hands-on sense of what this project can do - fail2ban - postfix - docker - Maildev container - brick - rsyslog - systemd - sample JSON payloads for use with curl or other http/API clients - demo environment doc - slides from group presentation/demo Worth noting: - Go modules (vs classic GOPATH setup) - GitHub Actions Workflows which apply linting and build checks - Makefile for general use cases (including local linting) - Note: See README first if building on Windows refs: - GH-26 - GH-21 - GH-16 - GH-15 - GH-13 - GH-12 - GH-11 - GH-7 - GH-6 - GH-4 - GH-1
Features of the initial prototype release: - Highly configurable (with more configuration choices to be exposed in the future) - Supports configuration settings from multiple sources - command-line flags - environment variables - configuration file - reasonable default settings - Ignore individual usernames (i.e., prevent disabling listed accounts) - Ignore individual IP Addresses (i.e., prevent disabling associated account) - User configurable logging settings - levels, format and output - Microsoft Teams notifications - generated for multiple events - alert received - disabled user - ignored user - ignored IP Address - error occurred - configurable retries - configurable notifications delay in order to respect remote API limits - Logging - Payload receipt from monitoring system - Action taken due to payload - username ignored - due to username inclusion in ignore file for usernames - due to IP Address inclusion in ignore file for IP Addresses - username disabled - contrib files/content provided to allow for spinning up a demo environment in order to provide a hands-on sense of what this project can do - fail2ban - postfix - docker - Maildev container - brick - rsyslog - systemd - sample JSON payloads for use with curl or other http/API clients - demo environment doc - slides from group presentation/demo Worth noting: - Go modules (vs classic GOPATH setup) - GitHub Actions Workflows which apply linting and build checks - Makefile for general use cases (including local linting) - Note: See README first if building on Windows refs: - GH-26 - GH-21 - GH-16 - GH-15 - GH-13 - GH-12 - GH-11 - GH-7 - GH-6 - GH-4 - GH-1
Spun off GH-31 for that research instead of dragging this existing issue across milestones. Leaving this at the v0.1.0 milestone since the bulk of the work/notes reflects the |
Blocking a user account can be done by adding the account to a specific flat-file referenced by EZproxy, but historically we've had to login to the admin panel to terminate a session. Is there an API we can use? If we can't kill existing sessions, perhaps we can match against an IP Address and block that instead?
References:
The text was updated successfully, but these errors were encountered: