-
-
-
- HTML
- @footer = true
- self
- end
-
- def to_html
- footer
- @html
- end
-
- def to_response
- footer
- Rack::Response.new(@html).finish
- end
-
- protected
-
- def css
- "\n"
- end
- end
-end
diff --git a/oa-core/lib/omniauth/strategy.rb b/oa-core/lib/omniauth/strategy.rb
deleted file mode 100644
index 41576e0..0000000
--- a/oa-core/lib/omniauth/strategy.rb
+++ /dev/null
@@ -1,242 +0,0 @@
-require 'omniauth/core'
-
-module OmniAuth
- class NoSessionError < StandardError; end
- # The Strategy is the base unit of OmniAuth's ability to
- # wrangle multiple providers. Each strategy provided by
- # OmniAuth includes this mixin to gain the default functionality
- # necessary to be compatible with the OmniAuth library.
- module Strategy
- def self.included(base)
- OmniAuth.strategies << base
- base.class_eval do
- attr_reader :app, :name, :env, :options, :response
- end
- end
-
- def initialize(app, name, *args, &block)
- @app = app
- @name = name.to_sym
- @options = args.last.is_a?(Hash) ? args.pop : {}
-
- yield self if block_given?
- end
-
- def inspect
- "#<#{self.class.to_s}>"
- end
-
- def call(env)
- dup.call!(env)
- end
-
- def call!(env)
- raise OmniAuth::NoSessionError.new("You must provide a session to use OmniAuth.") unless env['rack.session']
-
- @env = env
- @env['omniauth.strategy'] = self if on_auth_path?
-
- return mock_call!(env) if OmniAuth.config.test_mode
-
- return options_call if on_auth_path? && options_request?
- return request_call if on_request_path? && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym)
- return callback_call if on_callback_path?
- return other_phase if respond_to?(:other_phase)
- @app.call(env)
- end
-
- # Responds to an OPTIONS request.
- def options_call
- verbs = OmniAuth.config.allowed_request_methods.map(&:to_s).map(&:upcase).join(', ')
- return [ 200, { 'Allow' => verbs }, [] ]
- end
-
- # Performs the steps necessary to run the request phase of a strategy.
- def request_call
- setup_phase
- if response = call_through_to_app
- response
- else
- if request.params['origin']
- @env['rack.session']['omniauth.origin'] = request.params['origin']
- elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
- @env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
- end
- request_phase
- end
- end
-
- # Performs the steps necessary to run the callback phase of a strategy.
- def callback_call
- setup_phase
- @env['omniauth.origin'] = session.delete('omniauth.origin')
- @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
-
- callback_phase
- end
-
- def on_auth_path?
- on_request_path? || on_callback_path?
- end
-
- def on_request_path?
- on_path?(request_path)
- end
-
- def on_callback_path?
- on_path?(callback_path)
- end
-
- def on_path?(path)
- current_path.casecmp(path) == 0
- end
-
- def options_request?
- request.request_method == 'OPTIONS'
- end
-
- def mock_call!(env)
- return mock_request_call if on_request_path?
- return mock_callback_call if on_callback_path?
- call_app!
- end
-
- def mock_request_call
- setup_phase
- return response if response = call_through_to_app
-
- if request.params['origin']
- @env['rack.session']['omniauth.origin'] = request.params['origin']
- elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
- @env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
- end
- redirect(script_name + callback_path + query_string)
- end
-
- def mock_callback_call
- setup_phase
- mocked_auth = OmniAuth.mock_auth_for(name.to_sym)
- if mocked_auth.is_a?(Symbol)
- fail!(mocked_auth)
- else
- @env['omniauth.auth'] = mocked_auth
- @env['omniauth.origin'] = session.delete('omniauth.origin')
- @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
- call_app!
- end
- end
-
- def setup_phase
- if options[:setup].respond_to?(:call)
- options[:setup].call(env)
- elsif options[:setup]
- setup_env = env.merge('PATH_INFO' => setup_path, 'REQUEST_METHOD' => 'GET')
- call_app!(setup_env)
- end
- end
-
- def request_phase
- raise NotImplementedError
- end
-
- def callback_phase
- @env['omniauth.auth'] = auth_hash
- @env['omniauth.params'] = session['query_params'] || {}
- session['query_params'] = nil if session['query_params']
- call_app!
- end
-
- def path_prefix
- options[:path_prefix] || OmniAuth.config.path_prefix
- end
-
- def request_path
- options[:request_path] || "#{path_prefix}/#{name}"
- end
-
- def callback_path
- options[:callback_path] || "#{path_prefix}/#{name}/callback"
- end
-
- def setup_path
- options[:setup_path] || "#{path_prefix}/#{name}/setup"
- end
-
- def current_path
- request.path_info.downcase.sub(/\/$/,'')
- end
-
- def query_string
- request.query_string.empty? ? "" : "?#{request.query_string}"
- end
-
- def call_through_to_app
- status, headers, body = *call_app!
- session['query_params'] = Rack::Request.new(env).params
- @response = Rack::Response.new(body, status, headers)
-
- status == 404 ? nil : @response.finish
- end
-
- def call_app!(env = @env)
- @app.call(env)
- end
-
- def auth_hash
- AuthHash.new(:provider => name.to_s)
- end
-
- def full_host
- case OmniAuth.config.full_host
- when String
- OmniAuth.config.full_host
- when Proc
- OmniAuth.config.full_host.call(env)
- else
- uri = URI.parse(request.url.gsub(/\?.*$/,''))
- uri.path = ''
- uri.query = nil
- uri.to_s
- end
- end
-
- def callback_url
- full_host + script_name + callback_path + query_string
- end
-
- def script_name
- @env['SCRIPT_NAME'] || ''
- end
-
- def session
- @env['rack.session']
- end
-
- def request
- @request ||= Rack::Request.new(@env)
- end
-
- def redirect(uri)
- r = Rack::Response.new
-
- if options[:iframe]
- r.write("")
- else
- r.write("Redirecting to #{uri}...")
- r.redirect(uri)
- end
-
- r.finish
- end
-
- def user_info; {} end
-
- def fail!(message_key, exception = nil)
- self.env['omniauth.error'] = exception
- self.env['omniauth.error.type'] = message_key.to_sym
- self.env['omniauth.error.strategy'] = self
-
- OmniAuth.config.on_failure.call(self.env)
- end
- end
-end
diff --git a/oa-core/lib/omniauth/test.rb b/oa-core/lib/omniauth/test.rb
deleted file mode 100644
index bce2561..0000000
--- a/oa-core/lib/omniauth/test.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-module OmniAuth
-
- # Support for testing OmniAuth strategies.
- module Test
-
- autoload :PhonySession, 'omniauth/test/phony_session'
- autoload :StrategyMacros, 'omniauth/test/strategy_macros'
- autoload :StrategyTestCase, 'omniauth/test/strategy_test_case'
-
- end
-
-end
diff --git a/oa-core/lib/omniauth/test/phony_session.rb b/oa-core/lib/omniauth/test/phony_session.rb
deleted file mode 100644
index 768fa74..0000000
--- a/oa-core/lib/omniauth/test/phony_session.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-class OmniAuth::Test::PhonySession
- def initialize(app); @app = app end
- def call(env)
- @session ||= (env['rack.session'] || {})
- env['rack.session'] = @session
- @app.call(env)
- end
-end
diff --git a/oa-core/lib/omniauth/test/strategy_macros.rb b/oa-core/lib/omniauth/test/strategy_macros.rb
deleted file mode 100644
index 2d897e0..0000000
--- a/oa-core/lib/omniauth/test/strategy_macros.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-module OmniAuth
-
- module Test
-
- module StrategyMacros
-
- def sets_an_auth_hash
- it 'should set an auth hash' do
- last_request.env['omniauth.auth'].should be_kind_of(Hash)
- end
- end
-
- def sets_provider_to(provider)
- it "should set the provider to #{provider}" do
- (last_request.env['omniauth.auth'] || {})['provider'].should == provider
- end
- end
-
- def sets_uid_to(uid)
- it "should set the UID to #{uid}" do
- (last_request.env['omniauth.auth'] || {})['uid'].should == uid
- end
- end
-
- def sets_user_info_to(user_info)
- it "should set the user_info to #{user_info}" do
- (last_request.env['omniauth.auth'] || {})['user_info'].should == user_info
- end
- end
- end
-
- end
-
-end
diff --git a/oa-core/lib/omniauth/test/strategy_test_case.rb b/oa-core/lib/omniauth/test/strategy_test_case.rb
deleted file mode 100644
index 9dc67e8..0000000
--- a/oa-core/lib/omniauth/test/strategy_test_case.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'rack'
-require 'omniauth/test'
-
-module OmniAuth
-
- module Test
-
- # Support for testing OmniAuth strategies.
- #
- # @example Usage
- # class MyStrategyTest < Test::Unit::TestCase
- # include OmniAuth::Test::StrategyTestCase
- # def strategy
- # # return the parameters to a Rack::Builder map call:
- # [MyStrategy.new, :some, :configuration, :options => 'here']
- # end
- # setup do
- # post '/auth/my_strategy/callback', :user => { 'name' => 'Dylan', 'id' => '445' }
- # end
- # end
- module StrategyTestCase
-
- def app
- strat = self.strategy
- resp = self.app_response
- Rack::Builder.new {
- use OmniAuth::Test::PhonySession
- use *strat
- run lambda {|env| [404, {'Content-Type' => 'text/plain'}, [resp || env.key?('omniauth.auth').to_s]] }
- }.to_app
- end
-
- def app_response
- nil
- end
-
- def session
- last_request.env['rack.session']
- end
-
- def strategy
- raise NotImplementedError.new('Including specs must define #strategy')
- end
-
- end
-
- end
-
-end
diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb
deleted file mode 100644
index 9f980b0..0000000
--- a/oa-core/lib/omniauth/version.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-module OmniAuth
- module Version
- unless defined?(::OmniAuth::Version::MAJOR)
- MAJOR = 0
- end
- unless defined?(::OmniAuth::Version::MINOR)
- MINOR = 3
- end
- unless defined?(::OmniAuth::Version::PATCH)
- PATCH = 0
- end
- unless defined?(::OmniAuth::Version::PRE)
- PRE = "rc3"
- end
- unless defined?(::OmniAuth::Version::STRING)
- STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
- end
- end
-end
diff --git a/oa-core/spec/omniauth/builder_spec.rb b/oa-core/spec/omniauth/builder_spec.rb
deleted file mode 100644
index c45c3c2..0000000
--- a/oa-core/spec/omniauth/builder_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require File.expand_path('../../spec_helper', __FILE__)
-
-describe OmniAuth::Builder do
- describe '#provider' do
- it 'should translate a symbol to a constant' do
- OmniAuth::Strategies.should_receive(:const_get).with('MyStrategy').and_return(Class.new)
- OmniAuth::Builder.new(nil) do
- provider :my_strategy
- end
- end
-
- it 'should also just accept a class' do
- class ::ExampleClass; end
-
- lambda{ OmniAuth::Builder.new(nil) do
- provider ::ExampleClass
- end }.should_not raise_error
- end
- end
-end
diff --git a/oa-core/spec/omniauth/core_spec.rb b/oa-core/spec/omniauth/core_spec.rb
deleted file mode 100644
index dffa5ce..0000000
--- a/oa-core/spec/omniauth/core_spec.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-require File.expand_path('../../spec_helper', __FILE__)
-
-describe OmniAuth do
- describe '.strategies' do
- it 'should increase when a new strategy is made' do
- lambda{ class ExampleStrategy
- include OmniAuth::Strategy
- end }.should change(OmniAuth.strategies, :size).by(1)
- OmniAuth.strategies.last.should == ExampleStrategy
- end
- end
-
- context 'configuration' do
- it 'should be callable from .configure' do
- OmniAuth.configure do |c|
- c.should be_kind_of(OmniAuth::Configuration)
- end
- end
-
- before do
- @old_path_prefix = OmniAuth.config.path_prefix
- @old_on_failure = OmniAuth.config.on_failure
- end
-
- after do
- OmniAuth.configure do |config|
- config.path_prefix = @old_path_prefix
- config.on_failure = @old_on_failure
- end
- end
-
- it 'should be able to set the path' do
- OmniAuth.configure do |config|
- config.path_prefix = '/awesome'
- end
-
- OmniAuth.config.path_prefix.should == '/awesome'
- end
-
- it 'should be able to set the on_failure rack app' do
- OmniAuth.configure do |config|
- config.on_failure do
- 'yoyo'
- end
- end
-
- OmniAuth.config.on_failure.call.should == 'yoyo'
- end
- end
-
- describe '::Utils' do
- describe '.deep_merge' do
- it 'should combine hashes' do
- OmniAuth::Utils.deep_merge({'abc' => {'def' => 123}}, {'abc' => {'foo' => 'bar'}}).should == {
- 'abc' => {'def' => 123, 'foo' => 'bar'}
- }
- end
- end
-
- describe '.camelize' do
- it 'should work on normal cases' do
- {
- 'some_word' => 'SomeWord',
- 'AnotherWord' => 'AnotherWord',
- 'one' => 'One',
- 'three_words_now' => 'ThreeWordsNow'
- }.each_pair{ |k,v| OmniAuth::Utils.camelize(k).should == v }
- end
-
- it 'should work in special cases' do
- {
- 'oauth' => "OAuth",
- 'openid' => 'OpenID',
- 'open_id' => 'OpenID'
- }.each_pair{ |k,v| OmniAuth::Utils.camelize(k).should == v}
- end
- end
- end
-end
diff --git a/oa-core/spec/omniauth/strategy_spec.rb b/oa-core/spec/omniauth/strategy_spec.rb
deleted file mode 100644
index 7137f6b..0000000
--- a/oa-core/spec/omniauth/strategy_spec.rb
+++ /dev/null
@@ -1,397 +0,0 @@
-require File.expand_path('../../spec_helper', __FILE__)
-
-class ExampleStrategy
- include OmniAuth::Strategy
- def call(env); self.call!(env) end
- attr_reader :last_env
- def request_phase
- @fail = fail!(options[:failure]) if options[:failure]
- @last_env = env
- return @fail if @fail
- raise "Request Phase"
- end
- def callback_phase
- @fail = fail!(options[:failure]) if options[:failure]
- @last_env = env
- return @fail if @fail
- raise "Callback Phase"
- end
-end
-
-def make_env(path = '/auth/test', props = {})
- {
- 'REQUEST_METHOD' => 'GET',
- 'PATH_INFO' => path,
- 'rack.session' => {},
- 'rack.input' => StringIO.new('test=true')
- }.merge(props)
-end
-
-describe OmniAuth::Strategy do
- let(:app){ lambda{|env| [404, {}, ['Awesome']]}}
- describe '#initialize' do
- context 'options extraction' do
- it 'should be the last argument if the last argument is a Hash' do
- ExampleStrategy.new(app, 'test', :abc => 123).options[:abc].should == 123
- end
-
- it 'should be a blank hash if none are provided' do
- ExampleStrategy.new(app, 'test').options.should == {}
- end
- end
- end
-
- describe '#full_host' do
- let(:strategy){ ExampleStrategy.new(app, 'test', {}) }
- it 'should not freak out if there is a pipe in the URL' do
- strategy.call!(make_env('/whatever', 'rack.url_scheme' => 'http', 'SERVER_NAME' => 'facebook.lame', 'QUERY_STRING' => 'code=asofibasf|asoidnasd', 'SCRIPT_NAME' => '', 'SERVER_PORT' => 80))
- lambda{ strategy.full_host }.should_not raise_error
- end
- end
-
- describe '#call' do
- let(:strategy){ ExampleStrategy.new(app, 'test', @options) }
-
- context 'omniauth.origin' do
- it 'should be set on the request phase' do
- lambda{ strategy.call(make_env('/auth/test', 'HTTP_REFERER' => 'http://example.com/origin')) }.should raise_error("Request Phase")
- strategy.last_env['rack.session']['omniauth.origin'].should == 'http://example.com/origin'
- end
-
- it 'should be turned into an env variable on the callback phase' do
- lambda{ strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.origin' => 'http://example.com/origin'})) }.should raise_error("Callback Phase")
- strategy.last_env['omniauth.origin'].should == 'http://example.com/origin'
- end
-
- it 'should set from the params if provided' do
- lambda{ strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'origin=/foo')) }.should raise_error('Request Phase')
- strategy.last_env['rack.session']['omniauth.origin'].should == '/foo'
- end
-
- it 'should be set on the failure env' do
- OmniAuth.config.should_receive(:on_failure).and_return(lambda{|env| env})
- @options = {:failure => :forced_fail}
- strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.origin' => '/awesome'}))
- end
-
- context "with script_name" do
- it 'should be set on the request phase, containing full path' do
- env = {'HTTP_REFERER' => 'http://example.com/sub_uri/origin', 'SCRIPT_NAME' => '/sub_uri' }
- lambda{ strategy.call(make_env('/auth/test', env)) }.should raise_error("Request Phase")
- strategy.last_env['rack.session']['omniauth.origin'].should == 'http://example.com/sub_uri/origin'
- end
-
- it 'should be turned into an env variable on the callback phase, containing full path' do
- env = {
- 'rack.session' => {'omniauth.origin' => 'http://example.com/sub_uri/origin'},
- 'SCRIPT_NAME' => '/sub_uri'
- }
-
- lambda{ strategy.call(make_env('/auth/test/callback', env)) }.should raise_error("Callback Phase")
- strategy.last_env['omniauth.origin'].should == 'http://example.com/sub_uri/origin'
- end
-
- end
- end
-
- context 'default paths' do
- it 'should use the default request path' do
- lambda{ strategy.call(make_env) }.should raise_error("Request Phase")
- end
-
- it 'should be case insensitive on request path' do
- lambda{ strategy.call(make_env('/AUTH/Test'))}.should raise_error("Request Phase")
- end
-
- it 'should be case insensitive on callback path' do
- lambda{ strategy.call(make_env('/AUTH/TeSt/CaLlBAck'))}.should raise_error("Callback Phase")
- end
-
- it 'should use the default callback path' do
- lambda{ strategy.call(make_env('/auth/test/callback')) }.should raise_error("Callback Phase")
- end
-
- it 'should strip trailing spaces on request' do
- lambda{ strategy.call(make_env('/auth/test/')) }.should raise_error("Request Phase")
- end
-
- it 'should strip trailing spaces on callback' do
- lambda{ strategy.call(make_env('/auth/test/callback/')) }.should raise_error("Callback Phase")
- end
-
- context 'callback_url' do
- it 'uses the default callback_path' do
- strategy.should_receive(:full_host).and_return('http://example.com')
-
- lambda{ strategy.call(make_env) }.should raise_error("Request Phase")
-
- strategy.callback_url.should == 'http://example.com/auth/test/callback'
- end
-
- it 'preserves the query parameters' do
- strategy.stub(:full_host).and_return('http://example.com')
- begin
- strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'id=5'))
- rescue RuntimeError; end
- strategy.callback_url.should == 'http://example.com/auth/test/callback?id=5'
- end
-
- it 'consider script name' do
- strategy.stub(:full_host).and_return('http://example.com')
- begin
- strategy.call(make_env('/auth/test', 'SCRIPT_NAME' => '/sub_uri'))
- rescue RuntimeError; end
- strategy.callback_url.should == 'http://example.com/sub_uri/auth/test/callback'
- end
- end
- end
-
- context 'pre-request call through' do
- subject { ExampleStrategy.new(app, 'test') }
- let(:app){ lambda{|env| env['omniauth.boom'] = true; [env['test.status'] || 404, {}, ['Whatev']] } }
- it 'should be able to modify the env on the fly before the request_phase' do
- lambda{ subject.call(make_env) }.should raise_error("Request Phase")
- subject.response.status.should == 404
- subject.last_env.should be_key('omniauth.boom')
- end
-
- it 'should call through to the app instead if a non-404 response is received' do
- lambda{ subject.call(make_env('/auth/test', 'test.status' => 200)) }.should_not raise_error
- subject.response.body.should == ['Whatev']
- end
- end
-
- context 'custom paths' do
- it 'should use a custom request_path if one is provided' do
- @options = {:request_path => '/awesome'}
- lambda{ strategy.call(make_env('/awesome')) }.should raise_error("Request Phase")
- end
-
- it 'should use a custom callback_path if one is provided' do
- @options = {:callback_path => '/radical'}
- lambda{ strategy.call(make_env('/radical')) }.should raise_error("Callback Phase")
- end
-
- context 'callback_url' do
- it 'uses a custom callback_path if one is provided' do
- @options = {:callback_path => '/radical'}
- strategy.should_receive(:full_host).and_return('http://example.com')
-
- lambda{ strategy.call(make_env('/radical')) }.should raise_error("Callback Phase")
-
- strategy.callback_url.should == 'http://example.com/radical'
- end
-
- it 'preserves the query parameters' do
- @options = {:callback_path => '/radical'}
- strategy.stub(:full_host).and_return('http://example.com')
- begin
- strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'id=5'))
- rescue RuntimeError; end
- strategy.callback_url.should == 'http://example.com/radical?id=5'
- end
- end
- end
-
- context 'custom prefix' do
- before do
- @options = {:path_prefix => '/wowzers'}
- end
-
- it 'should use a custom prefix for request' do
- lambda{ strategy.call(make_env('/wowzers/test')) }.should raise_error("Request Phase")
- end
-
- it 'should use a custom prefix for callback' do
- lambda{ strategy.call(make_env('/wowzers/test/callback')) }.should raise_error("Callback Phase")
- end
-
- context 'callback_url' do
- it 'uses a custom prefix' do
- strategy.should_receive(:full_host).and_return('http://example.com')
-
- lambda{ strategy.call(make_env('/wowzers/test')) }.should raise_error("Request Phase")
-
- strategy.callback_url.should == 'http://example.com/wowzers/test/callback'
- end
-
- it 'preserves the query parameters' do
- strategy.stub(:full_host).and_return('http://example.com')
- begin
- strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'id=5'))
- rescue RuntimeError; end
- strategy.callback_url.should == 'http://example.com/wowzers/test/callback?id=5'
- end
- end
- end
-
- context 'request method restriction' do
- before do
- OmniAuth.config.allowed_request_methods = [:post]
- end
-
- it 'should not allow a request method of the wrong type' do
- lambda{ strategy.call(make_env)}.should_not raise_error
- end
-
- it 'should allow a request method of the correct type' do
- lambda{ strategy.call(make_env('/auth/test', 'REQUEST_METHOD' => 'POST'))}.should raise_error("Request Phase")
- end
-
- after do
- OmniAuth.config.allowed_request_methods = [:get, :post]
- end
- end
-
- context 'receiving an OPTIONS request' do
- shared_examples_for "an OPTIONS request" do
- it 'should respond with 200' do
- response[0].should == 200
- end
-
- it 'should set the Allow header properly' do
- response[1]['Allow'].should == "GET, POST"
- end
- end
-
- context 'to the request path' do
- let(:response) { strategy.call(make_env('/auth/test', 'REQUEST_METHOD' => 'OPTIONS')) }
- it_should_behave_like 'an OPTIONS request'
- end
-
- context 'to the request path' do
- let(:response) { strategy.call(make_env('/auth/test/callback', 'REQUEST_METHOD' => 'OPTIONS')) }
- it_should_behave_like 'an OPTIONS request'
- end
-
- context 'to some other path' do
- it 'should not short-circuit the request' do
- env = make_env('/other', 'REQUEST_METHOD' => 'OPTIONS')
- strategy.call(env).should == app.call(env)
- end
- end
- end
-
- context 'test mode' do
- before do
- OmniAuth.config.test_mode = true
- end
-
- it 'should short circuit the request phase entirely' do
- response = strategy.call(make_env)
- response[0].should == 302
- response[1]['Location'].should == '/auth/test/callback'
- end
-
- it 'should be case insensitive on request path' do
- strategy.call(make_env('/AUTH/Test'))[0].should == 302
- end
-
- it 'should respect SCRIPT_NAME (a.k.a. BaseURI)' do
- response = strategy.call(make_env('/auth/test', 'SCRIPT_NAME' => '/sub_uri'))
- response[1]['Location'].should == '/sub_uri/auth/test/callback'
- end
-
- it 'should be case insensitive on callback path' do
- strategy.call(make_env('/AUTH/TeSt/CaLlBAck')).should == strategy.call(make_env('/auth/test/callback'))
- end
-
- it 'should maintain query string parameters' do
- response = strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'cheese=stilton'))
- response[1]['Location'].should == '/auth/test/callback?cheese=stilton'
- end
-
- it 'should not short circuit requests outside of authentication' do
- strategy.call(make_env('/')).should == app.call(make_env('/'))
- end
-
- it 'should respond with the default hash if none is set' do
- strategy.call make_env('/auth/test/callback')
- strategy.env['omniauth.auth']['uid'].should == '1234'
- end
-
- it 'should respond with a provider-specific hash if one is set' do
- OmniAuth.config.mock_auth[:test] = {
- 'uid' => 'abc'
- }
-
- strategy.call make_env('/auth/test/callback')
- strategy.env['omniauth.auth']['uid'].should == 'abc'
- end
-
- it 'should simulate login failure if mocked data is set as a symbol' do
- OmniAuth.config.mock_auth[:test] = :invalid_credentials
-
- strategy.call make_env('/auth/test/callback')
- strategy.env['omniauth.error.type'].should == :invalid_credentials
- end
-
- it 'should set omniauth.origin on the request phase' do
- strategy.call(make_env('/auth/test', 'HTTP_REFERER' => 'http://example.com/origin'))
- strategy.env['rack.session']['omniauth.origin'].should == 'http://example.com/origin'
- end
-
- it 'should set omniauth.origin from the params if provided' do
- strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'origin=/foo'))
- strategy.env['rack.session']['omniauth.origin'].should == '/foo'
- end
-
- it 'should turn omniauth.origin into an env variable on the callback phase' do
- OmniAuth.config.mock_auth[:test] = {}
-
- strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.origin' => 'http://example.com/origin'}))
- strategy.env['omniauth.origin'].should == 'http://example.com/origin'
- end
- end
-
- context 'custom full_host' do
- it 'should be the string when a string is there' do
- OmniAuth.config.full_host = 'my.host.com'
- strategy.full_host.should == 'my.host.com'
- end
-
- it 'should run the proc with the env when it is a proc' do
- OmniAuth.config.full_host = Proc.new{|env| env['HOST']}
- strategy.call(make_env('/auth/test', 'HOST' => 'my.host.net'))
- strategy.full_host.should == 'my.host.net'
- end
- end
- end
-
- context 'setup phase' do
- context 'when options[:setup] = true' do
- let(:strategy){ ExampleStrategy.new(app, 'test', :setup => true) }
- let(:app){lambda{|env| env['omniauth.strategy'].options[:awesome] = 'sauce' if env['PATH_INFO'] == '/auth/test/setup'; [404, {}, 'Awesome'] }}
-
- it 'should call through to /auth/:provider/setup' do
- strategy.call(make_env('/auth/test'))
- strategy.options[:awesome].should == 'sauce'
- end
-
- it 'should not call through on a non-omniauth endpoint' do
- strategy.call(make_env('/somewhere/else'))
- strategy.options[:awesome].should_not == 'sauce'
- end
- end
-
- context 'when options[:setup] is an app' do
- let(:setup_proc) do
- Proc.new do |env|
- env['omniauth.strategy'].options[:awesome] = 'sauce'
- end
- end
-
- let(:strategy){ ExampleStrategy.new(app, 'test', :setup => setup_proc) }
-
- it 'should not call the app on a non-omniauth endpoint' do
- strategy.call(make_env('/somehwere/else'))
- strategy.options[:awesome].should_not == 'sauce'
- end
-
- it 'should call the rack app' do
- strategy.call(make_env('/auth/test'))
- strategy.options[:awesome].should == 'sauce'
- end
- end
- end
-end
diff --git a/oa-core/spec/spec_helper.rb b/oa-core/spec/spec_helper.rb
deleted file mode 100644
index c9f3ecf..0000000
--- a/oa-core/spec/spec_helper.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'simplecov'
-SimpleCov.start
-require 'rspec'
-require 'rack/test'
-require 'omniauth/core'
-require 'omniauth/test'
-
-RSpec.configure do |config|
- config.include Rack::Test::Methods
- config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
-end
-
diff --git a/oa-enterprise/.gemtest b/oa-enterprise/.gemtest
deleted file mode 100644
index e69de29..0000000
diff --git a/oa-enterprise/.rspec b/oa-enterprise/.rspec
deleted file mode 100644
index bb259fe..0000000
--- a/oa-enterprise/.rspec
+++ /dev/null
@@ -1,3 +0,0 @@
---color
---format=nested
---backtrace
diff --git a/oa-enterprise/.yardopts b/oa-enterprise/.yardopts
deleted file mode 100644
index 7a69ee4..0000000
--- a/oa-enterprise/.yardopts
+++ /dev/null
@@ -1,4 +0,0 @@
---markup markdown
---markup-provider maruku
--
-LICENSE
diff --git a/oa-enterprise/Gemfile b/oa-enterprise/Gemfile
deleted file mode 100644
index 73a8e19..0000000
--- a/oa-enterprise/Gemfile
+++ /dev/null
@@ -1,11 +0,0 @@
-require File.expand_path('../lib/omniauth/version', __FILE__)
-
-source 'http://rubygems.org'
-
-gem 'oa-core', OmniAuth::Version::STRING, :path => '../oa-core'
-
-platforms :jruby do
- gem 'jruby-openssl', '~> 0.7'
-end
-
-gemspec
diff --git a/oa-enterprise/LICENSE b/oa-enterprise/LICENSE
deleted file mode 100644
index 811fa0e..0000000
--- a/oa-enterprise/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/oa-enterprise/README.rdoc b/oa-enterprise/README.rdoc
deleted file mode 100644
index bbd7976..0000000
--- a/oa-enterprise/README.rdoc
+++ /dev/null
@@ -1,115 +0,0 @@
-= OmniAuth::Enterprise
-
-OmniAuth strategies for use in your intranet.
-
-== Installation
-
-To get just enterprise functionality:
-
- gem install oa-enterprise
-
-For the full auth suite:
-
- gem install omniauth
-
-== CAS
-
-Use the CAS strategy as a middleware in your application:
-
- require 'omniauth/enterprise'
-
- use OmniAuth::Strategies::CAS, :server => 'http://cas.mycompany.com/cas'
-
-Then simply direct users to '/auth/cas' to have them sign in via your company's CAS server.
-See OmniAuth::Strategies::CAS::Configuration for more configuration options.
-
-== LDAP
-
-Use the LDAP strategy as a middleware in your application:
-
- require 'omniauth/enterprise'
- use OmniAuth::Strategies::LDAP,
- :title => "My LDAP",
- :host => '10.101.10.1',
- :port => 389,
- :method => :plain,
- :base => 'dc=intridea, dc=com',
- :uid => 'sAMAccountName',
- :name_proc => Proc.new {|name| name.gsub(/@.*$/,'')}
- :bind_dn => 'default_bind_dn'
- :password => 'password'
-
-All of the listed options are required, with the exception of :name_proc, :bind_dn, and :password
-Allowed values of :method are: :plain, :ssl, :tls.
-
-:bind_dn and :password are used to perform the initial binding if user lookup is
-needed. If the user lookup returns result, the DN attribute from the result set is used
-to perform the final binding. This is needed only when the LDAP server requires
-DN to be used for binding and you may only want user to using email or username
-in the login form.
-
-:uid is the LDAP attribute name for the user name in the login form. typically
-AD would be 'sAMAccountName' or 'UserPrincipalName', while OpenLDAP is 'uid'.
-You can also use 'dn', if your user choose the put in the dn in the login form
-(but usually is too long for user to remember or know).
-
-:name_proc allows you to match the user name entered with the format of the
-:uid attributes. For example, value of 'sAMAccountName' in AD contains only the
-windows user name. If your user prefers use email to login, a name_proc as
-above will trim the email string down to just the windows name. In summary,
-:name_proc helps you to fill the gap between the authentication and user lookup
-process.
-
-:try_sasl and :sasl_mechanisms are optional. Use them to initialize a SASL
-connection to server. Allowed values are 'DIGEST-MD5' and 'GSS-SPNEGO'. If you
-are not familiar with these authentication methods, please just avoid them.
-
-Direct users to '/auth/ldap' to have them authenticated via your
-company's LDAP server.
-
-== SAML
-
-Use the SAML strategy as a middleware in your application:
-
- require 'omniauth/enterprise'
- use OmniAuth::Strategies::SAML,
- :assertion_consumer_service_url => "consumer_service_url",
- :issuer => "issuer",
- :idp_sso_target_url => "idp_sso_target_url",
- :idp_cert_fingerprint => "E7:91:B2:E1:...",
- :name_identifier_format => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
-
-:assertion_consumer_service_url
- The URL at which the SAML assertion should be received.
-
-:issuer
- The name of your application. Some identity providers might need this to establish the
- identity of the service provider requesting the login.
-
-:idp_sso_target_url
- The URL to which the authentication request should be sent. This would be on the identity provider.
-
-:idp_cert_fingerprint
- The certificate fingerprint, e.g. "90:CC:16:F0:8D:A6:D1:C6:BB:27:2D:BA:93:80:1A:1F:16:8E:4E:08".
- This is provided from the identity provider when setting up the relationship.
-
-:name_identifier_format
- Describes the format of the username required by this application.
- If you need the email address, use "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress".
- See http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf section 8.3 for
- other options. Note that the identity provider might not support all options.
-
-
-== Multiple Strategies
-
-If you're using multiple strategies together, use OmniAuth's Builder. That's
-what it's there for:
-
- require 'omniauth/enterprise'
- require 'omniauth/oauth' # for Campfire
- require 'openid/store/filesystem'
-
- use OmniAuth::Builder do
- provider :cas, :server => 'http://cas.mycompany.com/cas'
- provider :campfire
- end
diff --git a/oa-enterprise/Rakefile b/oa-enterprise/Rakefile
deleted file mode 100644
index 69797fc..0000000
--- a/oa-enterprise/Rakefile
+++ /dev/null
@@ -1,6 +0,0 @@
-require 'bundler'
-Bundler::GemHelper.install_tasks
-require 'rspec/core/rake_task'
-RSpec::Core::RakeTask.new(:spec)
-task :default => :spec
-task :test => :spec
diff --git a/oa-enterprise/lib/oa-enterprise.rb b/oa-enterprise/lib/oa-enterprise.rb
deleted file mode 100644
index 0c48616..0000000
--- a/oa-enterprise/lib/oa-enterprise.rb
+++ /dev/null
@@ -1 +0,0 @@
-require 'omniauth/enterprise'
diff --git a/oa-enterprise/lib/omniauth/enterprise.rb b/oa-enterprise/lib/omniauth/enterprise.rb
deleted file mode 100644
index 77321f2..0000000
--- a/oa-enterprise/lib/omniauth/enterprise.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require 'omniauth/core'
-
-module OmniAuth
- module Strategies
- autoload :CAS, 'omniauth/strategies/cas'
- autoload :LDAP, 'omniauth/strategies/ldap'
- autoload :SAML, 'omniauth/strategies/saml'
- end
-end
diff --git a/oa-enterprise/lib/omniauth/strategies/cas.rb b/oa-enterprise/lib/omniauth/strategies/cas.rb
deleted file mode 100644
index 2bacc8c..0000000
--- a/oa-enterprise/lib/omniauth/strategies/cas.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require 'omniauth/enterprise'
-
-module OmniAuth
- module Strategies
- class CAS
- include OmniAuth::Strategy
-
- autoload :Configuration, 'omniauth/strategies/cas/configuration'
- autoload :ServiceTicketValidator, 'omniauth/strategies/cas/service_ticket_validator'
-
- def initialize(app, options = {}, &block)
- super(app, options[:name] || :cas, options.dup, &block)
- @configuration = OmniAuth::Strategies::CAS::Configuration.new(options)
- end
-
- protected
-
- def request_phase
- [
- 302,
- {
- 'Location' => @configuration.login_url(callback_url),
- 'Content-Type' => 'text/plain'
- },
- ["You are being redirected to CAS for sign-in."]
- ]
- end
-
- def callback_phase
- ticket = request.params['ticket']
- return fail!(:no_ticket, 'No CAS Ticket') unless ticket
- validator = ServiceTicketValidator.new(@configuration, callback_url, ticket)
- @user_info = validator.user_info
- return fail!(:invalid_ticket, 'Invalid CAS Ticket') if @user_info.nil? || @user_info.empty?
- super
- end
-
- def auth_hash
- OmniAuth::Utils.deep_merge(super, {
- 'uid' => @user_info.delete('user'),
- 'extra' => @user_info
- })
- end
-
- end
- end
-end
diff --git a/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb b/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb
deleted file mode 100644
index 7d5a174..0000000
--- a/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb
+++ /dev/null
@@ -1,98 +0,0 @@
-require 'rack'
-
-module OmniAuth
- module Strategies
- class CAS
- class Configuration
-
- DEFAULT_LOGIN_URL = "%s/login"
-
- DEFAULT_SERVICE_VALIDATE_URL = "%s/serviceValidate"
-
- # @param [Hash] params configuration options
- # @option params [String, nil] :cas_server the CAS server root URL; probably something like
- # `http://cas.mycompany.com` or `http://cas.mycompany.com/cas`; optional.
- # @option params [String, nil] :cas_login_url (:cas_server + '/login') the URL to which to
- # redirect for logins; options if `:cas_server` is specified,
- # required otherwise.
- # @option params [String, nil] :cas_service_validate_url (:cas_server + '/serviceValidate') the
- # URL to use for validating service tickets; optional if `:cas_server` is
- # specified, requred otherwise.
- # @option params [Boolean, nil] :disable_ssl_verification disable verification for SSL cert,
- # helpful when you developing with a fake cert.
- def initialize(params)
- parse_params params
- end
-
- # Build a CAS login URL from +service+.
- #
- # @param [String] service the service (a.k.a. return-to) URL
- #
- # @return [String] a URL like `http://cas.mycompany.com/login?service=...`
- def login_url(service)
- append_service @login_url, service
- end
-
- # Build a service-validation URL from +service+ and +ticket+.
- # If +service+ has a ticket param, first remove it. URL-encode
- # +service+ and add it and the +ticket+ as paraemters to the
- # CAS serviceValidate URL.
- #
- # @param [String] service the service (a.k.a. return-to) URL
- # @param [String] ticket the ticket to validate
- #
- # @return [String] a URL like `http://cas.mycompany.com/serviceValidate?service=...&ticket=...`
- def service_validate_url(service, ticket)
- service = service.sub(/[?&]ticket=[^?&]+/, '')
- url = append_service(@service_validate_url, service)
- url << '&ticket=' << Rack::Utils.escape(ticket)
- end
-
- def disable_ssl_verification?
- @disable_ssl_verification
- end
-
- private
-
- def parse_params(params)
- if params[:cas_server].nil? && params[:cas_login_url].nil?
- raise ArgumentError.new(":cas_server or :cas_login_url MUST be provided")
- end
- @login_url = params[:cas_login_url]
- @login_url ||= DEFAULT_LOGIN_URL % params[:cas_server]
- validate_is_url 'login URL', @login_url
-
- if params[:cas_server].nil? && params[:cas_service_validate_url].nil?
- raise ArgumentError.new(":cas_server or :cas_service_validate_url MUST be provided")
- end
- @service_validate_url = params[:cas_service_validate_url]
- @service_validate_url ||= DEFAULT_SERVICE_VALIDATE_URL % params[:cas_server]
- validate_is_url 'service-validate URL', @service_validate_url
-
- @disable_ssl_verification = params[:disable_ssl_verification]
- end
-
- IS_NOT_URL_ERROR_MESSAGE = "%s is not a valid URL"
-
- def validate_is_url(name, possibly_a_url)
- url = URI.parse(possibly_a_url) rescue nil
- raise ArgumentError.new(IS_NOT_URL_ERROR_MESSAGE % name) unless url.kind_of?(URI::HTTP)
- end
-
- # Adds +service+ as an URL-escaped parameter to +base+.
- #
- # @param [String] base the base URL
- # @param [String] service the service (a.k.a. return-to) URL.
- #
- # @return [String] the new joined URL.
- def append_service(base, service)
- result = base.dup
- result << (result.include?('?') ? '&' : '?')
- result << 'service='
- result << Rack::Utils.escape(service)
- end
-
- end
- end
- end
-end
diff --git a/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb b/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb
deleted file mode 100644
index 0a1249a..0000000
--- a/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-require 'net/http'
-require 'net/https'
-require 'nokogiri'
-
-module OmniAuth
- module Strategies
- class CAS
- class ServiceTicketValidator
-
- VALIDATION_REQUEST_HEADERS = { 'Accept' => '*/*' }
-
- # Build a validator from a +configuration+, a
- # +return_to+ URL, and a +ticket+.
- #
- # @param [OmniAuth::Strategies::CAS::Configuration] configuration the CAS configuration
- # @param [String] return_to_url the URL of this CAS client service
- # @param [String] ticket the service ticket to validate
- def initialize(configuration, return_to_url, ticket)
- @configuration = configuration
- @uri = URI.parse(@configuration.service_validate_url(return_to_url, ticket))
- end
-
- # Request validation of the ticket from the CAS server's
- # serviceValidate (CAS 2.0) function.
- #
- # Swallows all XML parsing errors (and returns +nil+ in those cases).
- #
- # @return [Hash, nil] a user information hash if the response is valid; +nil+ otherwise.
- #
- # @raise any connection errors encountered.
- def user_info
- parse_user_info(find_authentication_success(get_service_response_body))
- end
-
- private
-
- # turns an `` node into a Hash;
- # returns nil if given nil
- def parse_user_info(node)
- return nil if node.nil?
- hash = {}
- node.children.each do |e|
- unless e.kind_of?(Nokogiri::XML::Text) ||
- e.name == 'cas:proxies' ||
- e.name == 'proxies'
- # There are no child elements
- if e.element_children.count == 0
- hash[e.name.sub(/^cas:/, '')] = e.content
- elsif e.element_children.count
- hash[e.name.sub(/^cas:/, '')] = [] if hash[e.name.sub(/^cas:/, '')].nil?
- hash[e.name.sub(/^cas:/, '')].push parse_user_info e
- end
- end
- end
- hash
- end
-
- # finds an `` node in
- # a `` body if present; returns nil
- # if the passed body is nil or if there is no such node.
- def find_authentication_success(body)
- return nil if body.nil? || body == ''
- begin
- doc = Nokogiri::XML(body)
- begin
- doc.xpath('/cas:serviceResponse/cas:authenticationSuccess')
- rescue Nokogiri::XML::XPath::SyntaxError
- doc.xpath('/serviceResponse/authenticationSuccess')
- end
- rescue Nokogiri::XML::XPath::SyntaxError
- nil
- end
- end
-
- # retrieves the `` XML from the CAS server
- def get_service_response_body
- result = ''
- http = ::Net::HTTP.new(@uri.host, @uri.port)
- http.use_ssl = @uri.port == 443 || @uri.instance_of?(URI::HTTPS)
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl? && @configuration.disable_ssl_verification?
- http.start do |c|
- response = c.get "#{@uri.path}?#{@uri.query}", VALIDATION_REQUEST_HEADERS.dup
- result = response.body
- end
- result
- end
-
- end
- end
- end
-end
diff --git a/oa-enterprise/lib/omniauth/strategies/ldap.rb b/oa-enterprise/lib/omniauth/strategies/ldap.rb
deleted file mode 100644
index e65f7f9..0000000
--- a/oa-enterprise/lib/omniauth/strategies/ldap.rb
+++ /dev/null
@@ -1,124 +0,0 @@
-require 'omniauth/enterprise'
-require 'net/ldap'
-require 'sasl/base'
-require 'sasl'
-
-module OmniAuth
- module Strategies
- class LDAP
- include OmniAuth::Strategy
-
- autoload :Adaptor, 'omniauth/strategies/ldap/adaptor'
- @@config = {
- 'name' => 'cn',
- 'first_name' => 'givenName',
- 'last_name' => 'sn',
- 'email' => ['mail', "email", 'userPrincipalName'],
- 'phone' => ['telephoneNumber', 'homePhone', 'facsimileTelephoneNumber'],
- 'mobile_number' => ['mobile', 'mobileTelephoneNumber'],
- 'nickname' => ['uid', 'userid', 'sAMAccountName'],
- 'title' => 'title',
- 'location' => {"%0, %1, %2, %3 %4" => [['address', 'postalAddress', 'homePostalAddress', 'street', 'streetAddress'], ['l'], ['st'],['co'],['postOfficeBox']]},
- 'uid' => 'dn',
- 'url' => ['wwwhomepage'],
- 'image' => 'jpegPhoto',
- 'description' => 'description'
- }
-
- # Initialize the LDAP Middleware
- #
- # @param [Rack Application] app Standard Rack middleware argument.
- # @option options [String, 'LDAP Authentication'] :title A title for the authentication form.
- def initialize(app, options = {}, &block)
- super(app, options[:name] || :ldap, options.dup, &block)
- @name_proc = (@options.delete(:name_proc) || Proc.new {|name| name})
- @adaptor = OmniAuth::Strategies::LDAP::Adaptor.new(options)
- end
-
- protected
-
- def request_phase
- if env['REQUEST_METHOD'] == 'GET'
- get_credentials
- else
- session['omniauth.ldap'] = {'username' => request['username'], 'password' => request['password']}
- redirect callback_path
- end
- end
-
- def get_credentials
- OmniAuth::Form.build(:title => (options[:title] || "LDAP Authentication")) do
- text_field 'Login', 'username'
- password_field 'Password', 'password'
- end.to_response
- end
-
- def callback_phase
- begin
- creds = session['omniauth.ldap']
- session.delete 'omniauth.ldap'
- @ldap_user_info = {}
- begin
- (@adaptor.bind(:allow_anonymous => true) unless @adaptor.bound?)
- rescue Exception => e
- puts "failed to bind with the default credentials: " + e.message
- end
- @ldap_user_info = @adaptor.search(:filter => Net::LDAP::Filter.eq(@adaptor.uid, @name_proc.call(creds['username'])),:limit => 1) if @adaptor.bound?
- bind_dn = creds['username']
- bind_dn = @ldap_user_info[:dn].to_a.first if @ldap_user_info[:dn]
- @adaptor.bind(:bind_dn => bind_dn, :password => creds['password'])
- @ldap_user_info = @adaptor.search(:filter => Net::LDAP::Filter.eq(@adaptor.uid, @name_proc.call(creds['username'])),:limit => 1) if @ldap_user_info.empty?
- @user_info = self.class.map_user(@@config, @ldap_user_info)
-
- @env['omniauth.auth'] = auth_hash
-
- rescue Exception => e
- return fail!(:invalid_credentials, e)
- end
- call_app!
- end
-
- def auth_hash
- OmniAuth::Utils.deep_merge(super, {
- 'uid' => @user_info["uid"],
- 'user_info' => @user_info,
- 'extra' => @ldap_user_info
- })
- end
-
- # Use only first value if the field is returned as an Array
- def self.get_ldap_field(ldap_object, field)
- value = ldap_object[field.to_sym]
- case value
- when Array
- value.first.to_s
- else
- value.to_s
- end
- end
-
- def self.map_user(mapper, object)
- user = {}
- mapper.each do |key, value|
- case value
- when String
- user[key] = get_ldap_field(object, value.downcase) if object[value.downcase.to_sym]
- when Array
- value.each {|v| (user[key] = get_ldap_field(object, v.downcase); break;) if object[v.downcase.to_sym]}
- when Hash
- value.map do |key1, value1|
- pattern = key1.dup
- value1.each_with_index do |v,i|
- part = '';
- v.each {|v1| (part = get_ldap_field(object, v1.downcase); break;) if object[v1.downcase.to_sym]}
- pattern.gsub!("%#{i}",part||'')
- end
- user[key] = pattern
- end
- end
- end
- user
- end
- end
- end
-end
diff --git a/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb b/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb
deleted file mode 100644
index 3f53345..0000000
--- a/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb
+++ /dev/null
@@ -1,276 +0,0 @@
-#this code boughts pieces from activeldap and net-ldap
-
-require 'rack'
-require 'net/ldap'
-require 'net/ntlm'
-require 'uri'
-
-module OmniAuth
- module Strategies
- class LDAP
- class Adaptor
- class LdapError < StandardError; end
- class ConfigurationError < StandardError; end
- class AuthenticationError < StandardError; end
- class ConnectionError < StandardError; end
-
- VALID_ADAPTER_CONFIGURATION_KEYS = [:host, :port, :method, :bind_dn, :password, :try_sasl, :sasl_mechanisms, :uid, :base, :allow_anonymous]
-
- MUST_HAVE_KEYS = [:host, :port, :method, :uid, :base]
-
- METHOD = {
- :ssl => :simple_tls,
- :tls => :start_tls,
- :plain => nil,
- }
-
- attr_accessor :bind_dn, :password
- attr_reader :connection, :uid, :base
-
- def initialize(configuration={})
- @connection = nil
- @disconnected = false
- @bound = false
- @configuration = configuration.dup
- @configuration[:allow_anonymous] ||= false
- @logger = @configuration.delete(:logger)
- message = []
- MUST_HAVE_KEYS.each do |name|
- message << name if configuration[name].nil?
- end
- raise ArgumentError.new(message.join(",") +" MUST be provided") unless message.empty?
- VALID_ADAPTER_CONFIGURATION_KEYS.each do |name|
- instance_variable_set("@#{name}", configuration[name])
- end
- end
-
- def connect(options={})
- host = options[:host] || @host
- method = ensure_method(options[:method] || @method || :plain)
- port = options[:port] || @port || ensure_port(method)
- @disconnected = false
- @bound = false
- @bind_tried = false
-
- config = {
- :host => host,
- :port => port,
- }
-
- config[:encryption] = {:method => method} if method
-
- @connection, @uri, @with_start_tls = begin
- uri = construct_uri(host, port, method == :simple_tls)
- with_start_tls = method == :start_tls
- [Net::LDAP::Connection.new(config), uri, with_start_tls]
- rescue Net::LDAP::LdapError
- raise ConnectionError, $!.message
- end
- end
-
- def unbind(options={})
- @connection.close # Net::LDAP doesn't implement unbind.
- end
-
- def bind(options={})
- connect(options) unless connecting?
- begin
- @bind_tried = true
-
- bind_dn = (options[:bind_dn] || @bind_dn).to_s
- try_sasl = options.has_key?(:try_sasl) ? options[:try_sasl] : @try_sasl
- if options.has_key?(:allow_anonymous)
- allow_anonymous = options[:allow_anonymous]
- else
- allow_anonymous = @allow_anonymous
- end
- # Rough bind loop:
- # Attempt 1: SASL if available
- # Attempt 2: SIMPLE with credentials if password block
- # Attempt 3: SIMPLE ANONYMOUS if 1 and 2 fail and allow anonymous is set to true
- if try_sasl and sasl_bind(bind_dn, options)
- puts "bound with sasl"
- elsif simple_bind(bind_dn, options)
- puts "bound with simple"
- elsif allow_anonymous and bind_as_anonymous(options)
- puts "bound as anonymous"
- else
- message = yield if block_given?
- message ||= ('All authentication methods for %s exhausted.') % target
- raise AuthenticationError, message
- end
- @bound = true
- rescue Net::LDAP::LdapError
- raise AuthenticationError, $!.message
- end
- end
-
- def disconnect!(options={})
- unbind(options)
- @connection = @uri = @with_start_tls = nil
- @disconnected = true
- end
-
- def rebind(options={})
- unbind(options) if bound?
- connect(options)
- end
-
- def connecting?
- !@connection.nil? and !@disconnected
- end
-
- def bound?
- connecting? and @bound
- end
-
- def search(options={}, &block)
- base = options[:base] || @base
- filter = options[:filter]
- limit = options[:limit]
-
- args = {
- :base => base,
- :filter => filter,
- :size => limit
- }
-
- attributes = {}
- execute(:search, args) do |entry|
- entry.attribute_names.each do |name|
- attributes[name] = entry[name]
- end
- end
- attributes
- end
-
- private
-
- def execute(method, *args, &block)
- result = @connection.send(method, *args, &block)
- message = nil
-
- if result.is_a?(Hash)
- message = result[:errorMessage]
- result = result[:resultCode]
- end
-
- unless result.zero?
- message = [Net::LDAP.result2string(result), message].compact.join(": ")
- raise LdapError, message
- end
- end
-
- def ensure_port(method)
- if method == :ssl
- URI::LDAPS::DEFAULT_PORT
- else
- URI::LDAP::DEFAULT_PORT
- end
- end
-
- def prepare_connection(options)
- end
-
- def ensure_method(method)
- method ||= "plain"
- normalized_method = method.to_s.downcase.to_sym
- return METHOD[normalized_method] if METHOD.has_key?(normalized_method)
-
- available_methods = METHOD.keys.collect {|m| m.inspect}.join(", ")
- format = "%s is not one of the available connect methods: %s"
- raise ConfigurationError, format % [method.inspect, available_methods]
- end
-
- def sasl_bind(bind_dn, options={})
- sasl_mechanisms = options[:sasl_mechanisms] || @sasl_mechanisms
- sasl_mechanisms.each do |mechanism|
- begin
- normalized_mechanism = mechanism.downcase.gsub(/-/, '_')
- sasl_bind_setup = "sasl_bind_setup_#{normalized_mechanism}"
- next unless respond_to?(sasl_bind_setup, true)
- initial_credential, challenge_response = send(sasl_bind_setup, bind_dn, options)
-
- args = {
- :method => :sasl,
- :initial_credential => initial_credential,
- :mechanism => mechanism,
- :challenge_response => challenge_response,
- }
-
- info = {
- :name => "bind: SASL", :dn => bind_dn, :mechanism => mechanism,
- }
-
- execute(:bind, args)
- return true
-
- rescue Exception => e
- puts e.message
- end
- end
- false
- end
-
- def sasl_bind_setup_digest_md5(bind_dn, options)
- initial_credential = ""
- challenge_response = Proc.new do |cred|
- pref = SASL::Preferences.new :digest_uri => "ldap/#{@host}", :username => bind_dn, :has_password? => true, :password => options[:password]||@password
- sasl = SASL.new("DIGEST-MD5", pref)
- response = sasl.receive("challenge", cred)
- response[1]
- end
- [initial_credential, challenge_response]
- end
-
- def sasl_bind_setup_gss_spnego(bind_dn, options)
- user,psw = [bind_dn, options[:password]||@password]
- raise LdapError.new( "invalid binding information" ) unless (user && psw)
-
- nego = proc {|challenge|
- t2_msg = Net::NTLM::Message.parse( challenge )
- user, domain = user.split('\\').reverse
- t2_msg.target_name = Net::NTLM::encode_utf16le(domain) if domain
- t3_msg = t2_msg.response( {:user => user, :password => psw}, {:ntlmv2 => true} )
- t3_msg.serialize
- }
- [Net::NTLM::Message::Type1.new.serialize, nego]
- end
-
- def simple_bind(bind_dn, options={})
- args = {
- :method => :simple,
- :username => bind_dn,
- :password => (options[:password]||@password).to_s,
- }
- begin
- raise AuthenticationError if args[:password] == ""
- execute(:bind, args)
- true
- rescue Exception
- false
- end
- end
-
- def bind_as_anonymous(options={})
- execute(:bind, {:method => :anonymous})
- true
- end
-
- def construct_uri(host, port, ssl)
- protocol = ssl ? "ldaps" : "ldap"
- URI.parse("#{protocol}://#{host}:#{port}").to_s
- end
-
- def target
- return nil if @uri.nil?
- if @with_start_tls
- "#{@uri}(StartTLS)"
- else
- @uri
- end
- end
- end
- end
- end
-end
diff --git a/oa-enterprise/lib/omniauth/strategies/saml.rb b/oa-enterprise/lib/omniauth/strategies/saml.rb
deleted file mode 100644
index 4238b11..0000000
--- a/oa-enterprise/lib/omniauth/strategies/saml.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-require 'omniauth/enterprise'
-
-module OmniAuth
- module Strategies
- class SAML
- include OmniAuth::Strategy
- autoload :AuthRequest, 'omniauth/strategies/saml/auth_request'
- autoload :AuthResponse, 'omniauth/strategies/saml/auth_response'
- autoload :ValidationError, 'omniauth/strategies/saml/validation_error'
- autoload :XMLSecurity, 'omniauth/strategies/saml/xml_security'
-
- @@settings = {}
-
- def initialize(app, options={})
- super(app, :saml)
- @@settings = {
- :assertion_consumer_service_url => options[:assertion_consumer_service_url],
- :issuer => options[:issuer],
- :idp_sso_target_url => options[:idp_sso_target_url],
- :idp_cert_fingerprint => options[:idp_cert_fingerprint],
- :name_identifier_format => options[:name_identifier_format] || "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
- }
- end
-
- def request_phase
- request = OmniAuth::Strategies::SAML::AuthRequest.new
- redirect(request.create(@@settings))
- end
-
- def callback_phase
- begin
- response = OmniAuth::Strategies::SAML::AuthResponse.new(request.params['SAMLResponse'])
- response.settings = @@settings
- @name_id = response.name_id
- return fail!(:invalid_ticket, 'Invalid SAML Ticket') if @name_id.nil? || @name_id.empty?
- super
- rescue ArgumentError => e
- fail!(:invalid_ticket, 'Invalid SAML Response')
- end
- end
-
- def auth_hash
- OmniAuth::Utils.deep_merge(super, {
- 'uid' => @name_id
- })
- end
-
- end
- end
-end
diff --git a/oa-enterprise/lib/omniauth/strategies/saml/auth_request.rb b/oa-enterprise/lib/omniauth/strategies/saml/auth_request.rb
deleted file mode 100644
index 8129f5f..0000000
--- a/oa-enterprise/lib/omniauth/strategies/saml/auth_request.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require "base64"
-require "uuid"
-require "zlib"
-require "cgi"
-
-module OmniAuth
- module Strategies
- class SAML
- class AuthRequest
-
- def create(settings, params = {})
- uuid = "_" + UUID.new.generate
- time = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
-
- request =
- "" +
- "#{settings[:issuer]}\n" +
- "\n" +
- "" +
- "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport\n" +
- ""
-
- deflated_request = Zlib::Deflate.deflate(request, 9)[2..-5]
- base64_request = Base64.encode64(deflated_request)
- encoded_request = CGI.escape(base64_request)
- request_params = "?SAMLRequest=" + encoded_request
-
- params.each_pair do |key, value|
- request_params << "{key}=#{CGI.escape(value.to_s)}"
- end
-
- settings[:idp_sso_target_url] + request_params
- end
-
- end
- end
- end
-end
\ No newline at end of file
diff --git a/oa-enterprise/lib/omniauth/strategies/saml/auth_response.rb b/oa-enterprise/lib/omniauth/strategies/saml/auth_response.rb
deleted file mode 100644
index d63f39d..0000000
--- a/oa-enterprise/lib/omniauth/strategies/saml/auth_response.rb
+++ /dev/null
@@ -1,141 +0,0 @@
-require "time"
-
-module OmniAuth
- module Strategies
- class SAML
- class AuthResponse
-
- ASSERTION = "urn:oasis:names:tc:SAML:2.0:assertion"
- PROTOCOL = "urn:oasis:names:tc:SAML:2.0:protocol"
- DSIG = "http://www.w3.org/2000/09/xmldsig#"
-
- attr_accessor :options, :response, :document, :settings
-
- def initialize(response, options = {})
- raise ArgumentError.new("Response cannot be nil") if response.nil?
- self.options = options
- self.response = response
- self.document = OmniAuth::Strategies::SAML::XMLSecurity::SignedDocument.new(Base64.decode64(response))
- end
-
- def is_valid?
- validate(soft = true)
- end
-
- def validate!
- validate(soft = false)
- end
-
- # The value of the user identifier as designated by the initialization request response
- def name_id
- @name_id ||= begin
- node = REXML::XPath.first(document, "/p:Response/a:Assertion[@ID='#{document.signed_element_id[1,document.signed_element_id.size]}']/a:Subject/a:NameID", { "p" => PROTOCOL, "a" => ASSERTION })
- node ||= REXML::XPath.first(document, "/p:Response[@ID='#{document.signed_element_id[1,document.signed_element_id.size]}']/a:Assertion/a:Subject/a:NameID", { "p" => PROTOCOL, "a" => ASSERTION })
- node.nil? ? nil : node.text
- end
- end
-
- # A hash of alle the attributes with the response. Assuming there is only one value for each key
- def attributes
- @attr_statements ||= begin
- result = {}
-
- stmt_element = REXML::XPath.first(document, "/p:Response/a:Assertion/a:AttributeStatement", { "p" => PROTOCOL, "a" => ASSERTION })
- return {} if stmt_element.nil?
-
- stmt_element.elements.each do |attr_element|
- name = attr_element.attributes["Name"]
- value = attr_element.elements.first.text
-
- result[name] = value
- end
-
- result.keys.each do |key|
- result[key.intern] = result[key]
- end
-
- result
- end
- end
-
- # When this user session should expire at latest
- def session_expires_at
- @expires_at ||= begin
- node = REXML::XPath.first(document, "/p:Response/a:Assertion/a:AuthnStatement", { "p" => PROTOCOL, "a" => ASSERTION })
- parse_time(node, "SessionNotOnOrAfter")
- end
- end
-
- # Conditions (if any) for the assertion to run
- def conditions
- @conditions ||= begin
- REXML::XPath.first(document, "/p:Response/a:Assertion[@ID='#{document.signed_element_id[1,document.signed_element_id.size]}']/a:Conditions", { "p" => PROTOCOL, "a" => ASSERTION })
- end
- end
-
- private
-
- def validation_error(message)
- raise OmniAuth::Strategies::SAML::ValidationError.new(message)
- end
-
- def validate(soft = true)
- validate_response_state(soft) &&
- validate_conditions(soft) &&
- document.validate(get_fingerprint, soft)
- end
-
- def validate_response_state(soft = true)
- if response.empty?
- return soft ? false : validation_error("Blank response")
- end
-
- if settings.nil?
- return soft ? false : validation_error("No settings on response")
- end
-
- if settings.idp_cert_fingerprint.nil? && settings.idp_cert.nil?
- return soft ? false : validation_error("No fingerprint or certificate on settings")
- end
-
- true
- end
-
- def get_fingerprint
- if settings.idp_cert
- cert = OpenSSL::X509::Certificate.new(settings.idp_cert)
- Digest::SHA1.hexdigest(cert.to_der).upcase.scan(/../).join(":")
- else
- settings.idp_cert_fingerprint
- end
- end
-
- def validate_conditions(soft = true)
- return true if conditions.nil?
- return true if options[:skip_conditions]
-
- if not_before = parse_time(conditions, "NotBefore")
- if Time.now.utc < not_before
- return soft ? false : validation_error("Current time is earlier than NotBefore condition")
- end
- end
-
- if not_on_or_after = parse_time(conditions, "NotOnOrAfter")
- if Time.now.utc >= not_on_or_after
- return soft ? false : validation_error("Current time is on or after NotOnOrAfter condition")
- end
- end
-
- true
- end
-
- def parse_time(node, attribute)
- if node && node.attributes[attribute]
- Time.parse(node.attributes[attribute])
- end
- end
-
- end
- end
- end
-end
\ No newline at end of file
diff --git a/oa-enterprise/lib/omniauth/strategies/saml/validation_error.rb b/oa-enterprise/lib/omniauth/strategies/saml/validation_error.rb
deleted file mode 100644
index f62f763..0000000
--- a/oa-enterprise/lib/omniauth/strategies/saml/validation_error.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-module OmniAuth
- module Strategies
- class SAML
- class ValidationError < Exception
- end
- end
- end
-end
\ No newline at end of file
diff --git a/oa-enterprise/lib/omniauth/strategies/saml/xml_security.rb b/oa-enterprise/lib/omniauth/strategies/saml/xml_security.rb
deleted file mode 100644
index 06974c8..0000000
--- a/oa-enterprise/lib/omniauth/strategies/saml/xml_security.rb
+++ /dev/null
@@ -1,126 +0,0 @@
-# The contents of this file are subject to the terms
-# of the Common Development and Distribution License
-# (the License). You may not use this file except in
-# compliance with the License.
-#
-# You can obtain a copy of the License at
-# https://opensso.dev.java.net/public/CDDLv1.0.html or
-# opensso/legal/CDDLv1.0.txt
-# See the License for the specific language governing
-# permission and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL
-# Header Notice in each file and include the License file
-# at opensso/legal/CDDLv1.0.txt.
-# If applicable, add the following below the CDDL Header,
-# with the fields enclosed by brackets [] replaced by
-# your own identifying information:
-# "Portions Copyrighted [year] [name of copyright owner]"
-#
-# $Id: xml_sec.rb,v 1.6 2007/10/24 00:28:41 todddd Exp $
-#
-# Copyright 2007 Sun Microsystems Inc. All Rights Reserved
-# Portions Copyrighted 2007 Todd W Saxton.
-
-require 'rubygems'
-require "rexml/document"
-require "rexml/xpath"
-require "openssl"
-require "xmlcanonicalizer"
-require "digest/sha1"
-
-module OmniAuth
- module Strategies
- class SAML
-
- module XMLSecurity
-
- class SignedDocument < REXML::Document
- DSIG = "http://www.w3.org/2000/09/xmldsig#"
-
- attr_accessor :signed_element_id
-
- def initialize(response)
- super(response)
- extract_signed_element_id
- end
-
- def validate(idp_cert_fingerprint, soft = true)
- # get cert from response
- base64_cert = self.elements["//ds:X509Certificate"].text
- cert_text = Base64.decode64(base64_cert)
- cert = OpenSSL::X509::Certificate.new(cert_text)
-
- # check cert matches registered idp cert
- fingerprint = Digest::SHA1.hexdigest(cert.to_der)
-
- if fingerprint != idp_cert_fingerprint.gsub(/[^a-zA-Z0-9]/,"").downcase
- return soft ? false : (raise OmniAuth::Strategies::SAML::ValidationError.new("Fingerprint mismatch"))
- end
-
- validate_doc(base64_cert, soft)
- end
-
- def validate_doc(base64_cert, soft = true)
- # validate references
-
- # check for inclusive namespaces
-
- inclusive_namespaces = []
- inclusive_namespace_element = REXML::XPath.first(self, "//ec:InclusiveNamespaces")
-
- if inclusive_namespace_element
- prefix_list = inclusive_namespace_element.attributes.get_attribute('PrefixList').value
- inclusive_namespaces = prefix_list.split(" ")
- end
-
- # remove signature node
- sig_element = REXML::XPath.first(self, "//ds:Signature", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"})
- sig_element.remove
-
- # check digests
- REXML::XPath.each(sig_element, "//ds:Reference", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}) do |ref|
- uri = ref.attributes.get_attribute("URI").value
- hashed_element = REXML::XPath.first(self, "//[@ID='#{uri[1,uri.size]}']")
- canoner = XML::Util::XmlCanonicalizer.new(false, true)
- canoner.inclusive_namespaces = inclusive_namespaces if canoner.respond_to?(:inclusive_namespaces) && !inclusive_namespaces.empty?
- canon_hashed_element = canoner.canonicalize(hashed_element)
- hash = Base64.encode64(Digest::SHA1.digest(canon_hashed_element)).chomp
- digest_value = REXML::XPath.first(ref, "//ds:DigestValue", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}).text
-
- if hash != digest_value
- return soft ? false : (raise OmniAuth::Strategies::SAML::ValidationError.new("Digest mismatch"))
- end
- end
-
- # verify signature
- canoner = XML::Util::XmlCanonicalizer.new(false, true)
- signed_info_element = REXML::XPath.first(sig_element, "//ds:SignedInfo", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"})
- canon_string = canoner.canonicalize(signed_info_element)
-
- base64_signature = REXML::XPath.first(sig_element, "//ds:SignatureValue", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}).text
- signature = Base64.decode64(base64_signature)
-
- # get certificate object
- cert_text = Base64.decode64(base64_cert)
- cert = OpenSSL::X509::Certificate.new(cert_text)
-
- if !cert.public_key.verify(OpenSSL::Digest::SHA1.new, signature, canon_string)
- return soft ? false : (raise OmniAuth::Strategies::SAML::ValidationError.new("Key validation error"))
- end
-
- return true
- end
-
- private
-
- def extract_signed_element_id
- reference_element = REXML::XPath.first(self, "//ds:Signature/ds:SignedInfo/ds:Reference", {"ds"=>DSIG})
- self.signed_element_id = reference_element.attribute("URI").value unless reference_element.nil?
- end
- end
- end
-
- end
- end
-end
\ No newline at end of file
diff --git a/oa-enterprise/lib/omniauth/version.rb b/oa-enterprise/lib/omniauth/version.rb
deleted file mode 100644
index 9f980b0..0000000
--- a/oa-enterprise/lib/omniauth/version.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-module OmniAuth
- module Version
- unless defined?(::OmniAuth::Version::MAJOR)
- MAJOR = 0
- end
- unless defined?(::OmniAuth::Version::MINOR)
- MINOR = 3
- end
- unless defined?(::OmniAuth::Version::PATCH)
- PATCH = 0
- end
- unless defined?(::OmniAuth::Version::PRE)
- PRE = "rc3"
- end
- unless defined?(::OmniAuth::Version::STRING)
- STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
- end
- end
-end
diff --git a/oa-enterprise/oa-enterprise.gemspec b/oa-enterprise/oa-enterprise.gemspec
deleted file mode 100644
index 0eb4c47..0000000
--- a/oa-enterprise/oa-enterprise.gemspec
+++ /dev/null
@@ -1,31 +0,0 @@
-# encoding: utf-8
-require File.expand_path('../lib/omniauth/version', __FILE__)
-
-Gem::Specification.new do |gem|
- gem.add_dependency 'addressable', '~> 2.2.6'
- gem.add_dependency 'net-ldap', '~> 0.2.2'
- gem.add_dependency 'nokogiri', '~> 1.5.0'
- gem.add_dependency 'oa-core', OmniAuth::Version::STRING
- gem.add_dependency 'pyu-ruby-sasl', '~> 0.0.3.1'
- gem.add_dependency 'rubyntlm', '~> 0.1.1'
- gem.add_dependency 'uuid'
- gem.add_dependency 'XMLCanonicalizer', '~> 1.0.1'
- gem.add_development_dependency 'rack-test', '~> 0.5'
- gem.add_development_dependency 'rake', '~> 0.8'
- gem.add_development_dependency 'rdiscount', '~> 1.6'
- gem.add_development_dependency 'rspec', '~> 2.5'
- gem.add_development_dependency 'simplecov', '~> 0.4'
- gem.add_development_dependency 'webmock', '~> 1.7'
- gem.add_development_dependency 'yard', '~> 0.7'
- gem.authors = ['James A. Rosen', 'Ping Yu', 'Michael Bleigh', 'Erik Michaels-Ober', 'Raecoo Cao']
- gem.description = %q{Enterprise strategies for OmniAuth.}
- gem.email = ['james.a.rosen@gmail.com', 'ping@intridea.com', 'michael@intridea.com', 'sferik@gmail.com', 'raecoo@intridea.com']
- gem.files = `git ls-files`.split("\n")
- gem.homepage = 'http://github.com/intridea/omniauth'
- gem.name = 'oa-enterprise'
- gem.require_paths = ['lib']
- gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version=
- gem.summary = gem.description
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
- gem.version = OmniAuth::Version::STRING
-end
diff --git a/oa-enterprise/spec/fixtures/cas_failure.xml b/oa-enterprise/spec/fixtures/cas_failure.xml
deleted file mode 100644
index f8238a1..0000000
--- a/oa-enterprise/spec/fixtures/cas_failure.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/oa-enterprise/spec/fixtures/cas_success.xml b/oa-enterprise/spec/fixtures/cas_success.xml
deleted file mode 100644
index 5a621ff..0000000
--- a/oa-enterprise/spec/fixtures/cas_success.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- psegel
- Peter
- Segel
- 2004-07-13
-
-
diff --git a/oa-enterprise/spec/omniauth/strategies/cas_spec.rb b/oa-enterprise/spec/omniauth/strategies/cas_spec.rb
deleted file mode 100644
index a43bda5..0000000
--- a/oa-enterprise/spec/omniauth/strategies/cas_spec.rb
+++ /dev/null
@@ -1,94 +0,0 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require 'cgi'
-
-describe OmniAuth::Strategies::CAS, :type => :strategy do
-
- include OmniAuth::Test::StrategyTestCase
-
- def strategy
- @cas_server ||= 'https://cas.example.org'
- [OmniAuth::Strategies::CAS, {:cas_server => @cas_server}]
- end
-
- describe 'GET /auth/cas' do
- before do
- get '/auth/cas'
- end
-
- it 'should redirect to the CAS server' do
- last_response.should be_redirect
- return_to = CGI.escape(last_request.url + '/callback')
- last_response.headers['Location'].should == @cas_server + '/login?service=' + return_to
- end
- end
-
- describe 'GET /auth/cas/callback without a ticket' do
- before do
- get '/auth/cas/callback'
- end
- it 'should fail' do
- last_response.should be_redirect
- last_response.headers['Location'].should =~ /no_ticket/
- end
- end
-
- describe 'GET /auth/cas/callback with an invalid ticket' do
- before do
- stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=9391d/).
- to_return(:body => File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'cas_failure.xml')))
- get '/auth/cas/callback?ticket=9391d'
- end
- it 'should fail' do
- last_response.should be_redirect
- last_response.headers['Location'].should =~ /invalid_ticket/
- end
- end
-
- describe 'GET /auth/cas/callback with a valid ticket' do
- before do
- stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=593af/).
- with { |request| @request_uri = request.uri.to_s }.
- to_return(:body => File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'cas_success.xml')))
- get '/auth/cas/callback?ticket=593af'
- end
-
- it 'should strip the ticket parameter from the callback URL before sending it to the CAS server' do
- @request_uri.scan('ticket=').length.should == 1
- end
-
- sets_an_auth_hash
- sets_provider_to 'cas'
- sets_uid_to 'psegel'
-
- it 'should set additional user information' do
- extra = (last_request.env['omniauth.auth'] || {})['extra']
- extra.should be_kind_of(Hash)
- extra['first-name'].should == 'Peter'
- extra['last-name'].should == 'Segel'
- extra['hire-date'].should == '2004-07-13'
- end
-
- it 'should call through to the master app' do
- last_response.body.should == 'true'
- end
- end
-
- unless RUBY_VERSION =~ /^1\.8\.\d$/
- describe 'GET /auth/cas/callback with a valid ticket and gzipped response from the server on ruby >1.8' do
- before do
- zipped = StringIO.new
- Zlib::GzipWriter.wrap zipped do |io|
- io.write File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'cas_success.xml'))
- end
- stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=593af/).
- with { |request| @request_uri = request.uri.to_s }.
- to_return(:body => zipped.string, :headers => { 'content-encoding' => 'gzip' })
- get '/auth/cas/callback?ticket=593af'
- end
-
- it 'should call through to the master app when response is gzipped' do
- last_response.body.should == 'true'
- end
- end
- end
-end
diff --git a/oa-enterprise/spec/omniauth/strategies/ldap_spec.rb b/oa-enterprise/spec/omniauth/strategies/ldap_spec.rb
deleted file mode 100644
index 0517fbd..0000000
--- a/oa-enterprise/spec/omniauth/strategies/ldap_spec.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require 'cgi'
-
-describe OmniAuth::Strategies::LDAP, :type => :strategy do
-
- include OmniAuth::Test::StrategyTestCase
-
- def strategy
- @ldap_server ||= 'ldap.example.org'
- [OmniAuth::Strategies::LDAP, {
- :host => @ldap_server,
- :port => 636,
- :method => :ssl,
- :uid => 'jeremyf',
- :base => 'o="University of OmniAuth", st=Sublime, c=RubyNation',
- }]
- end
-
- describe 'GET /auth/ldap' do
- before do
- get '/auth/ldap'
- end
-
- # TODO: Add checks that page has authentication form; I attempted
- # to use `should have_tag` but that was not working.
- it 'should get authentication page' do
- last_response.status.should == 200
- end
- end
-
- describe 'POST /auth/ldap' do
- before do
- post '/auth/ldap', {:username => 'jeremy', :password => 'valid_password' }
- end
-
- it 'should redirect us to /auth/ldap/callback' do
- last_response.should be_redirect
- last_response.location.should == '/auth/ldap/callback'
- end
- end
-end
\ No newline at end of file
diff --git a/oa-enterprise/spec/omniauth/strategies/saml_spec.rb b/oa-enterprise/spec/omniauth/strategies/saml_spec.rb
deleted file mode 100644
index 2bd1776..0000000
--- a/oa-enterprise/spec/omniauth/strategies/saml_spec.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-
-describe OmniAuth::Strategies::SAML, :type => :strategy do
-
- include OmniAuth::Test::StrategyTestCase
-
- def strategy
- [OmniAuth::Strategies::SAML, {
- :assertion_consumer_service_url => "http://consumer.service.url/auth/saml/callback",
- :issuer => "https://saml.issuer.url/issuers/29490",
- :idp_sso_target_url => "https://idp.sso.target_url/signon/29490",
- :idp_cert_fingerprint => "E7:91:B2:E1:4C:65:2C:49:F3:33:74:0A:58:5A:7E:55:F7:15:7A:33",
- :name_identifier_format => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
- }]
- end
-
- describe 'GET /auth/saml' do
- before do
- get '/auth/saml'
- end
-
- it 'should get authentication page' do
- last_response.should be_redirect
- end
- end
-
- describe 'POST /auth/saml/callback' do
-
- it 'should raise ArgumentError exception without the SAMLResponse parameter' do
- post '/auth/saml/callback'
- last_response.should be_redirect
- last_response.location.should == '/auth/failure?message=invalid_ticket'
- end
-
- end
-
-end
\ No newline at end of file
diff --git a/oa-enterprise/spec/spec_helper.rb b/oa-enterprise/spec/spec_helper.rb
deleted file mode 100644
index 45bfc33..0000000
--- a/oa-enterprise/spec/spec_helper.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require 'simplecov'
-SimpleCov.start
-require 'rspec'
-require 'rack/test'
-require 'webmock/rspec'
-require 'omniauth/core'
-require 'omniauth/test'
-require 'omniauth/enterprise'
-
-RSpec.configure do |config|
- config.include WebMock::API
- config.include Rack::Test::Methods
- config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
-end
diff --git a/oa-identity/.rspec b/oa-identity/.rspec
deleted file mode 100644
index f7ddb05..0000000
--- a/oa-identity/.rspec
+++ /dev/null
@@ -1,2 +0,0 @@
---format=nested
---colour
diff --git a/oa-identity/README.markdown b/oa-identity/README.markdown
deleted file mode 100644
index b7c88a0..0000000
--- a/oa-identity/README.markdown
+++ /dev/null
@@ -1,90 +0,0 @@
-# OmniAuth Identity
-
-The OmniAuth Identity gem provides a way for applications to utilize a
-traditional login/password based authentication system without the need
-to give up the simple authentication flow provided by OmniAuth. Identity
-is designed on purpose to be as featureless as possible: it provides the
-basic construct for user management and then gets out of the way.
-
-## Usage
-
-You use `oa-identity` just like you would any other OmniAuth provider: as a
-Rack middleware. The basic setup for a email/password authentication would
-look something like this:
-
- use OmniAuth::Builder do
- provider :identity, :fields => [:email]
- end
-
-Next, you need to create a model (called `Identity by default`) that will be
-able to persist the information provided by the user. Luckily for you, there
-are pre-built models for popular ORMs that make this dead simple. You just
-need to subclass the relevant class:
-
- class Identity < OmniAuth::Identity::Models::ActiveRecord
- # Add whatever you like!
- end
-
-Adapters are provided for `ActiveRecord` and `MongoMapper` and are
-autoloaded on request (but not loaded by default so no dependencies are
-injected).
-
-Once you've got an Identity persistence model and the strategy up and
-running, you can point users to `/auth/identity` and it will request
-that they log in or give them the opportunity to sign up for an account.
-Once they have authenticated with their identity, OmniAuth will call
-through to `/auth/identity/callback` with the same kinds of information
-it would had the user authenticated through an external provider.
-Simple!
-
-## Custom Auth Model
-
-To use a class other than the default, specify the :model option to a
-different class.
-
- use OmniAuth::Builder do
- provider :identity, :fields => [:email], :model => MyCustomClass
- end
-
-## Customizing Registration Failure
-
-To use your own custom registration form, create a form that POSTs to
-'/auth/identity/register' with 'password', 'password_confirmation', and your
-other fields.
-
- <%= form_tag '/auth/identity/register' do |f| %>
-
Create an Account
- <%= text_field_tag :email %>
- <%= password_field_tag, :password %>
- <%= password_field_tag, :password_confirmation %>
- <%= submit_tag %>
- <% end %>
-
-Beware not to nest your form parameters within a namespace. This strategy
-looks for the form parameters at the top level of the post params. If you are
-using [simple\_form](https://github.com/plataformatec/simple_form), then you
-can avoid the params nesting by specifying :input_html.
-
- <%= simple_form_for @identity, :url => '/auth/identity/register' do |f| %>
-
Create an Account
- <%# specify :input_html to avoid params nesting %>
- <%= f.input :email, :input_html => {:name => 'email'} %>
- <%= f.input :password, :as => 'password', :input_html => {:name => 'password'} %>
- <%= f.input :password_confirmation, :label => "Confirm Password", :as => 'password', :input_html => {:name => 'password_confirmation'} %>
-
- <% end %>
-
-Next you'll need to let OmniAuth know what action to call when a registration
-fails. In your OmniAuth configuration, specify any valid rack endpoint in the
-:on_failed_registration option.
-
- use OmniAuth::Builder do
- provider :identity,
- :fields => [:email],
- :on_failed_registration => UsersController.action(:new)
- end
-
-For more information on rack endpoints, check out [this
-introduction](http://library.edgecase.com/Rails/2011/01/04/rails-routing-and-rack-endpoints.html)
-and
-[ActionController::Metal](http://rubydoc.info/docs/rails/ActionController/Metal)
diff --git a/oa-identity/Rakefile b/oa-identity/Rakefile
deleted file mode 100644
index f7205cb..0000000
--- a/oa-identity/Rakefile
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'bundler'
-Bundler::GemHelper.install_tasks
-
-require 'rspec/core/rake_task'
-RSpec::Core::RakeTask.new(:spec)
-
-task :default => :spec
-task :test => :spec
diff --git a/oa-identity/lib/oa-identity.rb b/oa-identity/lib/oa-identity.rb
deleted file mode 100644
index 2a3ab8f..0000000
--- a/oa-identity/lib/oa-identity.rb
+++ /dev/null
@@ -1 +0,0 @@
-require 'omniauth/identity'
diff --git a/oa-identity/lib/omniauth/identity.rb b/oa-identity/lib/omniauth/identity.rb
deleted file mode 100644
index 1a15411..0000000
--- a/oa-identity/lib/omniauth/identity.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require 'omniauth/core'
-
-module OmniAuth
- module Strategies
- autoload :Identity, 'omniauth/strategies/identity'
- end
-
- module Identity
- autoload :Model, 'omniauth/identity/model'
- autoload :SecurePassword, 'omniauth/identity/secure_password'
- module Models
- autoload :ActiveRecord, 'omniauth/identity/models/active_record'
- # autoload :MongoMapper, 'omniauth/identity/models/mongo_mapper'
- # autoload :Mongoid, 'omniauth/identity/models/mongoid'
- end
- end
-end
diff --git a/oa-identity/lib/omniauth/identity/model.rb b/oa-identity/lib/omniauth/identity/model.rb
deleted file mode 100644
index 8f3a5d6..0000000
--- a/oa-identity/lib/omniauth/identity/model.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-module OmniAuth
- module Identity
- # This module provides an includable interface for implementing the
- # necessary API for OmniAuth Identity to properly locate identities
- # and provide all necessary information. All methods marked as
- # abstract must be implemented in the including class for things to
- # work properly.
- module Model
- def self.included(base)
- base.extend ClassMethods
- end
-
- module ClassMethods
- # Locate an identity given its unique login key.
- #
- # @abstract
- # @param [String] key The unique login key.
- # @return [Model] An instance of the identity model class.
- def locate(key)
- raise NotImplementedError
- end
-
- # Authenticate a user with the given key and password.
- #
- # @param [String] key The unique login key provided for a given identity.
- # @param [String] password The presumed password for the identity.
- # @return [Model] An instance of the identity model class.
- def authenticate(key, password)
- instance = locate(key)
- return false unless instance
- instance.authenticate(password)
- end
-
- # Used to set or retrieve the method that will be used to get
- # and set the user-supplied authentication key.
- # @return [String] The method name.
- def auth_key(method = false)
- @auth_key = method.to_s unless method == false
- @auth_key = nil if @auth_key == ''
-
- @auth_key || 'email'
- end
- end
-
- # Returns self if the provided password is correct, false
- # otherwise.
- #
- # @abstract
- # @param [String] password The password to check.
- # @return [self or false] Self if authenticated, false if not.
- def authenticate(password)
- raise NotImplementedError
- end
-
- SCHEMA_ATTRIBUTES = %w(name email nickname first_name last_name location description image phone)
- # A hash of as much of the standard OmniAuth schema as is stored
- # in this particular model. By default, this will call instance
- # methods for each of the attributes it needs in turn, ignoring
- # any for which `#respond_to?` is `false`.
- #
- # If `first_name`, `nickname`, and/or `last_name` is provided but
- # `name` is not, it will be automatically calculated.
- #
- # @return [Hash] A string-keyed hash of user information.
- def user_info
- info = SCHEMA_ATTRIBUTES.inject({}) do |hash,attribute|
- hash[attribute] = send(attribute) if respond_to?(attribute)
- hash
- end
-
- info['name'] ||= [info['first_name'], info['last_name']].join(' ').strip if info['first_name'] || info['last_name']
- info['name'] ||= info['nickname']
-
- info
- end
-
- # An identifying string that must be globally unique to the
- # application. Defaults to stringifying the `id` method.
- #
- # @return [String] An identifier string unique to this identity.
- def uid
- if respond_to?('id')
- return nil if self.id.nil?
- self.id.to_s
- else
- raise NotImplementedError
- end
- end
-
- # Used to retrieve the user-supplied authentication key (e.g. a
- # username or email). Determined using the class method of the same name,
- # defaults to `:email`.
- #
- # @return [String] An identifying string that will be entered by
- # users upon sign in.
- def auth_key
- if respond_to?(self.class.auth_key)
- send(self.class.auth_key)
- else
- raise NotImplementedError
- end
- end
-
- # Used to set the user-supplied authentication key (e.g. a
- # username or email. Determined using the `.auth_key` class
- # method.
- #
- # @param [String] value The value to which the auth key should be
- # set.
- def auth_key=(value)
- if respond_to?(self.class.auth_key + '=')
- send(self.class.auth_key + '=', value)
- else
- raise NotImplementedError
- end
- end
- end
- end
-end
diff --git a/oa-identity/lib/omniauth/identity/models/active_record.rb b/oa-identity/lib/omniauth/identity/models/active_record.rb
deleted file mode 100644
index 3bfbe9c..0000000
--- a/oa-identity/lib/omniauth/identity/models/active_record.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require 'active_record'
-
-module OmniAuth
- module Identity
- module Models
- class ActiveRecord < ::ActiveRecord::Base
- include OmniAuth::Identity::Model
- include OmniAuth::Identity::SecurePassword
-
- self.abstract_class = true
- has_secure_password
-
- def self.auth_key=(key)
- super
- validates_uniqueness_of key, :case_sensitive => false
- end
-
- def self.locate(key)
- where(auth_key => key).first
- end
- end
- end
- end
-end
diff --git a/oa-identity/lib/omniauth/identity/secure_password.rb b/oa-identity/lib/omniauth/identity/secure_password.rb
deleted file mode 100644
index b420747..0000000
--- a/oa-identity/lib/omniauth/identity/secure_password.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-require 'bcrypt'
-
-module OmniAuth
- module Identity
- # This is taken directly from Rails 3.1 code and is used if
- # the version of ActiveModel that's being used does not
- # include SecurePassword. The only difference is that instead of
- # using ActiveSupport::Concern, it checks to see if there is already
- # a has_secure_password method.
- module SecurePassword
- def self.included(base)
- unless base.respond_to?(:has_secure_password)
- base.extend ClassMethods
- end
- end
-
- module ClassMethods
- # Adds methods to set and authenticate against a BCrypt password.
- # This mechanism requires you to have a password_digest attribute.
- #
- # Validations for presence of password, confirmation of password (using
- # a "password_confirmation" attribute) are automatically added.
- # You can add more validations by hand if need be.
- #
- # Example using Active Record (which automatically includes ActiveModel::SecurePassword):
- #
- # # Schema: User(name:string, password_digest:string)
- # class User < ActiveRecord::Base
- # has_secure_password
- # end
- #
- # user = User.new(:name => "david", :password => "", :password_confirmation => "nomatch")
- # user.save # => false, password required
- # user.password = "mUc3m00RsqyRe"
- # user.save # => false, confirmation doesn't match
- # user.password_confirmation = "mUc3m00RsqyRe"
- # user.save # => true
- # user.authenticate("notright") # => false
- # user.authenticate("mUc3m00RsqyRe") # => user
- # User.find_by_name("david").try(:authenticate, "notright") # => nil
- # User.find_by_name("david").try(:authenticate, "mUc3m00RsqyRe") # => user
- def has_secure_password
- attr_reader :password
-
- validates_confirmation_of :password
- validates_presence_of :password_digest
-
- include InstanceMethodsOnActivation
-
- if respond_to?(:attributes_protected_by_default)
- def self.attributes_protected_by_default
- super + ['password_digest']
- end
- end
- end
- end
-
- module InstanceMethodsOnActivation
- # Returns self if the password is correct, otherwise false.
- def authenticate(unencrypted_password)
- if BCrypt::Password.new(password_digest) == unencrypted_password
- self
- else
- false
- end
- end
-
- # Encrypts the password into the password_digest attribute.
- def password=(unencrypted_password)
- @password = unencrypted_password
- unless unencrypted_password.blank?
- self.password_digest = BCrypt::Password.create(unencrypted_password)
- end
- end
- end
- end
- end
-end
diff --git a/oa-identity/lib/omniauth/strategies/identity.rb b/oa-identity/lib/omniauth/strategies/identity.rb
deleted file mode 100644
index 680b844..0000000
--- a/oa-identity/lib/omniauth/strategies/identity.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-module OmniAuth
- module Strategies
- # The identity strategy allows you to provide simple internal
- # user authentication using the same process flow that you
- # use for external OmniAuth providers.
- class Identity
- include OmniAuth::Strategy
-
- # @option options [Symbol] :name The name you want to use for this strategy.
- # @option options [Symbol] :model The class you wish to use as the identity model.
- # @option options [Array] :fields ([:name, :email]) Required information at identity registration.
- def initialize(app, options = {})
- options[:fields] ||= [:name, :email]
- super(app, options[:name] || :identity, options.dup)
- end
-
- def request_phase
- OmniAuth::Form.build(
- :title => (options[:title] || "Identity Verification"),
- :url => callback_path
- ) do |f|
- f.text_field 'Login', 'auth_key'
- f.password_field 'Password', 'password'
- f.html "