openid-store-mongoid 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
3
  ruby '1.9.3'
4
4
 
@@ -6,8 +6,9 @@ gem 'mongoid', '~>3.1'
6
6
  gem 'ruby-openid', '~>2.2.3'
7
7
 
8
8
  group :development, :test do
9
- gem "rspec", "~> 2.8"
10
- gem "rdoc", "~> 3.12"
11
- gem "bundler", "~> 1.0"
12
- gem "jeweler", "~> 1.8.4"
9
+ gem 'rspec', '~> 2.8'
10
+ gem 'yard', '~> 0.8'
11
+ gem 'redcarpet', '~> 2.2'
12
+ gem 'bundler', '~> 1.0'
13
+ gem 'jeweler', '~> 1.8.4'
13
14
  end
data/Gemfile.lock CHANGED
@@ -28,6 +28,7 @@ GEM
28
28
  rake (10.0.3)
29
29
  rdoc (3.12.1)
30
30
  json (~> 1.4)
31
+ redcarpet (2.2.2)
31
32
  rspec (2.12.0)
32
33
  rspec-core (~> 2.12.0)
33
34
  rspec-expectations (~> 2.12.0)
@@ -38,6 +39,7 @@ GEM
38
39
  rspec-mocks (2.12.2)
39
40
  ruby-openid (2.2.3)
40
41
  tzinfo (0.3.35)
42
+ yard (0.8.4.1)
41
43
 
42
44
  PLATFORMS
43
45
  ruby
@@ -46,6 +48,7 @@ DEPENDENCIES
46
48
  bundler (~> 1.0)
47
49
  jeweler (~> 1.8.4)
48
50
  mongoid (~> 3.1)
49
- rdoc (~> 3.12)
51
+ redcarpet (~> 2.2)
50
52
  rspec (~> 2.8)
51
53
  ruby-openid (~> 2.2.3)
54
+ yard (~> 0.8)
data/Rakefile CHANGED
@@ -35,12 +35,5 @@ task :default => :spec
35
35
 
36
36
  task :test => :spec
37
37
 
38
- require 'rdoc/task'
39
- Rake::RDocTask.new do |rdoc|
40
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
-
42
- rdoc.rdoc_dir = 'rdoc'
43
- rdoc.title = "temp #{version}"
44
- rdoc.rdoc_files.include('README*')
45
- rdoc.rdoc_files.include('lib/**/*.rb')
46
- end
38
+ require 'yard'
39
+ YARD::Rake::YardocTask.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -2,10 +2,13 @@ require 'mongoid'
2
2
  require 'openid/association'
3
3
 
4
4
  module OpenID::Store
5
+ # Wrapper class for an OpenID::Association object.
5
6
  class Association
6
7
  include Mongoid::Document
7
8
  field :secret, :type => Moped::BSON::Binary
8
9
 
10
+ # Create an OpenID::Association object from this object.
11
+ # @return [OpenID::Association] Child object created from this document.
9
12
  def from_record
10
13
  OpenID::Association.new(handle, secret.to_s, Time.at(issued), lifetime, assoc_type)
11
14
  end
@@ -2,6 +2,7 @@ require 'mongoid'
2
2
  require 'openid'
3
3
 
4
4
  module OpenID::Store
5
+ # Wrapper class for an OpenID::Nonce object.
5
6
  class Nonce
6
7
  include Mongoid::Document
7
8
  end
@@ -5,13 +5,22 @@ require 'moped/bson/binary'
5
5
  require 'openid/store/models/nonce'
6
6
  require 'openid/store/models/association'
7
7
 
8
+ # Module OpenID::Store is used for all OpenID Store types. Also helps distinguishes
9
+ # the Association/Nonce wrappers from OpenID::Association and OpenID::Nonce.
8
10
  module OpenID::Store
11
+ # OpenID Store class which uses Mongoid to store and access Association and Nonce data.
9
12
  class MongoidStore < OpenID::Store::Interface
13
+ # Cleans up any expired Nonce and Association data
14
+ # @note Not run as part of the normal process, must be run manually if desired.
10
15
  def self.cleanup
11
16
  cleanup_nonces
12
17
  cleanup_associations
13
18
  end
14
19
 
20
+ # Gets the Association for the given server url and handle.
21
+ # @param [String] server_url URL of the server making the request
22
+ # @param handle The handle associated with the Association
23
+ # @note Called internally by OpenID.
15
24
  def get_association(server_url, handle = nil)
16
25
  assns = query_associations(server_url, handle)
17
26
 
@@ -27,11 +36,13 @@ module OpenID::Store
27
36
  return nil
28
37
  end
29
38
 
39
+ # Stores an Association for the given server url and OpenID::Association.
40
+ # @param [String] server_url URL of the server making the request
41
+ # @param [OpenID::Association] assoc Object to use to create Association
42
+ # @note Called internally by OpenID.
30
43
  def store_association(server_url, assoc)
31
44
  remove_association(server_url, assoc.handle)
32
45
 
33
- # BSON::Binary is used because secrets raise an exception
34
- # due to character encoding
35
46
  Association.create(:server_url => server_url,
36
47
  :handle => assoc.handle,
37
48
  :secret => Moped::BSON::Binary.new(:generic, assoc.secret),
@@ -40,6 +51,11 @@ module OpenID::Store
40
51
  :assoc_type => assoc.assoc_type)
41
52
  end
42
53
 
54
+ # Creates a Nonce for the given information.
55
+ # @param [String] server_url URL of the server making the request
56
+ # @param timestamp Time the Nonce was created.
57
+ # @param [String] salt Random string to uniquify Nonces.
58
+ # @return True if the given nonce has not been created before and the timestamp is valid, False otherwise.
43
59
  def use_nonce(server_url, timestamp, salt)
44
60
  return false if any_nonces?(server_url, timestamp, salt) || delta_beyond_skew?(timestamp)
45
61
  Nonce.create(:server_url => server_url, :timestamp => timestamp, :salt => salt)
@@ -76,7 +92,7 @@ module OpenID::Store
76
92
  end
77
93
 
78
94
  def self.cleanup_associations
79
- Association.for_js("(this.issued + this.lifetime) > ti", ti: Time.now.to_i).delete
95
+ Association.for_js("(this.issued + this.lifetime) < ti", ti: Time.now.to_i).delete
80
96
  end
81
97
  end
82
98
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "openid-store-mongoid"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Larry Price"]
12
- s.date = "2013-02-23"
12
+ s.date = "2013-02-27"
13
13
  s.description = "Use a Mongoid database to store OpenID consumer data."
14
14
  s.email = "larry.price.dev@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -46,14 +46,16 @@ Gem::Specification.new do |s|
46
46
  s.add_runtime_dependency(%q<mongoid>, ["~> 3.1"])
47
47
  s.add_runtime_dependency(%q<ruby-openid>, ["~> 2.2.3"])
48
48
  s.add_development_dependency(%q<rspec>, ["~> 2.8"])
49
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
49
+ s.add_development_dependency(%q<yard>, ["~> 0.8"])
50
+ s.add_development_dependency(%q<redcarpet>, ["~> 2.2"])
50
51
  s.add_development_dependency(%q<bundler>, ["~> 1.0"])
51
52
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
52
53
  else
53
54
  s.add_dependency(%q<mongoid>, ["~> 3.1"])
54
55
  s.add_dependency(%q<ruby-openid>, ["~> 2.2.3"])
55
56
  s.add_dependency(%q<rspec>, ["~> 2.8"])
56
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
57
+ s.add_dependency(%q<yard>, ["~> 0.8"])
58
+ s.add_dependency(%q<redcarpet>, ["~> 2.2"])
57
59
  s.add_dependency(%q<bundler>, ["~> 1.0"])
58
60
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
59
61
  end
@@ -61,7 +63,8 @@ Gem::Specification.new do |s|
61
63
  s.add_dependency(%q<mongoid>, ["~> 3.1"])
62
64
  s.add_dependency(%q<ruby-openid>, ["~> 2.2.3"])
63
65
  s.add_dependency(%q<rspec>, ["~> 2.8"])
64
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
66
+ s.add_dependency(%q<yard>, ["~> 0.8"])
67
+ s.add_dependency(%q<redcarpet>, ["~> 2.2"])
65
68
  s.add_dependency(%q<bundler>, ["~> 1.0"])
66
69
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
67
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openid-store-mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-23 00:00:00.000000000 Z
12
+ date: 2013-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongoid
@@ -60,13 +60,13 @@ dependencies:
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2.8'
62
62
  - !ruby/object:Gem::Dependency
63
- name: rdoc
63
+ name: yard
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: '3.12'
69
+ version: '0.8'
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,23 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: '3.12'
77
+ version: '0.8'
78
+ - !ruby/object:Gem::Dependency
79
+ name: redcarpet
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '2.2'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '2.2'
78
94
  - !ruby/object:Gem::Dependency
79
95
  name: bundler
80
96
  requirement: !ruby/object:Gem::Requirement
@@ -145,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
161
  version: '0'
146
162
  segments:
147
163
  - 0
148
- hash: -2320968285031314853
164
+ hash: -1746080449216916929
149
165
  required_rubygems_version: !ruby/object:Gem::Requirement
150
166
  none: false
151
167
  requirements: