Closed dktcoding closed 5 years ago
I've been playing a little bit with this:
Since attr_accessible
was deprecated I added the protected_attributes_continued
gem
diff --git a/Gemfile b/Gemfile
index 88fa2de..caaf4ba 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,3 +1,4 @@
+gem 'protected_attributes_continued'
gem 'roo'
gem 'iconv'
group :test, :development do
before_filter
was also deprecated, but as I understand it, it's an "alias" of before_action
, so:
diff --git a/app/controllers/vault_settings_controller.rb b/app/controllers/vault_settings_controller.rb
index 748454b..aaf25f2 100644
--- a/app/controllers/vault_settings_controller.rb
+++ b/app/controllers/vault_settings_controller.rb
@@ -6,7 +6,7 @@ class VaultSettingsController < ApplicationController
menu_item :vault_settings
layout 'admin'
- before_filter :require_admin
+ before_action :require_admin
def index
Now class_name
requieres a string:
diff --git a/lib/project_patch.rb b/lib/project_patch.rb
index 8f7573b..cb7e929 100644
--- a/lib/project_patch.rb
+++ b/lib/project_patch.rb
@@ -4,7 +4,7 @@ require_dependency "#{Rails.root}/plugins/vault/lib/vault"
module ProjectPatch
def self.included(base)
base.class_eval do
- has_many :keys, class_name: Vault::Key
+ has_many :keys, class_name: Vault::Key.to_s
end
end
end
This changes allowed installing but every time I click on the Keys
tab:
Started GET "/projects/test-vault/keys" for 181.***.***.*** at 2018-12-10 21:19:34 -0300
Processing by KeysController#index as HTML
Parameters: {"project_id"=>"test-vault"}
Current user: fede (id=431)
Completed 500 Internal Server Error in 313ms (ActiveRecord: 302.2ms)
NameError (uninitialized constant #<Class:0x0000557e34102478>::Encryptor):
plugins/vault/app/models/vault/password.rb:13:in `decrypt!'
plugins/vault/app/controllers/keys_controller.rb:66:in `map'
plugins/vault/app/controllers/keys_controller.rb:66:in `index'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
Any ideas?
Sure we will implement this compatibility
gem 'protected_attributes_continued' would't solve all problems https://github.com/westonganger/protected_attributes_continued/issues/9 we will continue working to migrate
@noshutdown-ru-user any news on this issue, please? We are very eager to run Redmine 4 and this is our only blocker. Is there anything we can do to help?
this is cool, then soon we will publish fix, hope in couple of days
Is this related to v3.4 as well? Installed the plugin and when trying to access UI:
/usr/lib/ruby/vendor_ruby/rails/application.rb:352:in initialize!' /usr/share/redmine/config/environment.rb:14:in
<top (required)>'
config.ru:3:in require' config.ru:3:in
block in
Is this related to v3.4 as well? Installed the plugin and when trying to access UI:
/usr/lib/ruby/vendor_ruby/rails/application.rb:352:in
initialize!' /usr/share/redmine/config/environment.rb:14:in
<top (required)>' config.ru:3:inrequire' config.ru:3:in
block in'
it shouldn't, can you paste more env details ?
you can try this branch
Ah apologies and thank you!
Thank you @noshutdown-ru-user, tomorrow I'll give it a try.
Hi!
Just tried the redmine_v4
branch, it installs correctly, but on attempting to look at keys I got the following error (on a project that already had keys):
Started GET "/projects/**********/keys" for 181.---.---.--- at 2019-01-09 19:15:18 -0300
Processing by KeysController#index as HTML
Parameters: {"project_id"=>"**********"}
Current user: fede (id=10)
Completed 500 Internal Server Error in 26ms (ActiveRecord: 6.1ms)
NameError (uninitialized constant #<Class:0x000055dbd517e420>::Encryptor):
plugins/vault/app/models/vault/password.rb:14:in `decrypt!'
plugins/vault/app/controllers/keys_controller.rb:66:in `map'
plugins/vault/app/controllers/keys_controller.rb:66:in `index'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
I tried again in a new project and got the following:
Started POST "/projects/*********/keys" for 181.---.---.--- at 2019-01-09 19:17:46 -0300
Processing by KeysController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"zmdLdAGsignZdyv8KK0G7X0NQHq3wzHlyKNnokaoM0Q/xuQze1HCzHKXNshuGLv3/DsKwaXem0zXZjoRkOFebA==", "vault_key"=>{"name"=>"Test", "login"=>"TestUser", "url"=>"https://www.example.com", "type"=>"Vault::Password", "body"=>"1234567890", "tags"=>"", "comment"=>""}, "commit"=>"Guardar", "project_id"=>"*********"}
Current user: fede (id=10)
WARNING: Can't mass-assign protected attributes for Vault::Password: tags
plugins/vault/app/controllers/keys_controller.rb:82:in `create'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
Completed 500 Internal Server Error in 28ms (ActiveRecord: 6.6ms)
NameError (uninitialized constant #<Class:0x000055dbd517e420>::Encryptor):
plugins/vault/app/models/vault/password.rb:8:in `encrypt!'
plugins/vault/app/controllers/keys_controller.rb:91:in `block in create'
plugins/vault/app/controllers/keys_controller.rb:90:in `create'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
Aha so problem only with existed keys ? In new project everything is ok ?
Looks like the main problem is the same with both new (empty) projects and old projects (with keys) - Encryptor is inaccessible.
Strange we tested it on clear installation by this repo: https://github.com/noshutdown-ru/vagrant_redmine We will check it again
I gave it a shot and I got the error (NameError (uninitialized constant #<Class:0x00555a09e67c48>::Encryptor)
) in following cases:
Until there is an official fix available, I've replaced 2 lines in app/models/vault/password.rb
(WARNING: Obviously this only works if you are using Redmine encryption
in Vault settings
):
def encrypt!
- self.body = Encryptor::encrypt(self.body)
+ self.body = Redmine::Ciphering.encrypt_text(self.body).gsub(/\n/, '')
self
end
#TODO: all data should be stored in UTF-8
def decrypt!
- self.body = Encryptor::decrypt(self.body).force_encoding('UTF-8')
+ self.body = Redmine::Ciphering.decrypt_text(self.body).force_encoding('UTF-8')
self
end
As we are using Redmine encryption
in Vault settings
, it looks like it works just fine, I am able to open existing project's Keys and also create new keys.
I am not sure why the Encryptor
is unavailable tho, so I might not be of any help in the official solution.
we fixed issues with uninitialized constant Encryptor
, can you pull branch
Just pulled branch redmine_4.0
and everything seems to be working! (Old databases, new databases, adding/removing/modifying keys).
Great work!
Works here too. So something is changed in Redmine 4.x and lib autoloading?
I believe the correct require "#{Rails.root}/plugins/vault/lib/encryptor"
should not contain .rb
.
Anyway, should this require
also be added to following files, as they all use Encryptor
?
app/models/vault/key.rb
test/integration/plugin_test.rb
test/integration/keys_test.rb
test/unit/lib/encryptor_test.rb
lib/tasks/ciphering.rake
it quite strange because in development mode autoload working properly, we will check what different
Anyway, should this
require
also be added to following files, as they all useEncryptor
?app/models/vault/key.rb test/integration/plugin_test.rb test/integration/keys_test.rb test/unit/lib/encryptor_test.rb lib/tasks/ciphering.rake
they no needed, but we will check
we will check it
Added small changes and merged to master
Hi!
Are there any plans on supporting Redmine 4.0?