Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit logging #49

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/controllers/scim_rails/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ class ApplicationController < ActionController::API
include Response

before_action :authorize_request
before_action :log_request, if: -> { ScimRails.config.audit_logger }

private

def log_request
ScimRails.config.audit_logger.info request
end

def authorize_request
send(authentication_strategy) do |searchable_attribute, authentication_attribute|
authorization = AuthorizeApiRequest.new(
Expand Down
4 changes: 4 additions & 0 deletions lib/generators/scim_rails/templates/initializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
# For example, [:created_at, :id] or { created_at: :desc }.
# config.scim_users_list_order = :id

# This logger will be used to log every incoming SCIM request
# using its `info` method. Customize this for audit purposes if needed.
# config.audit_logger = Logger.new

# Method called on user model to deprovision a user.
config.user_deprovision_method = :archive!

Expand Down
8 changes: 8 additions & 0 deletions lib/scim_rails/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Config
ALGO_NONE = "none"

attr_writer \
:audit_logger,
:basic_auth_model,
:mutable_user_attributes_schema,
:scim_users_model
Expand Down Expand Up @@ -56,5 +57,12 @@ def basic_auth_model
def scim_users_model
@scim_users_model.constantize
end

def audit_logger
case @audit_logger
when String then @audit_logger.constantize
else @audit_logger
end
end
end
end