ataylor284 / spring-security-eventlog

A grails plugin to log spring security events.
5 stars 7 forks source link
grails spring-security

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:

Some of the event names that are captured:

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