From c4221c59390c18b5ced1286d539ca99fdc5c558f Mon Sep 17 00:00:00 2001 From: Leo McArdle Date: Thu, 11 Apr 2019 18:51:49 +0100 Subject: [PATCH] FIX: allow impersonation of system accounts --- lib/mozilla_iam/application_extensions.rb | 1 + plugin.rb | 2 +- spec/controllers/application_controller_spec.rb | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/mozilla_iam/application_extensions.rb b/lib/mozilla_iam/application_extensions.rb index d298acd..bb0c489 100644 --- a/lib/mozilla_iam/application_extensions.rb +++ b/lib/mozilla_iam/application_extensions.rb @@ -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) diff --git a/plugin.rb b/plugin.rb index 5295d22..2e1e718 100644 --- a/plugin.rb +++ b/plugin.rb @@ -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 diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 3069607..dcc3223 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -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