GithubHelp home page GithubHelp logo

liuzchao / spring-security-eventlog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ataylor284/spring-security-eventlog

0.0 1.0 0.0 959 KB

A grails plugin to log spring security events.

Groovy 58.17% Batchfile 41.83%

spring-security-eventlog's Introduction

Spring Security Eventlog Plugin

Build Status

This plugin creates a simple log of spring security events. Each time a user logs in or logs out, a log entry will created, storing the remote address, session id, user name, event name, switched user name, and the time at which the event occurred.

Events are logged to a table named SPRING_SECURITY_EVENT, mapped to a domain object ca.redtoad.eventlog.SpringSecurityEvent.

Each event has the following fields:

  • username - the username entered
  • sessionId - the user's session
  • eventName - the name of the event
  • remoteAddress - the user's IP address
  • switchedUsername - username that is being switched to
  • dateCreated - the event's timestamp

Some of the event names that are captured:

  • AuthenticationFailureBadCredentialsEvent - a bad username or password
  • AuthenticationSuccessEvent - a successful login
  • InteractiveAuthenticationSuccessEvent - a successful login where the user entered his/her username and password
  • AuthenticationSwitchUserEvent - user having ROLE_SWITCH_USER has assumed the identity of a (likely different) user
  • Logout - a user logged out interactively

Customizing

You can specify your own logger if you would like to override how events get logged. Create a subclass of SpringSecurityEventLogger and add your custom behavior to logAuthenticationEvent. For example:

package mypackage

import ca.redtoad.eventlog.SpringSecurityEventLogger
import org.springframework.security.core.Authentication

class CustomEventLogger extends SpringSecurityEventLogger {
    void logAuthenticationEvent(String eventName, Authentication authentication, String remoteAddress, String switchedUsername) {
        println "$eventName! $authentication from $remoteAddress"
    }
}

In your Config.groovy, tell grails to your own event logger class:

grails.plugin.springsecurity.eventlog.eventLogger = mypackage.CustomEventLogger

Changelog

  • Changes in spring-security-eventlog 0.4

    • cleaned up plugin (thanks burtbeckwith!)
    • updated build dependencies to latest versions
  • Changes in spring-security-eventlog 0.3

    • added logging of 'switched user name' when a AuthenticationSwitchUserEvent occurs
    • small cleanup of plugin definition
  • Changes in spring-security-eventlog 0.2

    • fix exception on anonymous logout
    • changed logAuthenticationEvent signature to take remoteAddress directly rather than pulling it out of authentication.details

spring-security-eventlog's People

Contributors

ataylor284 avatar burtbeckwith avatar tobiaskranz avatar ressom avatar

Watchers

Luke avatar

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.