oa-enterprise 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/omniauth/strategies/cas.rb +6 -6
- data/lib/omniauth/strategies/cas/configuration.rb +3 -3
- data/lib/omniauth/strategies/cas/service_ticket_validator.rb +5 -5
- data/lib/omniauth/strategies/ldap.rb +18 -17
- data/lib/omniauth/strategies/ldap/adaptor.rb +208 -212
- data/lib/omniauth/version.rb +19 -0
- data/oa-enterprise.gemspec +9 -6
- data/spec/omniauth/strategies/cas_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -4
- metadata +49 -27
- data/Gemfile +0 -3
@@ -4,19 +4,19 @@ module OmniAuth
|
|
4
4
|
module Strategies
|
5
5
|
class CAS
|
6
6
|
include OmniAuth::Strategy
|
7
|
-
|
7
|
+
|
8
8
|
autoload :Configuration, 'omniauth/strategies/cas/configuration'
|
9
9
|
autoload :ServiceTicketValidator, 'omniauth/strategies/cas/service_ticket_validator'
|
10
|
-
|
10
|
+
|
11
11
|
def initialize(app, options = {}, &block)
|
12
12
|
super(app, options[:name] || :cas, options.dup, &block)
|
13
13
|
@configuration = OmniAuth::Strategies::CAS::Configuration.new(options)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
protected
|
17
|
-
|
17
|
+
|
18
18
|
def request_phase
|
19
|
-
[
|
19
|
+
[
|
20
20
|
302,
|
21
21
|
{
|
22
22
|
'Location' => @configuration.login_url(callback_url),
|
@@ -34,7 +34,7 @@ module OmniAuth
|
|
34
34
|
return fail!(:invalid_ticket, 'Invalid CAS Ticket') if @user_info.nil? || @user_info.empty?
|
35
35
|
super
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def auth_hash
|
39
39
|
OmniAuth::Utils.deep_merge(super, {
|
40
40
|
'uid' => @user_info.delete('user'),
|
@@ -4,7 +4,7 @@ module OmniAuth
|
|
4
4
|
module Strategies
|
5
5
|
class CAS
|
6
6
|
class Configuration
|
7
|
-
|
7
|
+
|
8
8
|
DEFAULT_LOGIN_URL = "%s/login"
|
9
9
|
|
10
10
|
DEFAULT_SERVICE_VALIDATE_URL = "%s/serviceValidate"
|
@@ -27,7 +27,7 @@ module OmniAuth
|
|
27
27
|
# Build a CAS login URL from +service+.
|
28
28
|
#
|
29
29
|
# @param [String] service the service (a.k.a. return-to) URL
|
30
|
-
#
|
30
|
+
#
|
31
31
|
# @return [String] a URL like `http://cas.mycompany.com/login?service=...`
|
32
32
|
def login_url(service)
|
33
33
|
append_service @login_url, service
|
@@ -91,7 +91,7 @@ module OmniAuth
|
|
91
91
|
result << 'service='
|
92
92
|
result << Rack::Utils.escape(service)
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -5,7 +5,7 @@ require 'nokogiri'
|
|
5
5
|
module OmniAuth
|
6
6
|
module Strategies
|
7
7
|
class CAS
|
8
|
-
class ServiceTicketValidator
|
8
|
+
class ServiceTicketValidator
|
9
9
|
|
10
10
|
VALIDATION_REQUEST_HEADERS = { 'Accept' => '*/*' }
|
11
11
|
|
@@ -47,7 +47,7 @@ module OmniAuth
|
|
47
47
|
hash
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
# finds an `<cas:authenticationSuccess>` node in
|
52
52
|
# a `<cas:serviceResponse>` body if present; returns nil
|
53
53
|
# if the passed body is nil or if there is no such node.
|
@@ -64,11 +64,11 @@ module OmniAuth
|
|
64
64
|
nil
|
65
65
|
end
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
# retrieves the `<cas:serviceResponse>` XML from the CAS server
|
69
69
|
def get_service_response_body
|
70
70
|
result = ''
|
71
|
-
http = Net::HTTP.new(@uri.host, @uri.port)
|
71
|
+
http = ::Net::HTTP.new(@uri.host, @uri.port)
|
72
72
|
http.use_ssl = @uri.port == 443 || @uri.instance_of?(URI::HTTPS)
|
73
73
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl? && @configuration.disable_ssl_verification?
|
74
74
|
http.start do |c|
|
@@ -77,7 +77,7 @@ module OmniAuth
|
|
77
77
|
end
|
78
78
|
result
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -7,9 +7,9 @@ module OmniAuth
|
|
7
7
|
module Strategies
|
8
8
|
class LDAP
|
9
9
|
include OmniAuth::Strategy
|
10
|
-
|
10
|
+
|
11
11
|
autoload :Adaptor, 'omniauth/strategies/ldap/adaptor'
|
12
|
-
@@config = {'name' => 'cn',
|
12
|
+
@@config = {'name' => 'cn',
|
13
13
|
'first_name' => 'givenName',
|
14
14
|
'last_name' => 'sn',
|
15
15
|
'email' => ['mail', "email", 'userPrincipalName'],
|
@@ -32,9 +32,9 @@ module OmniAuth
|
|
32
32
|
@name_proc = (@options.delete(:name_proc) || Proc.new {|name| name})
|
33
33
|
@adaptor = OmniAuth::Strategies::LDAP::Adaptor.new(options)
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
protected
|
37
|
-
|
37
|
+
|
38
38
|
def request_phase
|
39
39
|
if env['REQUEST_METHOD'] == 'GET'
|
40
40
|
get_credentials
|
@@ -51,15 +51,16 @@ module OmniAuth
|
|
51
51
|
end.to_response
|
52
52
|
end
|
53
53
|
|
54
|
-
def callback_phase
|
54
|
+
def callback_phase
|
55
55
|
begin
|
56
|
-
creds = session
|
56
|
+
creds = session['omniauth.ldap']
|
57
|
+
session.delete 'omniauth.ldap'
|
57
58
|
@ldap_user_info = {}
|
58
|
-
begin
|
59
|
-
(@adaptor.bind(:allow_anonymous => true) unless @adaptor.bound?)
|
60
|
-
rescue Exception => e
|
59
|
+
begin
|
60
|
+
(@adaptor.bind(:allow_anonymous => true) unless @adaptor.bound?)
|
61
|
+
rescue Exception => e
|
61
62
|
puts "failed to bind with the default credentials: " + e.message
|
62
|
-
end
|
63
|
+
end
|
63
64
|
@ldap_user_info = @adaptor.search(:filter => Net::LDAP::Filter.eq(@adaptor.uid, @name_proc.call(creds['username'])),:limit => 1) if @adaptor.bound?
|
64
65
|
bind_dn = creds['username']
|
65
66
|
bind_dn = @ldap_user_info[:dn].to_a.first if @ldap_user_info[:dn]
|
@@ -68,13 +69,13 @@ module OmniAuth
|
|
68
69
|
@user_info = self.class.map_user(@@config, @ldap_user_info)
|
69
70
|
|
70
71
|
@env['omniauth.auth'] = auth_hash
|
71
|
-
|
72
|
+
|
72
73
|
rescue Exception => e
|
73
74
|
return fail!(:invalid_credentials, e)
|
74
75
|
end
|
75
76
|
call_app!
|
76
|
-
end
|
77
|
-
|
77
|
+
end
|
78
|
+
|
78
79
|
def auth_hash
|
79
80
|
OmniAuth::Utils.deep_merge(super, {
|
80
81
|
'uid' => @user_info["uid"],
|
@@ -82,7 +83,7 @@ module OmniAuth
|
|
82
83
|
'extra' => @ldap_user_info
|
83
84
|
})
|
84
85
|
end
|
85
|
-
|
86
|
+
|
86
87
|
def self.map_user(mapper, object)
|
87
88
|
user = {}
|
88
89
|
mapper.each do |key, value|
|
@@ -97,14 +98,14 @@ module OmniAuth
|
|
97
98
|
value1.each_with_index do |v,i|
|
98
99
|
part = '';
|
99
100
|
v.each {|v1| (part = object[v1.downcase.to_sym].to_s; break;) if object[v1.downcase.to_sym]}
|
100
|
-
pattern.gsub!("%#{i}",part||'')
|
101
|
-
end
|
101
|
+
pattern.gsub!("%#{i}",part||'')
|
102
|
+
end
|
102
103
|
user[key] = pattern
|
103
104
|
end
|
104
105
|
end
|
105
106
|
end
|
106
107
|
user
|
107
|
-
end
|
108
|
+
end
|
108
109
|
end
|
109
110
|
end
|
110
111
|
end
|
@@ -9,50 +9,49 @@ module OmniAuth
|
|
9
9
|
module Strategies
|
10
10
|
class LDAP
|
11
11
|
class Adaptor
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
class LdapError < StandardError; end
|
13
|
+
class ConfigurationError < StandardError; end
|
14
|
+
class AuthenticationError < StandardError; end
|
15
|
+
class ConnectionError < StandardError; end
|
16
|
+
|
17
17
|
VALID_ADAPTER_CONFIGURATION_KEYS = [:host, :port, :method, :bind_dn, :password,
|
18
18
|
:try_sasl, :sasl_mechanisms, :uid, :base, :allow_anonymous]
|
19
|
-
|
19
|
+
|
20
20
|
MUST_HAVE_KEYS = [:host, :port, :method, :uid, :base]
|
21
|
-
|
21
|
+
|
22
22
|
METHOD = {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
23
|
+
:ssl => :simple_tls,
|
24
|
+
:tls => :start_tls,
|
25
|
+
:plain => nil,
|
26
|
+
}
|
27
|
+
|
28
|
+
attr_accessor :bind_dn, :password
|
29
|
+
attr_reader :connection, :uid, :base
|
30
|
+
|
31
|
+
def initialize(configuration={})
|
32
|
+
@connection = nil
|
33
|
+
@disconnected = false
|
34
|
+
@bound = false
|
35
|
+
@configuration = configuration.dup
|
36
|
+
@configuration[:allow_anonymous] ||= false
|
37
|
+
@logger = @configuration.delete(:logger)
|
38
|
+
message = []
|
39
|
+
MUST_HAVE_KEYS.each do |name|
|
40
|
+
message << name if configuration[name].nil?
|
41
|
+
end
|
42
|
+
raise ArgumentError.new(message.join(",") +" MUST be provided") unless message.empty?
|
43
43
|
VALID_ADAPTER_CONFIGURATION_KEYS.each do |name|
|
44
44
|
instance_variable_set("@#{name}", configuration[name])
|
45
45
|
end
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
@bound = false
|
55
|
-
@bind_tried = false
|
48
|
+
def connect(options={})
|
49
|
+
host = options[:host] || @host
|
50
|
+
method = ensure_method(options[:method] || @method || :plain)
|
51
|
+
port = options[:port] || @port || ensure_port(method)
|
52
|
+
@disconnected = false
|
53
|
+
@bound = false
|
54
|
+
@bind_tried = false
|
56
55
|
|
57
56
|
config = {
|
58
57
|
:host => host,
|
@@ -60,7 +59,7 @@ module OmniAuth
|
|
60
59
|
}
|
61
60
|
|
62
61
|
config[:encryption] = {:method => method} if method
|
63
|
-
|
62
|
+
|
64
63
|
@connection, @uri, @with_start_tls = begin
|
65
64
|
uri = construct_uri(host, port, method == :simple_tls)
|
66
65
|
with_start_tls = method == :start_tls
|
@@ -69,78 +68,74 @@ module OmniAuth
|
|
69
68
|
rescue Net::LDAP::LdapError
|
70
69
|
raise ConnectionError, $!.message
|
71
70
|
end
|
71
|
+
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
73
|
+
def unbind(options={})
|
74
|
+
@connection.close # Net::LDAP doesn't implement unbind.
|
75
|
+
end
|
76
|
+
|
77
|
+
def bind(options={})
|
78
|
+
connect(options) unless connecting?
|
79
|
+
begin
|
80
|
+
@bind_tried = true
|
81
|
+
|
82
|
+
bind_dn = (options[:bind_dn] || @bind_dn).to_s
|
83
|
+
try_sasl = options.has_key?(:try_sasl) ? options[:try_sasl] : @try_sasl
|
84
|
+
if options.has_key?(:allow_anonymous)
|
85
|
+
allow_anonymous = options[:allow_anonymous]
|
86
|
+
else
|
87
|
+
allow_anonymous = @allow_anonymous
|
88
|
+
end
|
89
|
+
# Rough bind loop:
|
90
|
+
# Attempt 1: SASL if available
|
91
|
+
# Attempt 2: SIMPLE with credentials if password block
|
92
|
+
# Attempt 3: SIMPLE ANONYMOUS if 1 and 2 fail and allow anonymous is set to true
|
93
|
+
if try_sasl and sasl_bind(bind_dn, options)
|
94
|
+
puts "bound with sasl"
|
95
|
+
elsif simple_bind(bind_dn, options)
|
96
|
+
puts "bound with simple"
|
97
|
+
elsif allow_anonymous and bind_as_anonymous(options)
|
98
|
+
puts "bound as anonymous"
|
99
|
+
else
|
100
|
+
message = yield if block_given?
|
101
|
+
message ||= ('All authentication methods for %s exhausted.') % target
|
102
|
+
raise AuthenticationError, message
|
103
|
+
end
|
104
|
+
@bound = true
|
105
|
+
rescue Net::LDAP::LdapError
|
106
|
+
raise AuthenticationError, $!.message
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def disconnect!(options={})
|
111
|
+
unbind(options)
|
112
|
+
@connection = @uri = @with_start_tls = nil
|
113
|
+
@disconnected = true
|
114
|
+
end
|
115
|
+
|
116
|
+
def rebind(options={})
|
117
|
+
unbind(options) if bound?
|
118
|
+
connect(options)
|
119
|
+
end
|
120
|
+
|
121
|
+
def connecting?
|
122
|
+
!@connection.nil? and !@disconnected
|
90
123
|
end
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
@bound = true
|
108
|
-
rescue Net::LDAP::LdapError
|
109
|
-
raise AuthenticationError, $!.message
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def disconnect!(options={})
|
114
|
-
unbind(options)
|
115
|
-
@connection = @uri = @with_start_tls = nil
|
116
|
-
@disconnected = true
|
117
|
-
end
|
118
|
-
|
119
|
-
def rebind(options={})
|
120
|
-
unbind(options) if bound?
|
121
|
-
connect(options)
|
122
|
-
end
|
123
|
-
|
124
|
-
def connecting?
|
125
|
-
!@connection.nil? and !@disconnected
|
126
|
-
end
|
127
|
-
|
128
|
-
def bound?
|
129
|
-
connecting? and @bound
|
130
|
-
end
|
131
|
-
|
132
|
-
def search(options={}, &block)
|
133
|
-
base = options[:base]
|
134
|
-
filter = options[:filter]
|
135
|
-
limit = options[:limit]
|
136
|
-
|
137
|
-
args = {
|
138
|
-
:base => @base,
|
139
|
-
:filter => filter,
|
140
|
-
:size => limit
|
141
|
-
}
|
142
|
-
|
143
|
-
puts args.inspect
|
124
|
+
|
125
|
+
def bound?
|
126
|
+
connecting? and @bound
|
127
|
+
end
|
128
|
+
|
129
|
+
def search(options={}, &block)
|
130
|
+
base = options[:base]
|
131
|
+
filter = options[:filter]
|
132
|
+
limit = options[:limit]
|
133
|
+
|
134
|
+
args = {
|
135
|
+
:base => @base,
|
136
|
+
:filter => filter,
|
137
|
+
:size => limit
|
138
|
+
}
|
144
139
|
|
145
140
|
attributes = {}
|
146
141
|
execute(:search, args) do |entry|
|
@@ -151,11 +146,11 @@ module OmniAuth
|
|
151
146
|
attributes
|
152
147
|
end
|
153
148
|
|
154
|
-
|
155
|
-
|
149
|
+
private
|
150
|
+
|
156
151
|
def execute(method, *args, &block)
|
157
|
-
|
158
|
-
|
152
|
+
result = @connection.send(method, *args, &block)
|
153
|
+
message = nil
|
159
154
|
|
160
155
|
if result.is_a?(Hash)
|
161
156
|
message = result[:errorMessage]
|
@@ -166,117 +161,118 @@ module OmniAuth
|
|
166
161
|
message = [Net::LDAP.result2string(result), message].compact.join(": ")
|
167
162
|
raise LdapError, message
|
168
163
|
end
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
164
|
+
end
|
165
|
+
|
166
|
+
def ensure_port(method)
|
167
|
+
if method == :ssl
|
168
|
+
URI::LDAPS::DEFAULT_PORT
|
169
|
+
else
|
170
|
+
URI::LDAP::DEFAULT_PORT
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def prepare_connection(options)
|
175
|
+
end
|
176
|
+
|
177
|
+
def ensure_method(method)
|
178
|
+
method ||= "plain"
|
179
|
+
normalized_method = method.to_s.downcase.to_sym
|
180
|
+
return METHOD[normalized_method] if METHOD.has_key?(normalized_method)
|
181
|
+
|
182
|
+
available_methods = METHOD.keys.collect {|m| m.inspect}.join(", ")
|
183
|
+
format = "%s is not one of the available connect methods: %s"
|
184
|
+
raise ConfigurationError, format % [method.inspect, available_methods]
|
185
|
+
end
|
186
|
+
|
187
|
+
def sasl_bind(bind_dn, options={})
|
188
|
+
sasl_mechanisms = options[:sasl_mechanisms] || @sasl_mechanisms
|
189
|
+
sasl_mechanisms.each do |mechanism|
|
190
|
+
begin
|
191
|
+
normalized_mechanism = mechanism.downcase.gsub(/-/, '_')
|
192
|
+
sasl_bind_setup = "sasl_bind_setup_#{normalized_mechanism}"
|
193
|
+
next unless respond_to?(sasl_bind_setup, true)
|
194
|
+
initial_credential, challenge_response = send(sasl_bind_setup, bind_dn, options)
|
195
|
+
|
196
|
+
args = {
|
197
|
+
:method => :sasl,
|
198
|
+
:initial_credential => initial_credential,
|
199
|
+
:mechanism => mechanism,
|
200
|
+
:challenge_response => challenge_response,
|
201
|
+
}
|
202
|
+
|
203
|
+
info = {
|
204
|
+
:name => "bind: SASL", :dn => bind_dn, :mechanism => mechanism,
|
205
|
+
}
|
206
|
+
|
207
|
+
execute(:bind, args)
|
208
|
+
return true
|
209
|
+
|
210
|
+
rescue Exception => e
|
211
|
+
puts e.message
|
212
|
+
end
|
218
213
|
end
|
214
|
+
false
|
215
|
+
end
|
216
|
+
|
217
|
+
def sasl_bind_setup_digest_md5(bind_dn, options)
|
218
|
+
initial_credential = ""
|
219
|
+
challenge_response = Proc.new do |cred|
|
220
|
+
pref = SASL::Preferences.new :digest_uri => "ldap/#{@host}", :username => bind_dn, :has_password? => true, :password => options[:password]||@password
|
221
|
+
sasl = SASL.new("DIGEST-MD5", pref)
|
222
|
+
response = sasl.receive("challenge", cred)
|
223
|
+
response[1]
|
219
224
|
end
|
225
|
+
[initial_credential, challenge_response]
|
226
|
+
end
|
220
227
|
|
221
|
-
|
222
|
-
|
228
|
+
def sasl_bind_setup_gss_spnego(bind_dn, options)
|
229
|
+
puts options.inspect
|
230
|
+
user,psw = [bind_dn, options[:password]||@password]
|
231
|
+
raise LdapError.new( "invalid binding information" ) unless (user && psw)
|
223
232
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
233
|
+
nego = proc {|challenge|
|
234
|
+
t2_msg = Net::NTLM::Message.parse( challenge )
|
235
|
+
user, domain = user.split('\\').reverse
|
236
|
+
t2_msg.target_name = Net::NTLM::encode_utf16le(domain) if domain
|
237
|
+
t3_msg = t2_msg.response( {:user => user, :password => psw}, {:ntlmv2 => true} )
|
238
|
+
t3_msg.serialize
|
239
|
+
}
|
240
|
+
[Net::NTLM::Message::Type1.new.serialize, nego]
|
231
241
|
end
|
232
|
-
[initial_credential, challenge_response]
|
233
|
-
end
|
234
242
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
:method => :simple,
|
253
|
-
:username => bind_dn,
|
254
|
-
:password => (options[:password]||@password).to_s,
|
255
|
-
}
|
256
|
-
begin
|
257
|
-
execute(:bind, args)
|
243
|
+
def simple_bind(bind_dn, options={})
|
244
|
+
args = {
|
245
|
+
:method => :simple,
|
246
|
+
:username => bind_dn,
|
247
|
+
:password => (options[:password]||@password).to_s,
|
248
|
+
}
|
249
|
+
begin
|
250
|
+
raise AuthenticationError if args[:password] == ""
|
251
|
+
execute(:bind, args)
|
252
|
+
true
|
253
|
+
rescue Exception
|
254
|
+
false
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
def bind_as_anonymous(options={})
|
259
|
+
execute(:bind, {:method => :anonymous})
|
258
260
|
true
|
259
|
-
rescue Exception
|
260
|
-
false
|
261
261
|
end
|
262
|
-
end
|
263
|
-
def bind_as_anonymous(options={})
|
264
|
-
execute(:bind, {:method => :anonymous})
|
265
|
-
true
|
266
|
-
end
|
267
|
-
def construct_uri(host, port, ssl)
|
268
|
-
protocol = ssl ? "ldaps" : "ldap"
|
269
|
-
URI.parse("#{protocol}://#{host}:#{port}").to_s
|
270
|
-
end
|
271
262
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
263
|
+
def construct_uri(host, port, ssl)
|
264
|
+
protocol = ssl ? "ldaps" : "ldap"
|
265
|
+
URI.parse("#{protocol}://#{host}:#{port}").to_s
|
266
|
+
end
|
267
|
+
|
268
|
+
def target
|
269
|
+
return nil if @uri.nil?
|
270
|
+
if @with_start_tls
|
271
|
+
"#{@uri}(StartTLS)"
|
272
|
+
else
|
273
|
+
@uri
|
274
|
+
end
|
278
275
|
end
|
279
|
-
end
|
280
276
|
end
|
281
277
|
end
|
282
278
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module OmniAuth
|
2
|
+
module Version
|
3
|
+
unless defined?(::OmniAuth::Version::MAJOR)
|
4
|
+
MAJOR = 0
|
5
|
+
end
|
6
|
+
unless defined?(::OmniAuth::Version::MINOR)
|
7
|
+
MINOR = 2
|
8
|
+
end
|
9
|
+
unless defined?(::OmniAuth::Version::PATCH)
|
10
|
+
PATCH = 5
|
11
|
+
end
|
12
|
+
unless defined?(::OmniAuth::Version::PRE)
|
13
|
+
PRE = nil
|
14
|
+
end
|
15
|
+
unless defined?(::OmniAuth::Version::STRING)
|
16
|
+
STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/oa-enterprise.gemspec
CHANGED
@@ -1,23 +1,26 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('
|
2
|
+
require File.expand_path('../lib/omniauth/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.add_runtime_dependency 'addressable', '2.2.4'
|
6
|
-
gem.add_runtime_dependency '
|
6
|
+
gem.add_runtime_dependency 'jruby-openssl', '~> 0.7.3' if RUBY_PLATFORM == 'java'
|
7
7
|
gem.add_runtime_dependency 'nokogiri', '~> 1.4.2'
|
8
|
-
gem.add_runtime_dependency 'net-ldap', '~> 0.
|
9
|
-
gem.add_runtime_dependency '
|
8
|
+
gem.add_runtime_dependency 'net-ldap', '~> 0.2.2'
|
9
|
+
gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING
|
10
10
|
gem.add_runtime_dependency 'pyu-ruby-sasl', '~> 0.0.3.1'
|
11
|
+
gem.add_runtime_dependency 'rubyntlm', '~> 0.1.1'
|
12
|
+
gem.add_development_dependency 'maruku', '~> 0.6'
|
11
13
|
gem.add_development_dependency 'simplecov', '~> 0.4'
|
12
14
|
gem.add_development_dependency 'rack-test', '~> 0.5'
|
13
15
|
gem.add_development_dependency 'rake', '~> 0.8'
|
14
16
|
gem.add_development_dependency 'rspec', '~> 2.5'
|
15
17
|
gem.add_development_dependency 'webmock', '~> 1.6'
|
16
18
|
gem.add_development_dependency 'yard', '~> 0.6'
|
19
|
+
gem.add_development_dependency 'ZenTest', '~> 4.5'
|
17
20
|
gem.name = 'oa-enterprise'
|
18
|
-
gem.version =
|
19
|
-
gem.summary = %q{Enterprise strategies for OmniAuth.}
|
21
|
+
gem.version = OmniAuth::Version::STRING
|
20
22
|
gem.description = %q{Enterprise strategies for OmniAuth.}
|
23
|
+
gem.summary = gem.description
|
21
24
|
gem.email = ['james.a.rosen@gmail.com', 'ping@intridea.com', 'michael@intridea.com', 'sferik@gmail.com']
|
22
25
|
gem.homepage = 'http://github.com/intridea/omniauth'
|
23
26
|
gem.authors = ['James A. Rosen', 'Ping Yu', 'Michael Bleigh', 'Erik Michaels-Ober']
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
2
|
require 'cgi'
|
3
3
|
|
4
4
|
describe OmniAuth::Strategies::CAS, :type => :strategy do
|
@@ -86,8 +86,8 @@ describe OmniAuth::Strategies::CAS, :type => :strategy do
|
|
86
86
|
get '/auth/cas/callback?ticket=593af'
|
87
87
|
end
|
88
88
|
|
89
|
-
it 'should call through to the master app when response is gzipped' do
|
90
|
-
last_response.body.should == 'true'
|
89
|
+
it 'should call through to the master app when response is gzipped' do
|
90
|
+
last_response.body.should == 'true'
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'simplecov'
|
2
2
|
SimpleCov.start
|
3
3
|
require 'rspec'
|
4
|
-
require 'rspec/autorun'
|
5
|
-
require 'webmock/rspec'
|
6
4
|
require 'rack/test'
|
5
|
+
require 'webmock/rspec'
|
7
6
|
require 'omniauth/core'
|
8
7
|
require 'omniauth/test'
|
9
8
|
require 'omniauth/enterprise'
|
@@ -13,5 +12,3 @@ RSpec.configure do |config|
|
|
13
12
|
config.include Rack::Test::Methods
|
14
13
|
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
15
14
|
end
|
16
|
-
|
17
|
-
WebMock.disable_net_connect!
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: oa-enterprise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James A. Rosen
|
@@ -13,7 +13,7 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2011-04-
|
16
|
+
date: 2011-04-29 00:00:00 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: addressable
|
@@ -27,126 +27,148 @@ dependencies:
|
|
27
27
|
type: :runtime
|
28
28
|
version_requirements: *id001
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
30
|
+
name: nokogiri
|
31
31
|
prerelease: false
|
32
32
|
requirement: &id002 !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
37
|
+
version: 1.4.2
|
38
38
|
type: :runtime
|
39
39
|
version_requirements: *id002
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
|
-
name:
|
41
|
+
name: net-ldap
|
42
42
|
prerelease: false
|
43
43
|
requirement: &id003 !ruby/object:Gem::Requirement
|
44
44
|
none: false
|
45
45
|
requirements:
|
46
46
|
- - ~>
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 0.2.2
|
49
49
|
type: :runtime
|
50
50
|
version_requirements: *id003
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
|
-
name:
|
52
|
+
name: oa-core
|
53
53
|
prerelease: false
|
54
54
|
requirement: &id004 !ruby/object:Gem::Requirement
|
55
55
|
none: false
|
56
56
|
requirements:
|
57
|
-
- -
|
57
|
+
- - "="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.
|
59
|
+
version: 0.2.5
|
60
60
|
type: :runtime
|
61
61
|
version_requirements: *id004
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
63
|
+
name: pyu-ruby-sasl
|
64
64
|
prerelease: false
|
65
65
|
requirement: &id005 !ruby/object:Gem::Requirement
|
66
66
|
none: false
|
67
67
|
requirements:
|
68
68
|
- - ~>
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: 0.
|
70
|
+
version: 0.0.3.1
|
71
71
|
type: :runtime
|
72
72
|
version_requirements: *id005
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
|
-
name:
|
74
|
+
name: rubyntlm
|
75
75
|
prerelease: false
|
76
76
|
requirement: &id006 !ruby/object:Gem::Requirement
|
77
77
|
none: false
|
78
78
|
requirements:
|
79
79
|
- - ~>
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 0.
|
81
|
+
version: 0.1.1
|
82
82
|
type: :runtime
|
83
83
|
version_requirements: *id006
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
85
|
+
name: maruku
|
86
86
|
prerelease: false
|
87
87
|
requirement: &id007 !ruby/object:Gem::Requirement
|
88
88
|
none: false
|
89
89
|
requirements:
|
90
90
|
- - ~>
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: "0.
|
92
|
+
version: "0.6"
|
93
93
|
type: :development
|
94
94
|
version_requirements: *id007
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
|
-
name:
|
96
|
+
name: simplecov
|
97
97
|
prerelease: false
|
98
98
|
requirement: &id008 !ruby/object:Gem::Requirement
|
99
99
|
none: false
|
100
100
|
requirements:
|
101
101
|
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: "0.
|
103
|
+
version: "0.4"
|
104
104
|
type: :development
|
105
105
|
version_requirements: *id008
|
106
106
|
- !ruby/object:Gem::Dependency
|
107
|
-
name:
|
107
|
+
name: rack-test
|
108
108
|
prerelease: false
|
109
109
|
requirement: &id009 !ruby/object:Gem::Requirement
|
110
110
|
none: false
|
111
111
|
requirements:
|
112
112
|
- - ~>
|
113
113
|
- !ruby/object:Gem::Version
|
114
|
-
version: "0.
|
114
|
+
version: "0.5"
|
115
115
|
type: :development
|
116
116
|
version_requirements: *id009
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
118
|
+
name: rake
|
119
119
|
prerelease: false
|
120
120
|
requirement: &id010 !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: "
|
125
|
+
version: "0.8"
|
126
126
|
type: :development
|
127
127
|
version_requirements: *id010
|
128
128
|
- !ruby/object:Gem::Dependency
|
129
|
-
name:
|
129
|
+
name: rspec
|
130
130
|
prerelease: false
|
131
131
|
requirement: &id011 !ruby/object:Gem::Requirement
|
132
132
|
none: false
|
133
133
|
requirements:
|
134
134
|
- - ~>
|
135
135
|
- !ruby/object:Gem::Version
|
136
|
-
version: "
|
136
|
+
version: "2.5"
|
137
137
|
type: :development
|
138
138
|
version_requirements: *id011
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: webmock
|
141
141
|
prerelease: false
|
142
142
|
requirement: &id012 !ruby/object:Gem::Requirement
|
143
143
|
none: false
|
144
144
|
requirements:
|
145
145
|
- - ~>
|
146
146
|
- !ruby/object:Gem::Version
|
147
|
-
version: "
|
147
|
+
version: "1.6"
|
148
148
|
type: :development
|
149
149
|
version_requirements: *id012
|
150
|
+
- !ruby/object:Gem::Dependency
|
151
|
+
name: yard
|
152
|
+
prerelease: false
|
153
|
+
requirement: &id013 !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ~>
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: "0.6"
|
159
|
+
type: :development
|
160
|
+
version_requirements: *id013
|
161
|
+
- !ruby/object:Gem::Dependency
|
162
|
+
name: ZenTest
|
163
|
+
prerelease: false
|
164
|
+
requirement: &id014 !ruby/object:Gem::Requirement
|
165
|
+
none: false
|
166
|
+
requirements:
|
167
|
+
- - ~>
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: "4.5"
|
170
|
+
type: :development
|
171
|
+
version_requirements: *id014
|
150
172
|
description: Enterprise strategies for OmniAuth.
|
151
173
|
email:
|
152
174
|
- james.a.rosen@gmail.com
|
@@ -163,7 +185,6 @@ files:
|
|
163
185
|
- .gemtest
|
164
186
|
- .rspec
|
165
187
|
- .yardopts
|
166
|
-
- Gemfile
|
167
188
|
- LICENSE
|
168
189
|
- README.rdoc
|
169
190
|
- Rakefile
|
@@ -174,6 +195,7 @@ files:
|
|
174
195
|
- lib/omniauth/strategies/cas/service_ticket_validator.rb
|
175
196
|
- lib/omniauth/strategies/ldap.rb
|
176
197
|
- lib/omniauth/strategies/ldap/adaptor.rb
|
198
|
+
- lib/omniauth/version.rb
|
177
199
|
- oa-enterprise.gemspec
|
178
200
|
- spec/fixtures/cas_failure.xml
|
179
201
|
- spec/fixtures/cas_success.xml
|
data/Gemfile
DELETED