This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
Use native EZproxy support to terminate sessions #73
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.
MISSING
Light editing has been applied to cover new flags, config file settings, etc., but a larger refresh is still needed to introduce native termination support alongside the existing fail2ban integration.
A few known TODO items:
doc.go
fileCHANGELOG.md
README.md
docs/*.md
doc filesBACKSTORY
Not long after giving a demo on using brick + fail2ban to timeout
existing sessions, I stumbled across another project on GitHub which
uses
ezproxy kill
to terminate an active user session:Despite OCLC Support indicating otherwise, native support for
terminating user sessions was clearly available. This built-in support
offers a much safer/localized effect vs banning the IP associated
with a reported account; banning the IP has the potential to have a
much larger splash radius blocking legitimate user accounts.
The primary developer for the
calvinm/ezproxy-abuse-checker
projectconfirmed that they learned of this support on the EZProxy mailing
list: calvinm/ezproxy-abuse-checker#1
This is encouraging, as I am (at least a little) optimistic that this
unpublished support will persist in future versions, at least until
official, fully documented and supported functionality for terminating
sessions is included.
IMPLEMENTATION
This commit adds (optional) support for terminating user sessions
using the official EZProxy binary already present on EZproxy servers.
The fully-qualified location of this binary is configurable via
command-line flag, environment variable or TOML-format configuration
file. Additional settings are provided to tune the sessions search
process such as configurable retries and search delay.
The session termination process involves reading current sessions from
the Active Users and Hosts "state" file that EZproxy uses to track
sessions and hosts managed by EZProxy and then using the EZproxy
binary to terminate each session via the
kill
subcommand.As part of the early development efforts I initially tried to use the
latest Audit logs to pull session IDs, but quickly realized that while
the format was easier to parse, it was far less stable due to log
rotation and the need to resolve the active state ourselves (logins
minus logouts, minus timeouts, etc). Some of that support still
remains as of this commit, but may be removed in a future release if
found to not be needed. As of this writing I believe it can still be
used as part of interacting with a future endpoint.
The aforementioned search delay and retry settings are provided to
work around an observed race condition between EZproxy recording state
changes and other applications (such as ours) attempting to read the
current state. The delay in EZproxy writing the changes to disk (or
kernel settings?) may result in our application attempting to
terminate sessions related to a monitoring system report and not
finding them within the Active Users and Hosts "state" file.
The defaults attempt to strike a balance between waiting a little
longer in order to "find" and terminate those sessions vs moving on
with current findings. The defaults may need to be adjusted further
depending on the production environment.
TEAMS NOTIFICATIONS
Minor changes in an effort to better clarify the purpose of the lead-in
content:
step X of Y
labeling to notification titlesto generate primary "summary" text
dedicated single purpose vs blend of Note and Error field values as
before
ADDITIONAL SUPPORT
During development, the necessary code to interact with EZProxy was
first created as a local package, but was eventually moved to a
separate module in order to break out the changes for separate use.
See the
atc0005/go-ezproxy
project for further information on thatmodule.
Two separate binaries were created during testing:
mock
ezproxy
binary which returns known return codes and results +some extra to help condition validation checks for what I believe
will be unknown/unpublished return codes I've yet to encounter
es
binary used to search for and optionally terminate active usersessions for a specified username. This binary supports the same
search retry and delay settings as
brick
REFERENCES