Git Product home page Git Product logo

go-ezproxy's Introduction

go-ezproxy

Go library and tooling for working with EZproxy.

Latest Release Go Reference go.mod Go version Lint and Build Project Analysis

Table of contents

Project home

See our GitHub repo for the latest code, to file an issue or submit improvements for review and potential inclusion into the project.

Status

Alpha; very much getting a feel for how the project will be structured long-term and what functionality will be offered.

The existing functionality was added specifically to support the in-development atc0005/brick. This library is subject to change in order to better support that project.

Overview

This library is intended to provide common EZproxy-related functionality such as reporting or terminating active login sessions (either for all usernames or specific usernames), filtering (or not) audit file entries or traffic patterns (not implemented yet) for specific usernames or domains.

See the Input file formats doc for additional details regarding known and supported input file formats.

Just to be perfectly clear:

  • this library is intended to supplement the provided functionality of the official OCLC-developed/supported EZproxy application, not in any way replace it.
  • this library is not in any way associated with OCLC, EZproxy or other services offered by OCLC.

Features

Current

  • generate a list of audit records for session-related events

    • for all usernames
    • for a specific username
  • generate a list of active sessions using the audit log

    • using entires without a corresponding logout event type
  • generate a list of active sessions using the active file

    • for all usernames
    • for a specific username
  • terminate user sessions

    • single user session
    • bulk user sessions

Missing

  • Anything to do with traffic log entries
  • Examples

Changelog

See the CHANGELOG.md file for the changes associated with each release of this application. Changes that have been merged to master, but not yet an official release may also be noted in the file under the Unreleased section. A helpful link to the Git commit history since the last official release is also provided for further review.

Documentation

Please see:

If something doesn't make sense, please file an issue and note what is (or was) unclear.

Examples

Please see our GoDoc coverage for general usage and the examples doc for a list of applications developed using this module.

License

Taken directly from the LICENSE and NOTICE.txt files:

Copyright 2020-Present Adam Chalkley

https://github.com/atc0005/go-ezproxy/blob/master/LICENSE

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

References

Related projects

Official EZproxy docs

go-ezproxy's People

Contributors

atc0005 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

go-ezproxy's Issues

Deferred file close operations report "file already closed" error messages

Introduced in GH-34 (commit 7dc98a6):

defer func() {
if err := f.Close(); err != nil {
ezproxy.Logger.Printf(
"filterEntries: failed to close file %q: %s",
afr.Filename,
err.Error(),
)
}
}()

defer func() {
if err := f.Close(); err != nil {
ezproxy.Logger.Printf(
"AllSessionEntries: failed to close file %q: %s",
alr.Filename,
err.Error(),
)
}
}()

This catches and logs even the "errors" that we consider to be normal in a deferred function call that attempts to close a file that has potentially already been closed: file already closed

References

README | Update badges to link to the applicable workflow

While useful, the current status badges link out to the SVG used to provide the current status, not the workflow results themselves.

Update all badges to use a syntax similar to 'GoDoc' or 'Latest Release' so that the badge displays, but also functions as a "GoTo" button as well.

Loose goals for packages

The notes below are from a Google Keep entry I made almost two weeks ago. Some of the goals have been met, others have not. At some point I can extract incomplete items from these lists and create new feature issues in their own right.


Active Users and Hosts file

  • Active sessions for username or IP address
  • Total active sessions
  • Total current sessions active for a user

Audit Log

  • Events from Audit Log based on the provided session, username, or IP Address
  • Login failures for an IP Address or username

Traffic log

  • Last X minutes for username, IP address, or session ID (once we enable that)
  • Total download size for a user per domain

golint | comment on exported const XYZ should be of the form XYZ ...

activefile/activefile.go:32:2: comment on exported const `SessionLinePrefix` should be of the form `SessionLinePrefix ...` (golint)
        // All lines containing a session ID (among other details) begin with this
        ^
activefile/activefile.go:36:2: comment on exported const `SessionLineEvenNumbered` should be of the form `SessionLineEvenNumbered ...` (golint)
        // Indicate that this line should be found on even numbered lines
        ^
activefile/activefile.go:39:2: comment on exported const `UsernameLinePrefix` should be of the form `UsernameLinePrefix ...` (golint)
        // All lines containing a username begin with this single letter prefix
        ^
activefile/activefile.go:42:2: comment on exported const `UsernameLineEvenNumbered` should be of the form `UsernameLineEvenNumbered ...` (golint)
        // Indicate that this line should be found on odd numbered lines
        ^

False positive `G307: Deferring unsafe method "Close" on type "*os.File" (gosec)` linting error

These linting errors were surfaced from an upgraded golangci-lint:

activefile/activefile.go:141:2: G307: Deferring unsafe method "Close" on type "*os.File" (gosec)
	defer func() {
		if err := f.Close(); err != nil {
			// Ignore "file already closed" errors
			if !errors.Is(err, os.ErrClosed) {
				ezproxy.Logger.Printf(
					"filterEntries: failed to close file %q: %s",
					afr.Filename,
					err.Error(),
				)
			}
		}
	}()
auditlog/auditlog.go:164:2: G307: Deferring unsafe method "Close" on type "*os.File" (gosec)
	defer func() {
		if err := f.Close(); err != nil {
			// Ignore "file already closed" errors
			if !errors.Is(err, os.ErrClosed) {
				ezproxy.Logger.Printf(
					"AllSessionEntries: failed to close file %q: %s",
					alr.Filename,
					err.Error(),
				)
			}
		}
	}()
make: *** [Makefile:67: linting] Error 1

gosec | G204: Subprocess launched with variable

terminate.go:81:10: G204: Subprocess launched with variable (gosec)
                cmd := exec.Command(
                        executable,
                        SubCmdNameSessionTerminate,
                        session.SessionID,
                )

Since all of the arguments are variables (as that's sort of the point of this library?), I'm not yet sure what the fix is for this (or even if there is a fix).

Consider extending TerminateUserSessionResult type to include associated IP Address with Session ID

Running into a specific case today where having that bundled in would prove useful. Thus far the workflow is to gather the user sessions (which contains Username, IP Address and Session ID values) and then calling the Terminate() method. The results from that method leave out of the IP Address value previously associated with the Session ID.

The client code can build this support in, but including this information would be helpful.

Port WIP code from the "brick" project

Spinning this repo/project off to collect the EZproxy-related code that I've written while working on the atc0005/brick project. What I've written thus far is very basic, but the hope is that this will serve as a useful starting point for further work/project as I continue to learn Go.

Implement Stringer interface

Having this available for all custom types, but especially for collections types would come in handy for a variety of use cases with a current project I'm working on. Presumably this would be useful for others as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.