rack_my_openid 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/lib/rack_my_openid.rb +4 -0
- data/lib/rack_my_openid/backported_rack_digest_fix.rb +19 -0
- data/lib/rack_my_openid/handler.rb +4 -4
- data/lib/rack_my_openid/provider.rb +4 -3
- data/lib/rack_my_openid/version.rb +1 -1
- data/rack_my_openid.gemspec +2 -0
- data/spec/handler_spec.rb +3 -3
- metadata +40 -10
data/CHANGELOG
ADDED
data/lib/rack_my_openid.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rack/auth/digest/request'
|
2
|
+
|
3
|
+
module RackMyOpenid
|
4
|
+
module BackportedRackDigestFix
|
5
|
+
def self.included(klass)
|
6
|
+
klass.class_eval do
|
7
|
+
def request
|
8
|
+
@request ||= Rack::Request.new(@env)
|
9
|
+
end
|
10
|
+
|
11
|
+
def correct_uri?
|
12
|
+
request.fullpath == uri
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Rack::Auth::Digest::Request.send(:include, RackMyOpenid::BackportedRackDigestFix)
|
@@ -33,11 +33,11 @@ module RackMyOpenid
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def openid_server
|
36
|
-
@openid_server ||= OpenID::Server::Server.new(@options[:endpoint_url]
|
36
|
+
@openid_server ||= OpenID::Server::Server.new(openid_store, @options[:endpoint_url])
|
37
37
|
end
|
38
38
|
|
39
39
|
def openid_store
|
40
|
-
@openid_store ||= OpenID::Store::Memory
|
40
|
+
@openid_store ||= OpenID::Store::Memory.new
|
41
41
|
end
|
42
42
|
|
43
43
|
# Handle a valid OpenID request
|
@@ -57,10 +57,10 @@ module RackMyOpenid
|
|
57
57
|
def handle_check_id_request(request, session)
|
58
58
|
if request_provided_invalid_openid?(request)
|
59
59
|
return request.answer(false)
|
60
|
-
elsif trusted_realm?(request.
|
60
|
+
elsif trusted_realm?(request.trust_root, session)
|
61
61
|
return request.answer(true, nil, @options[:openid])
|
62
62
|
else
|
63
|
-
raise UntrustedRealm.new(request.
|
63
|
+
raise UntrustedRealm.new(request.trust_root)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -43,9 +43,10 @@ module RackMyOpenid
|
|
43
43
|
status 400
|
44
44
|
body 'Bad Request'
|
45
45
|
rescue RackMyOpenid::Handler::UntrustedRealm => e
|
46
|
-
|
46
|
+
params_without_default_proc = {}.merge params
|
47
|
+
session[:openid_request_params] = params_without_default_proc
|
47
48
|
session[:realm] = e.realm
|
48
|
-
redirect
|
49
|
+
redirect '/openid/decide', 302
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
@@ -55,7 +56,7 @@ module RackMyOpenid
|
|
55
56
|
if @realm = session[:realm]
|
56
57
|
erb :decide
|
57
58
|
else
|
58
|
-
redirect
|
59
|
+
redirect '/openid', 302
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
data/rack_my_openid.gemspec
CHANGED
@@ -18,9 +18,11 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
+
s.add_runtime_dependency 'rack', '>=1.2'
|
21
22
|
s.add_runtime_dependency 'sinatra'
|
22
23
|
s.add_runtime_dependency 'ruby-openid'
|
23
24
|
|
25
|
+
s.add_development_dependency 'rake'
|
24
26
|
s.add_development_dependency 'rspec'
|
25
27
|
s.add_development_dependency 'capybara'
|
26
28
|
end
|
data/spec/handler_spec.rb
CHANGED
@@ -2,14 +2,14 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
shared_examples_for 'a valid request' do
|
4
4
|
context 'when realm is trusted via options' do
|
5
|
-
let(:options_with_realm) { options.merge({:trusted_realms => [request.
|
5
|
+
let(:options_with_realm) { options.merge({:trusted_realms => [request.trust_root]}) }
|
6
6
|
it 'should answer true' do
|
7
7
|
described_class.new(options_with_realm).handle(params, session).should == 'answered true'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
context 'when realm is trusted via session' do
|
12
|
-
let(:session) { {:trusted_realms => [request.
|
12
|
+
let(:session) { {:trusted_realms => [request.trust_root] } }
|
13
13
|
it 'should answer true' do
|
14
14
|
described_class.new(options).handle(params, session).should == 'answered true'
|
15
15
|
end
|
@@ -64,7 +64,7 @@ describe RackMyOpenid::Handler do
|
|
64
64
|
let(:params) { {:mode => 'check_id'} }
|
65
65
|
let(:request) {
|
66
66
|
request = OpenID::Server::CheckIDRequest.new(nil, nil, nil)
|
67
|
-
request.stub(:
|
67
|
+
request.stub(:trust_root) { 'http://my.realm' }
|
68
68
|
request.stub(:answer).with(true, nil, options[:openid]) { 'answered true' }
|
69
69
|
request.stub(:answer).with(false) { 'answered false' }
|
70
70
|
request
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack_my_openid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rack
|
16
|
+
requirement: &70185625770120 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70185625770120
|
14
25
|
- !ruby/object:Gem::Dependency
|
15
26
|
name: sinatra
|
16
|
-
requirement: &
|
27
|
+
requirement: &70185625785420 !ruby/object:Gem::Requirement
|
17
28
|
none: false
|
18
29
|
requirements:
|
19
30
|
- - ! '>='
|
@@ -21,10 +32,10 @@ dependencies:
|
|
21
32
|
version: '0'
|
22
33
|
type: :runtime
|
23
34
|
prerelease: false
|
24
|
-
version_requirements: *
|
35
|
+
version_requirements: *70185625785420
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: ruby-openid
|
27
|
-
requirement: &
|
38
|
+
requirement: &70185625783160 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ! '>='
|
@@ -32,10 +43,21 @@ dependencies:
|
|
32
43
|
version: '0'
|
33
44
|
type: :runtime
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *70185625783160
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: &70185625780400 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70185625780400
|
36
58
|
- !ruby/object:Gem::Dependency
|
37
59
|
name: rspec
|
38
|
-
requirement: &
|
60
|
+
requirement: &70185625779160 !ruby/object:Gem::Requirement
|
39
61
|
none: false
|
40
62
|
requirements:
|
41
63
|
- - ! '>='
|
@@ -43,10 +65,10 @@ dependencies:
|
|
43
65
|
version: '0'
|
44
66
|
type: :development
|
45
67
|
prerelease: false
|
46
|
-
version_requirements: *
|
68
|
+
version_requirements: *70185625779160
|
47
69
|
- !ruby/object:Gem::Dependency
|
48
70
|
name: capybara
|
49
|
-
requirement: &
|
71
|
+
requirement: &70185625777680 !ruby/object:Gem::Requirement
|
50
72
|
none: false
|
51
73
|
requirements:
|
52
74
|
- - ! '>='
|
@@ -54,7 +76,7 @@ dependencies:
|
|
54
76
|
version: '0'
|
55
77
|
type: :development
|
56
78
|
prerelease: false
|
57
|
-
version_requirements: *
|
79
|
+
version_requirements: *70185625777680
|
58
80
|
description: Would be useful to enable OpenID authorisation with your Ruby/Rails-based
|
59
81
|
blog, personal website or whatever.
|
60
82
|
email:
|
@@ -65,10 +87,12 @@ extra_rdoc_files: []
|
|
65
87
|
files:
|
66
88
|
- .gitignore
|
67
89
|
- .rvmrc
|
90
|
+
- CHANGELOG
|
68
91
|
- Gemfile
|
69
92
|
- README.md
|
70
93
|
- Rakefile
|
71
94
|
- lib/rack_my_openid.rb
|
95
|
+
- lib/rack_my_openid/backported_rack_digest_fix.rb
|
72
96
|
- lib/rack_my_openid/handler.rb
|
73
97
|
- lib/rack_my_openid/provider.rb
|
74
98
|
- lib/rack_my_openid/version.rb
|
@@ -95,12 +119,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
119
|
- - ! '>='
|
96
120
|
- !ruby/object:Gem::Version
|
97
121
|
version: '0'
|
122
|
+
segments:
|
123
|
+
- 0
|
124
|
+
hash: 1985348002294510017
|
98
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
126
|
none: false
|
100
127
|
requirements:
|
101
128
|
- - ! '>='
|
102
129
|
- !ruby/object:Gem::Version
|
103
130
|
version: '0'
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
hash: 1985348002294510017
|
104
134
|
requirements: []
|
105
135
|
rubyforge_project: rack_my_openid
|
106
136
|
rubygems_version: 1.8.11
|