Skip to content

Commit

Permalink
FIX: allow impersonation of system accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed Apr 11, 2019
1 parent 652d284 commit c4221c5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/mozilla_iam/application_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module ApplicationExtensions
def check_iam_session
begin
return unless current_user
return if current_user.id < 0

last_refresh = session[:mozilla_iam].try(:[], :last_refresh)
no_refresh = session[:mozilla_iam].try(:[], :no_refresh)
Expand Down
2 changes: 1 addition & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# name: mozilla-iam
# about: A plugin to integrate Discourse with Mozilla's Identity and Access Management (IAM) system
# version: 1.1.3
# version: 1.1.4
# authors: Leo McArdle
# url: https://github.com/mozilla/discourse-mozilla-iam

Expand Down
15 changes: 15 additions & 0 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,20 @@
expect(session['current_user_id']).to be_nil
end
end

context "with system user" do
let(:user) { User.find(-1) }
before do
authenticate_user(user)
log_in_user(user)
end

it "does nothing" do
MozillaIAM::Profile.expects(:for).never
MozillaIAM::Profile.expects(:refresh).never

get :show, params: { id: 666 }, format: :json
end
end
end
end

0 comments on commit c4221c5

Please sign in to comment.