Skip to content

Simple and explicit user action auditing for Rails (former Shopify internal gem)

License

Notifications You must be signed in to change notification settings

benjlcox/auditor-general

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AuditorGeneral

Simple and explicit user action auditing for Rails

Installation

Add this line to your application's Gemfile:

gem 'auditor-general'

Then execute:

$ bundle

Or install it yourself as:

$ gem install auditor-general

Then run the following command to create the necessary migration:

rails g auditor_general:install

Then do a normal Rails migration:

rake db:migrate

Usage

Add the following to ApplicationController (or only to relevant controllers):

include AuditorGeneral::Controller

This will ensure curent_user.email is logged with each action. If current_user is unavailable the controller name will be logged instead

Then add the following to all models that will be audited:

include AuditorGeneral::Model

You can indicate which attributes to monitor with the following syntax:

  auditable attributes: [:name]

And you can optionally turn off auditing create/destroy by including:

  auditable attributes: [:name], create: false, destroy: false

You can log arbitrary actions not tied to models with this syntax:

  AuditorGeneral.log(model_type: "SomeLibrary", action: "restart", message: "Restarting some library somewhere")

Web View

Auditor General includes an optional web view for log files with some simple filtering features built in. To access this dashboard simply add the following to your routes.rb file:

  mount AuditorGeneral::Web => '/auditor-general'

Importantly, this will create a public route to view the dashboard. You an restrict the route to, for example, a certain user role using a constraint.

Contributing

  1. Fork it ( https://github.com/Shopify/auditor-general/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Simple and explicit user action auditing for Rails (former Shopify internal gem)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published