Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaptation to Redmine v5 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if Redmine::OmniAuthSAML.enabled? %>
<% if RedmineOmniAuthSaml.enabled? %>

<% content_for :header_tags do %>
<%= stylesheet_link_tag "login", :plugin => "redmine_omniauth_saml" %>
Expand Down
10 changes: 5 additions & 5 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require 'redmine'
require 'redmine_omniauth_saml'
require 'redmine_omniauth_saml/hooks'
require 'redmine_omniauth_saml/user_patch'
require File.expand_path('lib/redmine_omni_auth_saml.rb', __dir__)
require File.expand_path('lib/redmine_omni_auth_saml/hooks.rb', __dir__)
require File.expand_path('lib/redmine_omni_auth_saml/user_patch.rb', __dir__)


# Patches to existing classes/modules
ActiveSupport::Reloader.to_prepare do
require_dependency 'redmine_omniauth_saml/account_helper_patch'
require_dependency 'redmine_omniauth_saml/account_controller_patch'
require_dependency 'redmine_omni_auth_saml/account_helper_patch'
require_dependency 'redmine_omni_auth_saml/account_controller_patch'
end

# Plugin generic informations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module Redmine::OmniAuthSAML

module RedmineOmniAuthSaml
class << self

def settings_hash
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_dependency 'account_controller'

module Redmine::OmniAuthSAML
module RedmineOmniAuthSaml
module AccountControllerPatch
def self.included(base)
base.class_eval do
Expand Down Expand Up @@ -166,27 +166,27 @@ def saml_logout_user
end

def name_identifier_value
User.current.send Redmine::OmniAuthSAML.configured_saml[:name_identifier_value].to_sym
User.current.send RedmineOmniAuthSaml.configured_saml[:name_identifier_value].to_sym
end

def saml_settings
Redmine::OmniAuthSAML.settings_hash
RedmineOmniAuthSaml.settings_hash
end

def omniauth_saml_settings
Redmine::OmniAuthSAML.configured_saml
RedmineOmniAuthSaml.configured_saml
end

def saml_logout_url(service = nil)
logout_uri = Redmine::OmniAuthSAML.configured_saml[:signout_url]
logout_uri = RedmineOmniAuthSaml.configured_saml[:signout_url]
logout_uri += service.to_s unless logout_uri.blank?
logout_uri || home_url
end

end
end

unless AccountController.included_modules.include? Redmine::OmniAuthSAML::AccountControllerPatch
AccountController.prepend(Redmine::OmniAuthSAML::AccountControllerPatch)
unless AccountController.included_modules.include? RedmineOmniAuthSaml::AccountControllerPatch
AccountController.prepend(RedmineOmniAuthSaml::AccountControllerPatch)
AccountController.before_action :verify_authenticity_token, :except => [:login_with_saml_callback]
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_dependency 'account_helper'

module Redmine::OmniAuthSAML
module RedmineOmniAuthSaml
module AccountHelperPatch
def self.included(base)
base.send(:include, InstanceMethods)
Expand All @@ -11,12 +11,12 @@ def self.included(base)

module InstanceMethods
def label_for_saml_login
Redmine::OmniAuthSAML.label_login_with_saml.presence || l(:label_login_with_saml)
RedmineOmniAuthSaml.label_login_with_saml.presence || l(:label_login_with_saml)
end
end
end
end

unless AccountHelper.included_modules.include? Redmine::OmniAuthSAML::AccountHelperPatch
AccountHelper.send(:include, Redmine::OmniAuthSAML::AccountHelperPatch)
unless AccountHelper.included_modules.include? RedmineOmniAuthSaml::AccountHelperPatch
AccountHelper.send(:include, RedmineOmniAuthSaml::AccountHelperPatch)
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Redmine::OmniAuthSAML
module RedmineOmniAuthSaml
class Hooks < Redmine::Hook::ViewListener
render_on :view_account_login_top, :partial => 'redmine_omniauth_saml/view_account_login_top'
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_dependency 'user'

module OmniAuthSamlUser
module RedmineOmniAuthSaml::UserPatch
def self.prepended(base)
class << base
self.prepend(OmniAuthSamlUserMethods)
Expand Down Expand Up @@ -35,4 +35,4 @@ def change_password_allowed?

end

User.prepend(OmniAuthSamlUser)
User.prepend(RedmineOmniAuthSaml::UserPatch)