Merge pull request #33 from finnlabs/remove_lobby_boy

Remove lobby boy configuration
pull/6827/head
Markus Kahl 7 years ago committed by GitHub
commit 3814cd8e49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      README.md
  2. 4
      config/routes.rb
  3. 33
      lib/open_project/hooks/session_iframes.rb
  4. 27
      lib/open_project/openid_connect/engine.rb
  5. 62
      lib/open_project/openid_connect/lobby_boy_configuration.rb
  6. 13
      lib/open_project/openid_connect/sso_login.rb
  7. 1
      lib/open_project/openid_connect/sso_logout.rb
  8. 1
      openproject-openid_connect.gemspec

@ -10,8 +10,6 @@ You will have to add the following lines to your OpenProject's `Gemfile.plugins`
gem 'omniauth-openid-connect', :git => 'git@github.com:finnlabs/omniauth-openid-connect.git', :branch => 'dev'
gem 'omniauth-openid_connect-providers', :git => 'git@github.com:finnlabs/omniauth-openid_connect-providers.git', :branch => 'dev'
gem 'openproject-openid_connect', :git => 'git@github.com:finnlabs/openproject-openid_connect.git', :branch => 'dev'
gem 'lobby_boy', :git => 'git@github.com:finnlabs/lobby_boy.git', :branch => 'dev'
```
### Development

@ -1,7 +1,3 @@
require 'lobby_boy'
Rails.application.routes.draw do
mount LobbyBoy::Engine, at: '/'
get '/session/logout_warning', to: 'session#logout_warning'
end

@ -1,33 +0,0 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# 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.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
module OpenProject
class Hooks::SessionIFrames < Redmine::Hook::ViewListener
render_on :view_layouts_base_body_bottom, partial: 'lobby_boy/iframes'
end
end

@ -1,6 +1,4 @@
require 'open_project/openid_connect/lobby_boy_configuration'
require 'open_project/plugins'
require 'lobby_boy'
module OpenProject::OpenIDConnect
class Engine < ::Rails::Engine
@ -52,31 +50,6 @@ module OpenProject::OpenIDConnect
end
end
config.to_prepare do
OpenProject::OpenIDConnect::LobbyBoyConfiguration.update!
if LobbyBoy.configured?
require 'open_project/hooks/session_iframes'
require 'open_project/openid_connect/sso_login'
::Concerns::OmniauthLogin.prepend SSOLogin
require 'open_project/openid_connect/sso_logout'
::AccountController.prepend SSOLogout
end
end
initializer "openid_connect.middleware.lobby_boy_config" do |app|
anchor =
if defined? ::Multitenancy::Elevators::MappedDomainElevator
::Multitenancy::Elevators::MappedDomainElevator
else
ActionDispatch::Callbacks
end
app.config.middleware.insert_after anchor, OpenProject::OpenIDConnect::LobbyBoyConfiguration
end
config.to_prepare do
# set a secure cookie in production
secure_cookie = !!Rails.configuration.force_ssl

@ -1,62 +0,0 @@
module OpenProject
module OpenIDConnect
class LobbyBoyConfiguration
def initialize(app)
@app = app
end
##
# Updates the lobby boy settings with each request in case
# the host or protocol change in OpenProject's settings.
def call(env)
self.class.update_client! if LobbyBoy.configured?
@app.call env
end
class << self
attr_accessor :provider
def enabled?
Rails.env != 'test'
end
def update!
self.provider = lookup_provider
if enabled? && provider
update_client!
update_provider!
end
end
def lookup_provider
OpenProject::Plugins::AuthPlugin.providers.find { |p| p[:sso] }
end
def update_client!
LobbyBoy.configure_client! host: host,
logged_in: lambda { !session[:user_id].nil? },
end_session_endpoint: end_session_endpoint,
on_logout_js_partial: 'session/warn_logout'
end
def update_provider!
LobbyBoy.configure_provider! name: provider[:name],
client_id: provider[:client_options][:identifier],
issuer: provider[:issuer],
end_session_endpoint: provider[:end_session_endpoint],
check_session_iframe: provider[:check_session_iframe]
end
def host
"#{Setting.protocol}://#{Setting.host_name}"
end
def end_session_endpoint
'/logout?script'
end
end
end
end
end

@ -1,13 +0,0 @@
module OpenProject
module OpenIDConnect
module SSOLogin
include ::LobbyBoy::SessionHelper
def authorization_successful(_user, auth_hash)
super.tap do |_|
confirm_login! # lobby_boy helper
end
end
end
end
end

@ -1,7 +1,6 @@
module OpenProject
module OpenIDConnect
module SSOLogout
include LobbyBoy::SessionHelper
include ::OmniauthHelper
def session_expired?

@ -18,5 +18,4 @@ Gem::Specification.new do |s|
s.add_dependency 'rails', '~> 5.0'
s.add_dependency 'openproject-auth_plugins', '~> 8.0'
s.add_dependency 'omniauth-openid_connect-providers', '~> 0.1'
s.add_dependency 'lobby_boy'
end

Loading…
Cancel
Save