diff --git a/.travis.yml b/.travis.yml index f4e4330..887cd68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: ruby rvm: - 2.4.9 - 2.6.5 + - 2.7.2 addons: postgresql: "9.4" @@ -9,6 +10,7 @@ addons: env: - REDMINE_VER=3.4-stable - REDMINE_VER=4.1-stable + - REDMINE_VER=5.1-stable install: "echo skip bundle install" diff --git a/CHANGELOG.md b/CHANGELOG.md index 82c5cfb..dbf27a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# 1.7.7 + +* Add compatibility with Redmine 5.1 +* Add 2FA OTP instructions + +# 1.7.6 + +* Bump version after redmine_bots + # 1.7.5 * Fix problem with telegram_id exceeding int. diff --git a/Gemfile b/Gemfile index 172a537..4d4f5e2 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,8 @@ source 'https://rubygems.org' -gem 'active_model_otp', git: 'https://github.com/heapsource/active_model_otp.git', ref: '6ed9927' -gem 'rotp', '~> 4.0' -gem 'rqrcode', '~> 1.0' +gem 'active_model_otp' +gem 'rotp', '>= 5.0.0' +gem 'rqrcode' group :test do gem 'shoulda', '~> 3.6' diff --git a/init.rb b/init.rb index b4cdeb6..2e08ca8 100644 --- a/init.rb +++ b/init.rb @@ -2,13 +2,17 @@ FileUtils.mkdir_p(Rails.root.join('log/redmine_2fa')) unless Dir.exist?(Rails.root.join('log/redmine_2fa')) -require 'redmine_two_fa' +require './plugins/redmine_2fa/lib/redmine_two_fa' require 'telegram/bot' -# Rails 5.1/Rails 4 -reloader = defined?(ActiveSupport::Reloader) ? ActiveSupport::Reloader : ActionDispatch::Reloader - -reloader.to_prepare do +register_after_redmine_initialize_proc = + if Redmine::VERSION::MAJOR >= 5 + Rails.application.config.public_method(:after_initialize) + else + reloader = defined?(ActiveSupport::Reloader) ? ActiveSupport::Reloader : ActionDispatch::Reloader + reloader.public_method(:to_prepare) + end +register_after_redmine_initialize_proc.call do paths = '/lib/redmine_two_fa/{patches/*_patch,hooks/*_hook,*}.rb' Dir.glob(File.dirname(__FILE__) + paths).each do |file| require_dependency file diff --git a/lib/redmine_two_fa/patches/application_controller_patch.rb b/lib/redmine_two_fa/patches/application_controller_patch.rb deleted file mode 100644 index ffd9cd7..0000000 --- a/lib/redmine_two_fa/patches/application_controller_patch.rb +++ /dev/null @@ -1,12 +0,0 @@ -module TwoFaApplicationControllerPatch - def find_current_user - user = super - return user unless api_request? || api_key_from_request.present? - return user unless Setting.rest_api_enabled? && Setting.plugin_redmine_2fa['restrict_api_access'] && accept_api_auth? - user&.api_allowed? ? user : nil - end -end - -Rails.configuration.to_prepare do - ApplicationController.prepend(TwoFaApplicationControllerPatch) -end diff --git a/lib/redmine_two_fa/patches/two_fa_application_controller_patch.rb b/lib/redmine_two_fa/patches/two_fa_application_controller_patch.rb new file mode 100644 index 0000000..266716c --- /dev/null +++ b/lib/redmine_two_fa/patches/two_fa_application_controller_patch.rb @@ -0,0 +1,15 @@ +module RedmineTwoFa::Patches + module TwoFaApplicationControllerPatch + def find_current_user + user = super + return user unless api_request? || api_key_from_request.present? + return user unless Setting.rest_api_enabled? && Setting.plugin_redmine_2fa['restrict_api_access'] && accept_api_auth? + user&.api_allowed? ? user : nil + end + end +end + +Rails.configuration.to_prepare do + ApplicationController.prepend(RedmineTwoFa::Patches::TwoFaApplicationControllerPatch) +end +