Skip to content

Commit

Permalink
FIX: add increased logging around when users are logged out
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed Apr 8, 2019
1 parent 7b36d1f commit 652d284
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions lib/mozilla_iam/application_extensions.rb
Expand Up @@ -27,19 +27,24 @@ def check_iam_session
end

if last_refresh + logout_delay < Time.now
reset_session
log_off_user
raise <<~EOF
Mozilla IAM: User session expired
user_id: #{current_user.id}, last_refresh: #{last_refresh}, logout_delay: #{logout_delay}
EOF
else
refresh_iam_session
unless Profile.for(current_user).is_aal_enough?(session[:mozilla_iam].try(:[], :aal))
reset_session
log_off_user
aal = session[:mozilla_iam].try(:[], :aal)
unless Profile.for(current_user).is_aal_enough?(aal)
raise <<~EOF
Mozilla IAM: AAL not enough, user logged out
user_id: #{current_user.id}, aal: #{aal}
EOF
end
end
rescue => e
Rails.logger.warn("Killed session for user #{current_user.id}: #{e.class} (#{e.message})\n#{e.backtrace.join("\n")}")
reset_session
log_off_user
raise e
end
end

Expand Down
2 changes: 1 addition & 1 deletion 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.2
# version: 1.1.3
# authors: Leo McArdle
# url: https://github.com/mozilla/discourse-mozilla-iam

Expand Down

0 comments on commit 652d284

Please sign in to comment.