Missing Digest #1541
This commit is contained in:
parent
8d9b06ae9d
commit
06d818964c
@ -116,6 +116,7 @@ Rails/SkipsModelValidations:
|
|||||||
- db/migrate/20160215125801_approval_workflow_status.rb
|
- db/migrate/20160215125801_approval_workflow_status.rb
|
||||||
- db/migrate/20140519133201_trash_bin.rb
|
- db/migrate/20140519133201_trash_bin.rb
|
||||||
- db/migrate/07_dmsf_1_4_4.rb
|
- db/migrate/07_dmsf_1_4_4.rb
|
||||||
|
- db/migrate/20240829093801_rename_dmsf_digest_token.rb
|
||||||
|
|
||||||
Rails/ThreeStateBooleanColumn:
|
Rails/ThreeStateBooleanColumn:
|
||||||
Exclude:
|
Exclude:
|
||||||
|
|||||||
@ -107,6 +107,8 @@ def dmsf_init
|
|||||||
pmap.permission :delete_project_watchers, { watchers: :destroy }
|
pmap.permission :delete_project_watchers, { watchers: :destroy }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# DMSF WebDAV digest token
|
||||||
|
Token.add_action :dmsf_webdav_digest, max_instances: 1, validity_time: nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if Redmine::Plugin.installed?('easy_extensions')
|
if Redmine::Plugin.installed?('easy_extensions')
|
||||||
|
|||||||
@ -475,7 +475,7 @@ class DmsfController < ApplicationController
|
|||||||
raise StandardError, l(:notice_account_wrong_password) unless User.current.check_password?(params[:password])
|
raise StandardError, l(:notice_account_wrong_password) unless User.current.check_password?(params[:password])
|
||||||
|
|
||||||
# We have to create a token first to prevent an autogenerated token's value
|
# We have to create a token first to prevent an autogenerated token's value
|
||||||
token = Token.create!(user_id: User.current.id, action: 'dmsf-webdav-digest')
|
token = Token.create!(user_id: User.current.id, action: 'dmsf_webdav_digest')
|
||||||
token.value = ActiveSupport::Digest.hexdigest(
|
token.value = ActiveSupport::Digest.hexdigest(
|
||||||
"#{User.current.login}:#{RedmineDmsf::Webdav::AUTHENTICATION_REALM}:#{params[:password]}"
|
"#{User.current.login}:#{RedmineDmsf::Webdav::AUTHENTICATION_REALM}:#{params[:password]}"
|
||||||
)
|
)
|
||||||
|
|||||||
30
db/migrate/20240829093801_rename_dmsf_digest_token.rb
Normal file
30
db/migrate/20240829093801_rename_dmsf_digest_token.rb
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Karel Pičman <karel.picman@kontron.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
# Rename DMSF digest token
|
||||||
|
class RenameDmsfDigestToken < ActiveRecord::Migration[6.1]
|
||||||
|
def up
|
||||||
|
Token.where(action: 'dmsf-webdav-digest').update_all action: 'dmsf_webdav_digest'
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
Token.where(action: 'dmsf_webdav_digest').update_all action: 'dmsf-webdav-digest'
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -36,8 +36,8 @@ module RedmineDmsf
|
|||||||
|
|
||||||
# Updates user's DMSF WebDAV digest
|
# Updates user's DMSF WebDAV digest
|
||||||
if controller.params[:password].present?
|
if controller.params[:password].present?
|
||||||
token = Token.find_by(user_id: user.id, action: 'dmsf-webdav-digest')
|
token = Token.find_by(user_id: user.id, action: 'dmsf_webdav_digest')
|
||||||
token ||= Token.create!(user_id: user.id, action: 'dmsf-webdav-digest')
|
token ||= Token.create!(user_id: user.id, action: 'dmsf_webdav_digest')
|
||||||
token.value = ActiveSupport::Digest.hexdigest(
|
token.value = ActiveSupport::Digest.hexdigest(
|
||||||
"#{user.login}:#{RedmineDmsf::Webdav::AUTHENTICATION_REALM}:#{controller.params[:password]}"
|
"#{user.login}:#{RedmineDmsf::Webdav::AUTHENTICATION_REALM}:#{controller.params[:password]}"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -76,7 +76,7 @@ module RedmineDmsf
|
|||||||
Rails.logger.error l(:notice_account_locked)
|
Rails.logger.error l(:notice_account_locked)
|
||||||
raise Unauthorized
|
raise Unauthorized
|
||||||
end
|
end
|
||||||
token = Token.find_by(user_id: user.id, action: 'dmsf-webdav-digest')
|
token = Token.find_by(user_id: user.id, action: 'dmsf_webdav_digest')
|
||||||
if token.nil? && defined?(EasyExtensions)
|
if token.nil? && defined?(EasyExtensions)
|
||||||
if user.easy_digest_token_expired?
|
if user.easy_digest_token_expired?
|
||||||
Rails.logger.error "Digest authentication: #{user} is locked"
|
Rails.logger.error "Digest authentication: #{user} is locked"
|
||||||
|
|||||||
@ -665,7 +665,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
post '/dmsf/digest', params: { password: 'jsmith' }
|
post '/dmsf/digest', params: { password: 'jsmith' }
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_redirected_to my_account_path
|
assert_redirected_to my_account_path
|
||||||
token = Token.find_by(user_id: @jsmith.id, action: 'dmsf-webdav-digest')
|
token = Token.find_by(user_id: @jsmith.id, action: 'dmsf_webdav_digest')
|
||||||
assert token
|
assert token
|
||||||
assert_equal ActiveSupport::Digest.hexdigest("jsmith:#{RedmineDmsf::Webdav::AUTHENTICATION_REALM}:jsmith"),
|
assert_equal ActiveSupport::Digest.hexdigest("jsmith:#{RedmineDmsf::Webdav::AUTHENTICATION_REALM}:jsmith"),
|
||||||
token.value
|
token.value
|
||||||
|
|||||||
@ -49,7 +49,7 @@ class DmsfWebdavGetTest < RedmineDmsf::Test::IntegrationTest
|
|||||||
digest = ActiveSupport::Digest.hexdigest(
|
digest = ActiveSupport::Digest.hexdigest(
|
||||||
"#{@jsmith_user.login}:#{RedmineDmsf::Webdav::AUTHENTICATION_REALM}:jsmith"
|
"#{@jsmith_user.login}:#{RedmineDmsf::Webdav::AUTHENTICATION_REALM}:jsmith"
|
||||||
)
|
)
|
||||||
token ||= Token.create!(user_id: @jsmith_user.id, action: 'dmsf-webdav-digest')
|
token ||= Token.create!(user_id: @jsmith_user.id, action: 'dmsf_webdav_digest')
|
||||||
token.value = digest
|
token.value = digest
|
||||||
assert token.save
|
assert token.save
|
||||||
authorization = encode_credentials(username: 'jsmith', digest: digest, target: '/dmsf/webdav')
|
authorization = encode_credentials(username: 'jsmith', digest: digest, target: '/dmsf/webdav')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user