Skip to content

Commit 81cac38

Browse files
authored
Merge pull request #19 from DianthuDia/rack/open_id/more_build_header
Support another build header of Rack/openid
2 parents 0cc5557 + 6d98a73 commit 81cac38

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/omniauth/strategies/open_id.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,27 @@ class OpenID
2424
option :name, :open_id
2525
option :required, [AX[:email], AX[:name], AX[:first_name], AX[:last_name], 'email', 'fullname']
2626
option :optional, [AX[:nickname], AX[:city], AX[:state], AX[:website], AX[:image], 'postcode', 'nickname']
27+
option :immediate, false
28+
option :trust_root, proc{|root_uri| nil }
2729
option :store, ::OpenID::Store::Memory.new
2830
option :identifier, nil
2931
option :identifier_param, 'openid_url'
3032
option :trust_root, nil
3133

3234
def dummy_app
33-
lambda{|env| [401, {"WWW-Authenticate" => Rack::OpenID.build_header(
35+
lambda{|env|
36+
req = Rack::Request.new(env)
37+
root_uri = "#{req.scheme}://#{req.host_with_port}/"
38+
39+
[401, {"WWW-Authenticate" => Rack::OpenID.build_header(
3440
:identifier => identifier,
3541
:return_to => callback_url,
3642
:trust_root => options.trust_root || %r{^(https?://[^/]+)}.match(callback_url) {|m| m[1]},
3743
:required => options.required,
3844
:optional => options.optional,
39-
:method => 'post'
45+
:method => 'post',
46+
:immediate => options.immediate,
47+
:trust_root => options.trust_root.call(root_uri)
4048
)}, []]}
4149
end
4250

0 commit comments

Comments
 (0)
close