From 37c5f322e6d0f93ffa44c23f5cd774eb02947eb7 Mon Sep 17 00:00:00 2001 From: bearns Date: Wed, 14 Oct 2020 17:22:08 +0300 Subject: [PATCH] Some minor fixes --- docker-compose.yml | 16 ++--- docker-compose.yml~ | 27 ++++++-- redmine/Dockerfile | 4 +- redmine/Dockerfile~ | 4 +- redmine/redmine_ldap_passwd-master/README.md | 27 -------- .../app/models/auth_source_ldap_passwd.rb | 57 ---------------- .../config/locales/en.yml | 3 - redmine/redmine_ldap_passwd-master/init.rb | 36 ---------- ...ne_ldap_passwd_account_controller_patch.rb | 66 ------------------- ...e_ldap_passwd_auth_sources_helper_patch.rb | 25 ------- ...redmine_ldap_passwd_my_controller_patch.rb | 64 ------------------ 11 files changed, 34 insertions(+), 295 deletions(-) delete mode 100644 redmine/redmine_ldap_passwd-master/README.md delete mode 100644 redmine/redmine_ldap_passwd-master/app/models/auth_source_ldap_passwd.rb delete mode 100644 redmine/redmine_ldap_passwd-master/config/locales/en.yml delete mode 100644 redmine/redmine_ldap_passwd-master/init.rb delete mode 100644 redmine/redmine_ldap_passwd-master/lib/redmine_ldap_passwd_account_controller_patch.rb delete mode 100644 redmine/redmine_ldap_passwd-master/lib/redmine_ldap_passwd_auth_sources_helper_patch.rb delete mode 100644 redmine/redmine_ldap_passwd-master/lib/redmine_ldap_passwd_my_controller_patch.rb diff --git a/docker-compose.yml b/docker-compose.yml index 9655a26..9458b1a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,14 +10,14 @@ services: environment: REDMINE_DB_MYSQL: db REDMINE_SECRET_KEY_BASE: supersecretkey - REDMINE_PLUGINS_MIGRATE: true + REDMINE_PLUGINS_MIGRATE: "true" env_file: - db.env volumes: - redmine-files:/usr/src/redmine/files - redmine-logs:/var/log/redmine depends_on: - - db + - db db: image: mysql:5.7 @@ -26,26 +26,26 @@ services: environment: MYSQL_DATABASE: redmine env_file: - - db.env + - db.env volumes: - db:/var/lib/mysql - + volumes: db: driver_opts: type: none - device: /media/docker/nc-db + device: /tmp/docker/redmine-db o: bind redmine-files: driver_opts: type: none - device: /media/docker/nc-data + device: /tmp/docker/redmine-files o: bind redmine-logs: driver_opts: type: none - device: /media/docker/nc-data - o: bind + device: /tmp/docker/redmine-logs + o: bind # openldap: # diff --git a/docker-compose.yml~ b/docker-compose.yml~ index 5a336a6..5a348e7 100644 --- a/docker-compose.yml~ +++ b/docker-compose.yml~ @@ -14,10 +14,10 @@ services: env_file: - db.env volumes: - - /srv/docker/redmine/redmine_mysql:/usr/src/redmine/files - - /srv/docker/redmine/redmine-logs:/var/log/redmine + - redmine-files:/usr/src/redmine/files + - redmine-logs:/var/log/redmine depends_on: - - db + - db db: image: mysql:5.7 @@ -26,9 +26,26 @@ services: environment: MYSQL_DATABASE: redmine env_file: - - db.env + - db.env volumes: - - /srv/docker/redmine/mysql:/var/lib/mysql + - db:/var/lib/mysql + +volumes: + db: + driver_opts: + type: none + device: /tmp/docker/redmine-db + o: bind + redmine-files: + driver_opts: + type: none + device: /tmp/docker/redmine-files + o: bind + redmine-logs: + driver_opts: + type: none + device: /tmp/docker/redmine-logs + o: bind # openldap: # diff --git a/redmine/Dockerfile b/redmine/Dockerfile index bd5412e..9eb702d 100644 --- a/redmine/Dockerfile +++ b/redmine/Dockerfile @@ -1,3 +1,3 @@ -FROM redmine:latest-alpine +FROM redmine:latest ENV REDMINE_DB_PASSWORD=${MYSQL_ROOT_PASSWORD} -COPY ./redmine_ldap_passwd/. /usr/share/redmine/plugins/ \ No newline at end of file +ADD ./redmine_ldap_passwd/ /usr/share/redmine/plugins/ \ No newline at end of file diff --git a/redmine/Dockerfile~ b/redmine/Dockerfile~ index 98291bd..96b8441 100644 --- a/redmine/Dockerfile~ +++ b/redmine/Dockerfile~ @@ -1,3 +1,3 @@ -FROM redmine +FROM redmine:latest ENV REDMINE_DB_PASSWORD=${MYSQL_ROOT_PASSWORD} -COPY ./redmine_ldap_passwd/. /usr/share/redmine/plugins/ \ No newline at end of file +COPY redmine_ldap_passwd /usr/share/redmine/plugins/ \ No newline at end of file diff --git a/redmine/redmine_ldap_passwd-master/README.md b/redmine/redmine_ldap_passwd-master/README.md deleted file mode 100644 index 94f1a2b..0000000 --- a/redmine/redmine_ldap_passwd-master/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Redmine LDAP Passwd plugin >= Redmine 3.0 - -The plugin extends AuthSourceLdap to introduce the ability to recover or change user password. - -### Features - -* Allows to changed password and update LDAP record. -* Allows to recover password and update LDAP record. - -**Notes** - -* The solution has been tested on MS Active Directory only. It works only with SSL connection, please ensure SSL is configured on Active Directory side. - -### Install - -1. Follow Redmine [plugin installation instructions](http://www.redmine.org/projects/redmine/wiki/Plugins#Installing-a-plugin). -2. Add new LDAP connection and check the records in 'auth_sources' making sure column 'type'='AuthSourceLdapPasswd'. If it is not, update the record manually executing the SQL query. -3. Assign new LDAP connection to the specific users you would like to provide access through LDAP to. - -### Uninstall - -1. Follow Redmine [plugin uninstall instructions](http://www.redmine.org/projects/redmine/wiki/Plugins#Uninstalling-a-plugin). - -### Changelog - -* **3.0 (2016-05-31)** - * Initial version released. \ No newline at end of file diff --git a/redmine/redmine_ldap_passwd-master/app/models/auth_source_ldap_passwd.rb b/redmine/redmine_ldap_passwd-master/app/models/auth_source_ldap_passwd.rb deleted file mode 100644 index 2f77ee3..0000000 --- a/redmine/redmine_ldap_passwd-master/app/models/auth_source_ldap_passwd.rb +++ /dev/null @@ -1,57 +0,0 @@ -class AuthSourceLdapPasswd < AuthSourceLdap - def allow_password_changes? - self.tls - end - - def change_user_password(user, password, new_password) - return false unless AuthSourceLdapPasswd.change_password_allowed?(user) - - attrs = get_user_dn(user.login, password) - if attrs && attrs[:dn] - if self.account && self.account.include?("$login") - ldap_con = initialize_ldap_con(self.account.sub("$login", Net::LDAP::DN.escape(user.login)), password) - else - ldap_con = initialize_ldap_con(self.account, self.account_password) - end - - ops = [[:replace, :unicodePwd, AuthSourceLdapPasswd.str2unicodePwd(new_password)]] - ldap_con.modify :dn => attrs[:dn], :operations => ops - - result = ldap_con.get_operation_result - if result.code == 0 - user.passwd_changed_on = Time.now.change(:usec => 0) - user.save - - return true - else - return result - end - end - - false - end - - def self.str2unicodePwd(str) - ('"' + str + '"').encode("utf-16le").force_encoding("utf-8") - end - - def self.change_password_allowed?(user) - return false if user.nil? - AuthSourceLdapPasswd.name.eql?(user.auth_source.type) - end - - def self.is_password_valid(password) - return false if password.nil? || password.length < 7 - - s = 0 - contains = [ - password.match(/\p{Lower}/) ? 1 : 0, - password.match(/\p{Upper}/) ? 1 : 0, - password.match(/\p{Digit}/) ? 1 : 0, - password.match(/[^\\w\\d]+/) ? 1 : 0 - ] - contains.each { |a| s += a } - - return s >= 3 - end -end diff --git a/redmine/redmine_ldap_passwd-master/config/locales/en.yml b/redmine/redmine_ldap_passwd-master/config/locales/en.yml deleted file mode 100644 index 980bf2d..0000000 --- a/redmine/redmine_ldap_passwd-master/config/locales/en.yml +++ /dev/null @@ -1,3 +0,0 @@ -en: - notice_new_password_and_confirmation_different: The new password is different from the confirmation password - notice_new_password_format: "1. The password should be at least seven characters long. 2. The password should contain characters from at least three of the following four categories: (a) English uppercase characters (A - Z) (b) English lowercase characters (a - z) (c) Base 10 digits (0 - 9) (d) Non-alphanumeric (For example: !, $, or %). 3. The password shouldn't contain three or more characters from the user's account name." \ No newline at end of file diff --git a/redmine/redmine_ldap_passwd-master/init.rb b/redmine/redmine_ldap_passwd-master/init.rb deleted file mode 100644 index 2cdb515..0000000 --- a/redmine/redmine_ldap_passwd-master/init.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'redmine' - -require_dependency 'redmine_ldap_passwd_my_controller_patch' -require_dependency 'redmine_ldap_passwd_auth_sources_helper_patch' -require_dependency 'redmine_ldap_passwd_account_controller_patch' - -Redmine::Plugin.register :redmine_ldap_passwd do - name 'Redmine LDAP Change Password' - author 'Yura Zaplavnov' - description 'The plugin extends AuthSourceLdap to introduce the ability to recover or change user password.' - version '3.0.1' - url 'https://github.com/xeagle2/redmine_ldap_passwd' - author_url 'https://github.com/xeagle2' -end - -require 'dispatcher' unless Rails::VERSION::MAJOR >= 3 - -if Rails::VERSION::MAJOR >= 5 - ActiveSupport::Reloader.to_prepare do - MyController.send(:include, RedmineLdapPasswd::MyControllerPatch) - AuthSourcesHelper.send(:include, RedmineLdapPasswd::AuthSourcesHelperPatch) - AccountController.send(:include, RedmineLdapPasswd::AccountControllerPatch) - end -elsif Rails::VERSION::MAJOR >= 3 - ActionDispatch::Callbacks.to_prepare do - MyController.send(:include, RedmineLdapPasswd::MyControllerPatch) - AuthSourcesHelper.send(:include, RedmineLdapPasswd::AuthSourcesHelperPatch) - AccountController.send(:include, RedmineLdapPasswd::AccountControllerPatch) - end -else - Dispatcher.to_prepare do - MyController.send(:include, RedmineLdapPasswd::MyControllerPatch) - AuthSourcesHelper.send(:include, RedmineLdapPasswd::AuthSourcesHelperPatch) - AccountController.send(:include, RedmineLdapPasswd::AccountControllerPatch) - end -end \ No newline at end of file diff --git a/redmine/redmine_ldap_passwd-master/lib/redmine_ldap_passwd_account_controller_patch.rb b/redmine/redmine_ldap_passwd-master/lib/redmine_ldap_passwd_account_controller_patch.rb deleted file mode 100644 index 47ab32a..0000000 --- a/redmine/redmine_ldap_passwd-master/lib/redmine_ldap_passwd_account_controller_patch.rb +++ /dev/null @@ -1,66 +0,0 @@ -module RedmineLdapPasswd - module AccountControllerPatch - def self.included(base) - base.send(:extend, ClassMethods) - base.send(:include, InstanceMethods) - - base.class_eval do - unloadable # Send unloadable so it will not be unloaded in development - - if Rails::VERSION::MAJOR >= 5 - alias_method :lost_password_without_extension, :lost_password - alias_method :lost_password, :lost_password_with_extension - else - alias_method :lost_password, :extension - end - end - end - - module ClassMethods - end - - module InstanceMethods - def lost_password_with_extension - if params[:token] - @token = Token.find_token("recovery", params[:token].to_s) - if @token.nil? || @token.expired? - redirect_to home_url - return - end - - @user = @token.user - unless @user && @user.active? - redirect_to home_url - return - end - - if request.post? - if params[:new_password_confirmation] != params[:new_password] - flash.now[:error] = l(:notice_new_password_and_confirmation_different) - elsif !AuthSourceLdapPasswd.is_password_valid (params[:new_password]) - flash.now[:error] = l(:notice_new_password_format) - else - r = @user.auth_source.change_user_password(@user, '', params[:new_password]) - - if r == true - flash[:notice] = l(:notice_account_password_updated) - redirect_to signin_path - elsif r == false - lost_password_without_extension - else - flash.now[:error] = r.message - end - - return - end - end - - render :template => "account/password_recovery" - return - else - lost_password_without_extension - end - end - end - end -end \ No newline at end of file diff --git a/redmine/redmine_ldap_passwd-master/lib/redmine_ldap_passwd_auth_sources_helper_patch.rb b/redmine/redmine_ldap_passwd-master/lib/redmine_ldap_passwd_auth_sources_helper_patch.rb deleted file mode 100644 index c3effe5..0000000 --- a/redmine/redmine_ldap_passwd-master/lib/redmine_ldap_passwd_auth_sources_helper_patch.rb +++ /dev/null @@ -1,25 +0,0 @@ -module RedmineLdapPasswd - module AuthSourcesHelperPatch - def self.included(base) # :nodoc: - base.send(:include, InstanceMethods) - - base.class_eval do - unloadable # Send unloadable so it will not be unloaded in development - - if Rails::VERSION::MAJOR >= 5 - alias_method :auth_source_partial_name_without_ignored_passwd, :auth_source_partial_name - alias_method :auth_source_partial_name, :auth_source_partial_name_with_ignored_passwd - else - alias_method :auth_source_partial_name, :ignored_passwd - end - end - end - - module InstanceMethods - # Make sure AuthSourceLdapPasswd is loaded with the same form as AuthSourceLdap - def auth_source_partial_name_with_ignored_passwd(auth_source) - "form_#{auth_source.class.name.underscore}".chomp('_passwd') - end - end - end -end \ No newline at end of file diff --git a/redmine/redmine_ldap_passwd-master/lib/redmine_ldap_passwd_my_controller_patch.rb b/redmine/redmine_ldap_passwd-master/lib/redmine_ldap_passwd_my_controller_patch.rb deleted file mode 100644 index b61c628..0000000 --- a/redmine/redmine_ldap_passwd-master/lib/redmine_ldap_passwd_my_controller_patch.rb +++ /dev/null @@ -1,64 +0,0 @@ -module RedmineLdapPasswd - module MyControllerPatch - def self.included(base) - base.send(:extend, ClassMethods) - base.send(:include, InstanceMethods) - - base.class_eval do - unloadable # Send unloadable so it will not be unloaded in development - - if Rails::VERSION::MAJOR >= 5 - alias_method :password_without_extension, :password - alias_method :password, :password_with_extension - else - alias_method_chain :password, :extension - end - end - end - - module ClassMethods - end - - module InstanceMethods - def password_with_extension - @user = User.current - - unless @user.change_password_allowed? - flash[:error] = l(:notice_can_t_change_password) - redirect_to my_account_path - return - end - - if request.post? - if !@user.check_password?(params[:password]) - flash.now[:error] = l(:notice_account_wrong_password) - elsif params[:password] == params[:new_password] - flash.now[:error] = l(:notice_new_password_must_be_different) - elsif params[:new_password_confirmation] != params[:new_password] - flash.now[:error] = l(:notice_new_password_and_confirmation_different) - elsif AuthSourceLdapPasswd.change_password_allowed?(@user) - if AuthSourceLdapPasswd.is_password_valid (params[:new_password]) - r = @user.auth_source.change_user_password(@user, params[:password], params[:new_password]) - - if r == true - session[:ctime] = User.current.passwd_changed_on.utc.to_i - flash[:notice] = l(:notice_account_password_updated) - redirect_to my_account_path - elsif r == false - password_without_extension - else - flash.now[:error] = r.message - end - else - flash.now[:error] = l(:notice_new_password_format) - end - else - password_without_extension - end - end - rescue Net::LDAP::LdapError => e - raise AuthSourceException.new(e.message) - end - end - end -end \ No newline at end of file