based openid plugin on general auth plugin

pull/6827/head
Markus Kahl 11 years ago
parent 4ba6849de4
commit df7024121c
  1. 28
      lib/open_project/openid_connect/engine.rb
  2. 1
      openproject-openid_connect.gemspec

@ -19,7 +19,7 @@ module OpenProject::OpenIDConnect
openid_connect/auth_provider-google.png
)
initializer "openid_connect.middleware" do |app|
def init_auth
# Loading OpenID providers manually since rails doesn't do it automatically,
# possibly due to non trivially module-name-convertible paths.
require 'omniauth/openid_connect/provider'
@ -36,28 +36,20 @@ module OpenProject::OpenIDConnect
end
OmniAuth::OpenIDConnect::Provider.load_generic_providers
end
app.config.middleware.use OmniAuth::Builder do
OmniAuth::OpenIDConnect::Provider.all.each do |pro|
p = pro.new
settings_available = if pro.available?
"settings available"
else
"settings missing"
end
def omniauth_strategies
[:openid_connect]
end
Rails.logger.info "[OpenID Connect] Registering provider for #{p.name} (#{settings_available})"
provider :openid_connect, :name => p.name, :setup => lambda { |env|
Rails.logger.info "[OpenID Connect] Trying dynamic provider #{p.name}"
opt = env['omniauth.strategy'].options
p.to_hash.each do |key, value|
opt[key] = value
end
}
end
def providers_for_strategy(strategy)
if strategy == :openid_connect
OmniAuth::OpenIDConnect::Provider.available.map(&:new)
end
end
include OpenProject::Plugins::AuthPlugin
initializer 'openid_connect.register_hooks' do
require 'open_project/openid_connect/hooks'
end

@ -17,6 +17,7 @@ Gem::Specification.new do |s|
s.add_dependency "rails", "~> 3.2.14"
s.add_dependency "openproject-plugins", "~> 1.0"
s.add_dependency "openproject-auth_plugins"
s.add_dependency "omniauth"
s.add_development_dependency "rspec", "~> 2.14"

Loading…
Cancel
Save