Skip to content

Commit

Permalink
security fix - don't show passwords in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
mackuba committed Apr 28, 2010
1 parent 4d6c14c commit a94d775
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -27,6 +27,7 @@ gem "merb-slices", merb_gems_version
gem "merb-auth-core", merb_gems_version
gem "merb-auth-more", merb_gems_version
gem "merb-auth-slice-password", merb_gems_version
gem "merb-param-protection", merb_gems_version

git "git://github.com/schwabsauce/merb_dm_xss_terminate.git" do
gem "merb_dm_xss_terminate"
Expand Down
14 changes: 14 additions & 0 deletions app/controllers/application.rb
Expand Up @@ -10,6 +10,20 @@ def current_user

private

# overriding param protection code from merb-param-protection, because it's stupid and can't handle nested params
def self._filter_params(params)
return params if self.log_params_args.nil?
result = { }
params.each do |k,v|
if v.is_a?(Hash)
result[k] = self._filter_params(v)
else
result[k] = (self.log_params_args.include?(k.to_sym) ? '[FILTERED]' : v)
end
end
result
end

def self.protect_fields_for(record, fields = {})
if fields[:in]
before(nil, :only => fields[:in]) do |c|
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/exceptions.rb
@@ -1,4 +1,6 @@
class Exceptions < Merb::Controller

log_params_filtered :password

# handle NotFound exceptions (404)
def not_found
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/users.rb
Expand Up @@ -11,6 +11,8 @@ class Users < Application
:always => [:activities_count],
:admin => [:role_id, :client_id, :login, :active, :admin, :type, :class_name]

log_params_filtered :password, :password_confirmation

def index
@user = if params[:client_id]
ClientUser.new :client => Client.get(params[:client_id])
Expand Down
3 changes: 3 additions & 0 deletions slices/merb-auth-slice-password/app/controllers/sessions.rb
@@ -1,4 +1,7 @@
class MerbAuthSlicePassword::Sessions < MerbAuthSlicePassword::Application

log_params_filtered :password

private
def redirect_after_logout
message[:notice] = "Logged Out"
Expand Down

0 comments on commit a94d775

Please sign in to comment.