Class: OpenID::Store::MongoidStore
- Inherits:
-
Interface
- Object
- Interface
- OpenID::Store::MongoidStore
- Defined in:
- lib/openid/store/mongoid_store.rb
Overview
OpenID Store class which uses Mongoid to store and access Association and Nonce data.
Class Method Summary collapse
-
.cleanup ⇒ Object
Cleans up any expired Nonce and Association data.
Instance Method Summary collapse
-
#get_association(server_url, handle = nil) ⇒ Object
Gets the Association for the given server url and handle.
- #remove_association(server_url, handle) ⇒ Object
-
#store_association(server_url, assoc) ⇒ Object
Stores an Association for the given server url and OpenID::Association.
-
#use_nonce(server_url, timestamp, salt) ⇒ Object
Creates a Nonce for the given information.
Class Method Details
.cleanup ⇒ Object
Note:
Not run as part of the normal process, must be run manually if desired.
Cleans up any expired Nonce and Association data
15 16 17 18 |
# File 'lib/openid/store/mongoid_store.rb', line 15 def self.cleanup cleanup_nonces cleanup_associations end |
Instance Method Details
#get_association(server_url, handle = nil) ⇒ Object
Note:
Called internally by OpenID.
Gets the Association for the given server url and handle.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/openid/store/mongoid_store.rb', line 24 def get_association(server_url, handle = nil) assns = query_associations(server_url, handle) assns.reverse.each do |assn| a = assn.from_record if a.expires_in == 0 assn.destroy else return a end end if assns.any? return nil end |
#remove_association(server_url, handle) ⇒ Object
65 66 67 68 69 |
# File 'lib/openid/store/mongoid_store.rb', line 65 def remove_association(server_url, handle) Association.where(:server_url => server_url, :handle => handle).each do |assoc| assoc.destroy end end |
#store_association(server_url, assoc) ⇒ Object
Note:
Called internally by OpenID.
Stores an Association for the given server url and OpenID::Association.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/openid/store/mongoid_store.rb', line 43 def store_association(server_url, assoc) remove_association(server_url, assoc.handle) Association.create(:server_url => server_url, :handle => assoc.handle, :secret => Moped::BSON::Binary.new(:generic, assoc.secret), :issued => assoc.issued.to_i, :lifetime => assoc.lifetime, :assoc_type => assoc.assoc_type) end |
#use_nonce(server_url, timestamp, salt) ⇒ Object
Creates a Nonce for the given information.
59 60 61 62 63 |
# File 'lib/openid/store/mongoid_store.rb', line 59 def use_nonce(server_url, , salt) return false if any_nonces?(server_url, , salt) || delta_beyond_skew?() Nonce.create(:server_url => server_url, :timestamp => , :salt => salt) return true end |