ruby-openid 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ruby-openid might be problematic. Click here for more details.

Files changed (41) hide show
  1. data/examples/rails_openid_login_generator/openid_login_generator-0.1.gem +0 -0
  2. data/examples/rails_openid_login_generator/templates/controller.rb~ +111 -0
  3. data/lib/openid/consumer.rb +21 -9
  4. data/lib/openid/server.rb +2 -1
  5. data/test/runtests.rb~ +21 -0
  6. metadata +44 -92
  7. data/examples/cacert.pem +0 -7815
  8. data/examples/consumerd.rb +0 -290
  9. data/examples/openid-store/associations/http-localhost_3A3000_2Fserver-LQl7HUNueJIJcpPoAGiHEHNdJMc +0 -6
  10. data/examples/openid-store/associations/http-www.myopenid.com_2Fserver-ZFp96P4qV1FjqgGt2rtZBvRJWic +0 -6
  11. data/examples/openid-store/auth_key +0 -1
  12. data/examples/openid-store/nonces/PNiw86rQ +0 -0
  13. data/examples/openid-store/nonces/hdZo7WC9 +0 -0
  14. data/examples/openid-store/nonces/uHhMdi1i +0 -0
  15. data/examples/rails_server/app/controllers/login_controller.rb~ +0 -35
  16. data/examples/rails_server/app/controllers/server_controller.rb~ +0 -190
  17. data/examples/rails_server/db/openid-store/associations/http-localhost_2F_7Cnormal-YU.tkND1J4fEZhnuAoT5Zc0yCA0 +0 -6
  18. data/examples/rails_server/db/openid-store/associations/http-localhost_2F_7Cnormal-jRS20gc5OzJ5pkpjy9BjqvTj3B0 +0 -6
  19. data/examples/rails_server/log/development.log +0 -6459
  20. data/examples/rails_server/log/production.log +0 -0
  21. data/examples/rails_server/log/server.log +0 -0
  22. data/examples/rails_server/log/test.log +0 -0
  23. data/examples/rails_server/tmp/sessions/ruby_sess.1b2e9635e0f69c0d +0 -0
  24. data/examples/rails_server/tmp/sessions/ruby_sess.1b3584d2b3784c97 +0 -0
  25. data/examples/rails_server/tmp/sessions/ruby_sess.20ed70e0e63d7e31 +0 -0
  26. data/examples/rails_server/tmp/sessions/ruby_sess.30cf5b98539677d5 +0 -0
  27. data/examples/rails_server/tmp/sessions/ruby_sess.3910508c0c857695 +0 -0
  28. data/examples/rails_server/tmp/sessions/ruby_sess.472170ef38098672 +0 -0
  29. data/examples/rails_server/tmp/sessions/ruby_sess.5406e21ba5b1c7bb +0 -0
  30. data/examples/rails_server/tmp/sessions/ruby_sess.5d2bd2b7086f12d5 +0 -0
  31. data/examples/rails_server/tmp/sessions/ruby_sess.968757c6d12af322 +0 -0
  32. data/examples/rails_server/tmp/sessions/ruby_sess.a87a5045744b3abf +0 -0
  33. data/examples/rails_server/tmp/sessions/ruby_sess.ca9f0a416be0be57 +0 -0
  34. data/examples/rails_server/tmp/sessions/ruby_sess.cd269e6040645b5b +0 -0
  35. data/examples/rails_server/tmp/sessions/ruby_sess.cf2acf62b93dbc88 +0 -0
  36. data/examples/rails_server/tmp/sessions/ruby_sess.d2ef8fe29591ef9b +0 -0
  37. data/examples/rails_server/tmp/sessions/ruby_sess.e23240e097e2c83d +0 -0
  38. data/examples/rails_server/tmp/sessions/ruby_sess.fb154d2f7c286aba +0 -0
  39. data/lib/openid/discovery.rb~ +0 -122
  40. data/lib/openid/stores.rb~ +0 -178
  41. data/test/teststore.rb~ +0 -47
File without changes
File without changes
File without changes
@@ -1,122 +0,0 @@
1
- require "openid/util"
2
- require "openid/service"
3
- require "openid/parse"
4
-
5
- # try and use the yadis gem, falling back to system yadis
6
- begin
7
- require 'rubygems'
8
- require_gem 'ruby-yadis', ">=0.4"
9
- rescue LoadError
10
- require "yadis"
11
- end
12
-
13
- module OpenID
14
-
15
- OPENID_IDP_2_0_TYPE = 'http://openid.net/server/2.0'
16
- OPENID_2_0_TYPE = 'http://openid.net/signon/2.0'
17
- OPENID_1_2_TYPE = 'http://openid.net/signon/1.2'
18
- OPENID_1_1_TYPE = 'http://openid.net/signon/1.1'
19
- OPENID_1_0_TYPE = 'http://openid.net/signon/1.0'
20
- OPENID_TYPE_URIS = [OPENID_2_0_TYPE,OPENID_1_2_TYPE,
21
- OPENID_1_1_TYPE,OPENID_1_0_TYPE]
22
-
23
- # OpenID::Discovery encapsulates the logic for doing Yadis and OpenID 1.0
24
- # style server discovery. This class uses a session object to manage
25
- # a list of tried OpenID servers for implemeting server fallback. This is
26
- # useful the case when a user's primary server(s) is not available, and
27
- # will allow then to try again with one of their alternates.
28
- class OpenIDDiscovery < Discovery
29
-
30
- def initialize(session, url, fetcher, suffix=nil)
31
- super(session, url, suffix)
32
- @fetcher = fetcher
33
- end
34
-
35
- # Pass in a custom filter here if you like. Otherwise you'll get all
36
- # OpenID sso services. filter should produce objects or subclasses of
37
- # OpenIDServiceEndpoint.
38
- def discover(filter=nil)
39
- unless filter
40
- filter = lambda {|s| OpenIDServiceEndpoint.from_endpoint(s)}
41
- end
42
-
43
- begin
44
- # do yadis discover, filtering out OpenID services
45
- return super(filter)
46
- rescue YADISParseError, YADISHTTPError
47
-
48
- # Couldn't do Yadis discovery, fall back on OpenID 1.0 disco
49
- status, service = self.openid_discovery(@url)
50
- if status == SUCCESS
51
- return [service.consumer_id, [service]]
52
- end
53
- end
54
-
55
- return [nil, []]
56
- end
57
-
58
- # Perform OpenID 1.0 style link rel discovery. No string normalization
59
- # will be done on +url+. See Util.normalize_url for information on
60
- # textual URL transformations.
61
- def openid_discovery(url)
62
- ret = @fetcher.get(url)
63
- return [HTTP_FAILURE, nil] if ret.nil?
64
-
65
- consumer_id, data = ret
66
- server = nil
67
- delegate = nil
68
- parse_link_attrs(data) do |attrs|
69
- rel = attrs["rel"]
70
- if rel == "openid.server" and server.nil?
71
- href = attrs["href"]
72
- server = href unless href.nil?
73
- end
74
-
75
- if rel == "openid.delegate" and delegate.nil?
76
- href = attrs["href"]
77
- delegate = href unless href.nil?
78
- end
79
- end
80
-
81
- return [PARSE_ERROR, nil] if server.nil?
82
-
83
- server_id = delegate.nil? ? consumer_id : delegate
84
-
85
- consumer_id = OpenID::Util.normalize_url(consumer_id)
86
- server_id = OpenID::Util.normalize_url(server_id)
87
- server_url = OpenID::Util.normalize_url(server)
88
-
89
- service = OpenID::FakeOpenIDServiceEndpoint.new(consumer_id,
90
- server_id,
91
- server_url)
92
- return [SUCCESS, service]
93
- end
94
-
95
- end
96
-
97
- class XRIDiscovery < Discovery
98
- def initialize(session, iname, suffix=nil)
99
- super(session, iname, suffix)
100
- end
101
-
102
- def discover(filter=nil)
103
- begin
104
- services = XRI::ProxyResolver.new.query(@url, OPENID_TYPE_URIS)
105
- rescue XRI::XRIHTTPError, ArgumentError
106
- return [nil, []]
107
- end
108
- endpoints = []
109
- services.each {|s|
110
- se = OpenIDServiceEndpoint.from_endpoint(s)
111
- if se
112
- se.delegate_url = @url
113
- se.yadis_url = @url
114
- endpoints << se
115
- end
116
- }
117
- return [@url, endpoints]
118
- end
119
-
120
- end
121
-
122
- end
@@ -1,178 +0,0 @@
1
- require "openid/util"
2
-
3
- module OpenID
4
-
5
- # Interface for the abstract Store
6
- class Store
7
-
8
- @@AUTH_KEY_LEN = 20
9
-
10
- # Put a Association object into storace
11
- def store_association(association)
12
- raise NotImplementedError
13
- end
14
-
15
- # Returns a Association object from storage that matches
16
- # the server_url. Returns nil if no such association is found or if
17
- # the one matching association is expired. (Is allowed to GC expired
18
- # associations when found.)
19
- def get_association(server_url)
20
- raise NotImplementedError
21
- end
22
-
23
- # If there is a matching association, remove it from the store and
24
- # return true, otherwise return false.
25
- def removeAssociation(server_url, handle)
26
- raise NotImplementedError
27
- end
28
-
29
- # Stores a nonce (which is passed in as a string).
30
- def store_nonce(nonce)
31
- raise NotImplementedError
32
- end
33
-
34
- # If the nonce is in the store, remove it and return true. Otherwise
35
- # return false.
36
- def use_nonce(nonce)
37
- raise NotImplementedError
38
- end
39
-
40
- # Returns a 20-byte auth key used to sign the tokens, to ensure
41
- # that they haven't been tampered with in transit. It must return
42
- # the same key every time it is called.
43
- def get_auth_key
44
- raise NotImplementedError
45
- end
46
-
47
- # Method return true if the store is dumb-mode-style store.
48
- def dumb?
49
- false
50
- end
51
-
52
- end
53
-
54
-
55
- class DumbStore < Store
56
-
57
- def initialize(secret_phrase)
58
- require "digest/sha1"
59
- @auth_key = Digest::SHA1.hexdigest(secret_phrase)
60
- end
61
-
62
- def store_association(assoc)
63
- nil
64
- end
65
-
66
- def get_association(server_url)
67
- nil
68
- end
69
-
70
- def remove_association(server_url, handle)
71
- false
72
- end
73
-
74
- def store_nonce(nonce)
75
- nil
76
- end
77
-
78
- def use_nonce(nonce)
79
- true
80
- end
81
-
82
- def get_auth_key
83
- @auth_key
84
- end
85
-
86
- def dumb?
87
- true
88
- end
89
-
90
- end
91
-
92
- class ServerAssocs
93
- def initialize
94
- @assocs = {}
95
- end
96
-
97
- def set(assoc)
98
- @assocs[assoc.handle] = assoc
99
- end
100
-
101
- def get(handle)
102
- @assocs[handle]
103
- end
104
-
105
- def remove(handle)
106
- return @assocs.delete(handle)
107
- end
108
-
109
- def best
110
- best = nil
111
- @assocs.each do |k, assoc|
112
- if best.nil? or best.issued < assoc.issued
113
- best = assoc
114
- end
115
- end
116
- return best
117
- end
118
- end
119
-
120
- # An in-memory implementation of Store. This class is mainly used
121
- # for testing, though it may be useful for long-running single process apps.
122
- #
123
- # You should probably be looking at OpenID::FilesystemStore
124
- class MemoryStore < Store
125
-
126
- def initialize
127
- @server_assocs = {}
128
- @nonces = {}
129
- @auth_key = OpenID::Util.random_string(@@AUTH_KEY_LEN)
130
- end
131
-
132
- def dumb?
133
- false
134
- end
135
-
136
- def store_association(server_url, assoc)
137
- assocs = _get_server_assocs(server_url)
138
- assocs.set(self.deepcopy(assoc))
139
- end
140
-
141
- def get_association(server_url, handle=nil)
142
- assocs = _get_server_assocs(server_url)
143
- return assocs.best if handle.nil?
144
- return assocs.get(handle)
145
- end
146
-
147
- def remove_association(server_url, handle)
148
- assocs = _get_server_assocs(server_url)
149
- return assocs.remove(handle)
150
- end
151
-
152
- def use_nonce(nonce)
153
- return true if @nonces.delete(nonce)
154
- return false
155
- end
156
-
157
- def store_nonce(nonce)
158
- @nonces[nonce] = true
159
- end
160
-
161
- def get_auth_key
162
- @auth_key
163
- end
164
-
165
- def _get_server_assocs(server_url)
166
- unless @server_assocs.has_key?(server_url)
167
- @server_assocs[server_url] = ServerAssocs.new
168
- end
169
- return @server_assocs[server_url]
170
- end
171
-
172
- def deepcopy(o)
173
- Marshal.load(Marshal.dump(o))
174
- end
175
-
176
- end
177
-
178
- end
data/test/teststore.rb~ DELETED
@@ -1,47 +0,0 @@
1
- require 'test/unit'
2
- require 'fileutils'
3
- require 'pathname'
4
- require 'tmpdir'
5
-
6
- require 'openid/filestore'
7
- require 'storetestcase'
8
-
9
- class FileStoreTestCase < Test::Unit::TestCase
10
- include StoreTestCase
11
-
12
- @@dir = Pathname.new(Dir.tmpdir).join('filstoretest')
13
-
14
- def setup
15
- FileUtils.rm_rf(@@dir)
16
- @store = OpenID::FilesystemStore.new(@@dir)
17
- end
18
-
19
- def teardown
20
- FileUtils.rm_rf(@@dir)
21
- end
22
- end
23
-
24
- class DumbStoreTestCase < Test::Unit::TestCase
25
- include StoreTestCase
26
-
27
- def setup
28
- @store = OpenID::DumbStore.new('unit-test')
29
- end
30
-
31
- def test_nonce
32
- assert_equal(true, @store.use_none('anything'))
33
- end
34
-
35
- end
36
-
37
- class MemoryStoreTestCase < Test::Unit::TestCase
38
- include StoreTestCase
39
-
40
- @@dir = Pathname.new(Dir.tmpdir).join('filstoretest')
41
-
42
- def setup
43
- @store = OpenID::MemoryStore.new
44
- end
45
-
46
- end
47
-