ar_openid_store 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Dan Webb
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/NOTICE ADDED
@@ -0,0 +1,212 @@
1
+ This product includes software developed by JanRain,
2
+ available from http://openidenabled.com/
3
+
4
+ The original license in full:
5
+
6
+ The code in lib/hmac/ is Copyright 2001 by Daiki Ueno, and distributed under
7
+ the terms of the Ruby license. See http://www.ruby-lang.org/en/LICENSE.txt
8
+
9
+ The remainder of this package is Copyright 2006-2007 by JanRain, Inc. and
10
+ distributed under the terms of license below:
11
+
12
+ Apache License
13
+ Version 2.0, January 2004
14
+ http://www.apache.org/licenses/
15
+
16
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
17
+
18
+ 1. Definitions.
19
+
20
+ "License" shall mean the terms and conditions for use, reproduction,
21
+ and distribution as defined by Sections 1 through 9 of this document.
22
+
23
+ "Licensor" shall mean the copyright owner or entity authorized by
24
+ the copyright owner that is granting the License.
25
+
26
+ "Legal Entity" shall mean the union of the acting entity and all
27
+ other entities that control, are controlled by, or are under common
28
+ control with that entity. For the purposes of this definition,
29
+ "control" means (i) the power, direct or indirect, to cause the
30
+ direction or management of such entity, whether by contract or
31
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
32
+ outstanding shares, or (iii) beneficial ownership of such entity.
33
+
34
+ "You" (or "Your") shall mean an individual or Legal Entity
35
+ exercising permissions granted by this License.
36
+
37
+ "Source" form shall mean the preferred form for making modifications,
38
+ including but not limited to software source code, documentation
39
+ source, and configuration files.
40
+
41
+ "Object" form shall mean any form resulting from mechanical
42
+ transformation or translation of a Source form, including but
43
+ not limited to compiled object code, generated documentation,
44
+ and conversions to other media types.
45
+
46
+ "Work" shall mean the work of authorship, whether in Source or
47
+ Object form, made available under the License, as indicated by a
48
+ copyright notice that is included in or attached to the work
49
+ (an example is provided in the Appendix below).
50
+
51
+ "Derivative Works" shall mean any work, whether in Source or Object
52
+ form, that is based on (or derived from) the Work and for which the
53
+ editorial revisions, annotations, elaborations, or other modifications
54
+ represent, as a whole, an original work of authorship. For the purposes
55
+ of this License, Derivative Works shall not include works that remain
56
+ separable from, or merely link (or bind by name) to the interfaces of,
57
+ the Work and Derivative Works thereof.
58
+
59
+ "Contribution" shall mean any work of authorship, including
60
+ the original version of the Work and any modifications or additions
61
+ to that Work or Derivative Works thereof, that is intentionally
62
+ submitted to Licensor for inclusion in the Work by the copyright owner
63
+ or by an individual or Legal Entity authorized to submit on behalf of
64
+ the copyright owner. For the purposes of this definition, "submitted"
65
+ means any form of electronic, verbal, or written communication sent
66
+ to the Licensor or its representatives, including but not limited to
67
+ communication on electronic mailing lists, source code control systems,
68
+ and issue tracking systems that are managed by, or on behalf of, the
69
+ Licensor for the purpose of discussing and improving the Work, but
70
+ excluding communication that is conspicuously marked or otherwise
71
+ designated in writing by the copyright owner as "Not a Contribution."
72
+
73
+ "Contributor" shall mean Licensor and any individual or Legal Entity
74
+ on behalf of whom a Contribution has been received by Licensor and
75
+ subsequently incorporated within the Work.
76
+
77
+ 2. Grant of Copyright License. Subject to the terms and conditions of
78
+ this License, each Contributor hereby grants to You a perpetual,
79
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
80
+ copyright license to reproduce, prepare Derivative Works of,
81
+ publicly display, publicly perform, sublicense, and distribute the
82
+ Work and such Derivative Works in Source or Object form.
83
+
84
+ 3. Grant of Patent License. Subject to the terms and conditions of
85
+ this License, each Contributor hereby grants to You a perpetual,
86
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
87
+ (except as stated in this section) patent license to make, have made,
88
+ use, offer to sell, sell, import, and otherwise transfer the Work,
89
+ where such license applies only to those patent claims licensable
90
+ by such Contributor that are necessarily infringed by their
91
+ Contribution(s) alone or by combination of their Contribution(s)
92
+ with the Work to which such Contribution(s) was submitted. If You
93
+ institute patent litigation against any entity (including a
94
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
95
+ or a Contribution incorporated within the Work constitutes direct
96
+ or contributory patent infringement, then any patent licenses
97
+ granted to You under this License for that Work shall terminate
98
+ as of the date such litigation is filed.
99
+
100
+ 4. Redistribution. You may reproduce and distribute copies of the
101
+ Work or Derivative Works thereof in any medium, with or without
102
+ modifications, and in Source or Object form, provided that You
103
+ meet the following conditions:
104
+
105
+ (a) You must give any other recipients of the Work or
106
+ Derivative Works a copy of this License; and
107
+
108
+ (b) You must cause any modified files to carry prominent notices
109
+ stating that You changed the files; and
110
+
111
+ (c) You must retain, in the Source form of any Derivative Works
112
+ that You distribute, all copyright, patent, trademark, and
113
+ attribution notices from the Source form of the Work,
114
+ excluding those notices that do not pertain to any part of
115
+ the Derivative Works; and
116
+
117
+ (d) If the Work includes a "NOTICE" text file as part of its
118
+ distribution, then any Derivative Works that You distribute must
119
+ include a readable copy of the attribution notices contained
120
+ within such NOTICE file, excluding those notices that do not
121
+ pertain to any part of the Derivative Works, in at least one
122
+ of the following places: within a NOTICE text file distributed
123
+ as part of the Derivative Works; within the Source form or
124
+ documentation, if provided along with the Derivative Works; or,
125
+ within a display generated by the Derivative Works, if and
126
+ wherever such third-party notices normally appear. The contents
127
+ of the NOTICE file are for informational purposes only and
128
+ do not modify the License. You may add Your own attribution
129
+ notices within Derivative Works that You distribute, alongside
130
+ or as an addendum to the NOTICE text from the Work, provided
131
+ that such additional attribution notices cannot be construed
132
+ as modifying the License.
133
+
134
+ You may add Your own copyright statement to Your modifications and
135
+ may provide additional or different license terms and conditions
136
+ for use, reproduction, or distribution of Your modifications, or
137
+ for any such Derivative Works as a whole, provided Your use,
138
+ reproduction, and distribution of the Work otherwise complies with
139
+ the conditions stated in this License.
140
+
141
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
142
+ any Contribution intentionally submitted for inclusion in the Work
143
+ by You to the Licensor shall be under the terms and conditions of
144
+ this License, without any additional terms or conditions.
145
+ Notwithstanding the above, nothing herein shall supersede or modify
146
+ the terms of any separate license agreement you may have executed
147
+ with Licensor regarding such Contributions.
148
+
149
+ 6. Trademarks. This License does not grant permission to use the trade
150
+ names, trademarks, service marks, or product names of the Licensor,
151
+ except as required for reasonable and customary use in describing the
152
+ origin of the Work and reproducing the content of the NOTICE file.
153
+
154
+ 7. Disclaimer of Warranty. Unless required by applicable law or
155
+ agreed to in writing, Licensor provides the Work (and each
156
+ Contributor provides its Contributions) on an "AS IS" BASIS,
157
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
158
+ implied, including, without limitation, any warranties or conditions
159
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
160
+ PARTICULAR PURPOSE. You are solely responsible for determining the
161
+ appropriateness of using or redistributing the Work and assume any
162
+ risks associated with Your exercise of permissions under this License.
163
+
164
+ 8. Limitation of Liability. In no event and under no legal theory,
165
+ whether in tort (including negligence), contract, or otherwise,
166
+ unless required by applicable law (such as deliberate and grossly
167
+ negligent acts) or agreed to in writing, shall any Contributor be
168
+ liable to You for damages, including any direct, indirect, special,
169
+ incidental, or consequential damages of any character arising as a
170
+ result of this License or out of the use or inability to use the
171
+ Work (including but not limited to damages for loss of goodwill,
172
+ work stoppage, computer failure or malfunction, or any and all
173
+ other commercial damages or losses), even if such Contributor
174
+ has been advised of the possibility of such damages.
175
+
176
+ 9. Accepting Warranty or Additional Liability. While redistributing
177
+ the Work or Derivative Works thereof, You may choose to offer,
178
+ and charge a fee for, acceptance of support, warranty, indemnity,
179
+ or other liability obligations and/or rights consistent with this
180
+ License. However, in accepting such obligations, You may act only
181
+ on Your own behalf and on Your sole responsibility, not on behalf
182
+ of any other Contributor, and only if You agree to indemnify,
183
+ defend, and hold each Contributor harmless for any liability
184
+ incurred by, or claims asserted against, such Contributor by reason
185
+ of your accepting any such warranty or additional liability.
186
+
187
+ END OF TERMS AND CONDITIONS
188
+
189
+ APPENDIX: How to apply the Apache License to your work.
190
+
191
+ To apply the Apache License to your work, attach the following
192
+ boilerplate notice, with the fields enclosed by brackets "[]"
193
+ replaced with your own identifying information. (Don't include
194
+ the brackets!) The text should be enclosed in the appropriate
195
+ comment syntax for the file format. We also recommend that a
196
+ file or class name and description of purpose be included on the
197
+ same "printed page" as the copyright notice for easier
198
+ identification within third-party archives.
199
+
200
+ Copyright [yyyy] [name of copyright owner]
201
+
202
+ Licensed under the Apache License, Version 2.0 (the "License");
203
+ you may not use this file except in compliance with the License.
204
+ You may obtain a copy of the License at
205
+
206
+ http://www.apache.org/licenses/LICENSE-2.0
207
+
208
+ Unless required by applicable law or agreed to in writing, software
209
+ distributed under the License is distributed on an "AS IS" BASIS,
210
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
211
+ See the License for the specific language governing permissions and
212
+ limitations under the License.
data/README ADDED
@@ -0,0 +1,30 @@
1
+ ar_openid_store
2
+ ===============
3
+
4
+ An ActiveRecord-based OpenID store for the ruby-openid gem. This gem itself is based on the active_record_openid_store included in the examples of the ruby-openid gem by JanRail (see NOTICE). I've just packaged it
5
+ as a gem for convience and use outside of Rails.
6
+
7
+ To install:
8
+
9
+ gem install ar_openid_store
10
+
11
+ To create the tables. Create a migration similar to the following:
12
+
13
+ require 'ar_openid_store/migration'
14
+ class AddOpenidTables < ActiveRecord::Migration
15
+
16
+ def self.up
17
+ create_openid_tables
18
+ end
19
+
20
+ def self.down
21
+ drop_openid_tables
22
+ end
23
+
24
+ end
25
+
26
+ To use with merb_openid:
27
+
28
+ Merb::Config[:merb_openid][:store] = ActiveRecordStore.new
29
+
30
+
@@ -0,0 +1,97 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rake/contrib/rubyforgepublisher'
4
+
5
+ PLUGIN = "ar_openid_store"
6
+ NAME = "ar_openid_store"
7
+ VERSION = "0.0.1"
8
+ AUTHOR = "Dan Webb"
9
+ EMAIL = "dan@danwebb.net"
10
+ HOMEPAGE = "http://merb-plugins.rubyforge.org/ar_openid_store/"
11
+ SUMMARY = "Merb plugin that provides ..."
12
+
13
+ spec = Gem::Specification.new do |s|
14
+ s.name = NAME
15
+ s.version = VERSION
16
+ s.platform = Gem::Platform::RUBY
17
+ s.has_rdoc = true
18
+ s.extra_rdoc_files = ["README", "LICENSE", 'NOTICE']
19
+ s.summary = SUMMARY
20
+ s.description = s.summary
21
+ s.author = AUTHOR
22
+ s.email = EMAIL
23
+ s.homepage = HOMEPAGE
24
+ s.add_dependency('ruby-openid', '>= 2.0.0')
25
+ s.require_path = 'lib'
26
+ s.autorequire = PLUGIN
27
+ s.files = %w(LICENSE README Rakefile NOTICE) + Dir.glob("{lib}/**/*")
28
+ end
29
+
30
+ Rake::GemPackageTask.new(spec) do |pkg|
31
+ pkg.gem_spec = spec
32
+ pkg.need_zip = true
33
+ pkg.need_tar = true
34
+ end
35
+
36
+ task :install => [:package] do
37
+ sh %{sudo gem install pkg/#{NAME}-#{VERSION} --no-update-sources}
38
+ end
39
+
40
+ task :verify_user do
41
+ raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
42
+ end
43
+
44
+ desc "Publish gem+tgz+zip on RubyForge. You must make sure lib/version.rb is aligned with the CHANGELOG file"
45
+ task :publish_packages => [:verify_user, :package] do
46
+ package_name = [spec.name, spec.version].join '-'
47
+
48
+ release_files = FileList[
49
+ "pkg/#{package_name}.gem",
50
+ "pkg/#{package_name}.tgz",
51
+ "pkg/#{package_name}.zip"
52
+ ]
53
+ unless spec.version =~ /RC[0-9]$/
54
+ require 'meta_project'
55
+ require 'rake/contrib/xforge'
56
+
57
+ Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new('merbopenid')) do |xf|
58
+ # Never hardcode user name and password in the Rakefile!
59
+ xf.user_name = ENV['RUBYFORGE_USER']
60
+ xf.files = release_files.to_a
61
+ xf.release_name = "ActiveRecord OpenID Store #{spec.version}"
62
+ xf.release_notes = ''
63
+ xf.release_changes = ''
64
+ end
65
+ else
66
+ puts "SINCE THIS IS A PRERELEASE, FILES ARE UPLOADED WITH SSH, NOT TO THE RUBYFORGE FILE SECTION"
67
+ puts "YOU MUST TYPE THE PASSWORD #{release_files.length} TIMES..."
68
+
69
+ host = "merbopenid-website@rubyforge.org"
70
+ remote_dir = "/var/www/gforge-projects/merbopenid"
71
+
72
+ publisher = Rake::SshFilePublisher.new(
73
+ host,
74
+ remote_dir,
75
+ File.dirname(__FILE__),
76
+ *release_files
77
+ )
78
+ publisher.upload
79
+
80
+ puts "UPLOADED THE FOLLOWING FILES:"
81
+ release_files.each do |file|
82
+ name = file.match(/pkg\/(.*)/)[1]
83
+ puts "* http://merbopenid.rubyforge.org/#{name}"
84
+ end
85
+
86
+ puts "They are not linked to anywhere, so don't forget to tell people!"
87
+ end
88
+ end
89
+
90
+ namespace :jruby do
91
+
92
+ desc "Run :package and install the resulting .gem with jruby"
93
+ task :install => :package do
94
+ sh %{#{SUDO} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
95
+ end
96
+
97
+ end
@@ -0,0 +1,59 @@
1
+ require 'ar_openid_store/association'
2
+ require 'ar_openid_store/nonce'
3
+ require 'openid/store/interface'
4
+
5
+ # not in OpenID module to avoid namespace conflict
6
+ class ActiveRecordStore < OpenID::Store::Interface
7
+ include ArOpenidStore
8
+
9
+ def store_association(server_url, assoc)
10
+ remove_association(server_url, assoc.handle)
11
+ Association.create(:server_url => server_url,
12
+ :handle => assoc.handle,
13
+ :secret => assoc.secret,
14
+ :issued => assoc.issued,
15
+ :lifetime => assoc.lifetime,
16
+ :assoc_type => assoc.assoc_type)
17
+ end
18
+
19
+ def get_association(server_url, handle=nil)
20
+ assocs = if handle.blank?
21
+ Association.find_all_by_server_url(server_url)
22
+ else
23
+ Association.find_all_by_server_url_and_handle(server_url, handle)
24
+ end
25
+
26
+ assocs.reverse.each do |assoc|
27
+ a = assoc.from_record
28
+ if a.expires_in == 0
29
+ assoc.destroy
30
+ else
31
+ return a
32
+ end
33
+ end if assocs.any?
34
+
35
+ return nil
36
+ end
37
+
38
+ def remove_association(server_url, handle)
39
+ Association.delete_all(['server_url = ? AND handle = ?', server_url, handle]) > 0
40
+ end
41
+
42
+ def use_nonce(server_url, timestamp, salt)
43
+ return false if Nonce.find_by_server_url_and_timestamp_and_salt(server_url, timestamp, salt)
44
+ return false if (timestamp - Time.now.to_i).abs > OpenID::Nonce.skew
45
+ Nonce.create(:server_url => server_url, :timestamp => timestamp, :salt => salt)
46
+ return true
47
+ end
48
+
49
+ def cleanup_nonces
50
+ now = Time.now.to_i
51
+ Nonce.delete_all(["timestamp > ? OR timestamp < ?", now + OpenID::Nonce.skew, now - OpenID::Nonce.skew])
52
+ end
53
+
54
+ def cleanup_associations
55
+ now = Time.now.to_i
56
+ Association.delete_all(['issued + lifetime > ?',now])
57
+ end
58
+
59
+ end
@@ -0,0 +1,11 @@
1
+ require 'openid/association'
2
+
3
+ module ArOpenidStore
4
+ class Association < ActiveRecord::Base
5
+ set_table_name 'open_id_associations'
6
+ def from_record
7
+ OpenID::Association.new(handle, secret, issued, lifetime, assoc_type)
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,31 @@
1
+ module ArOpenidStore
2
+
3
+ module Migration
4
+
5
+ def create_openid_tables
6
+ create_table "open_id_associations", :force => true do |t|
7
+ t.column "server_url", :binary
8
+ t.column "handle", :string
9
+ t.column "secret", :binary
10
+ t.column "issued", :integer
11
+ t.column "lifetime", :integer
12
+ t.column "assoc_type", :string
13
+ end
14
+
15
+ create_table "open_id_nonces", :force => true do |t|
16
+ t.column :server_url, :string, :null => false
17
+ t.column :timestamp, :integer, :null => false
18
+ t.column :salt, :string, :null => false
19
+ end
20
+ end
21
+
22
+ def drop_openid_tables
23
+ drop_table "open_id_associations"
24
+ drop_table "open_id_nonces"
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+
31
+ ActiveRecord::Migration.extend ArOpenidStore::Migration
@@ -0,0 +1,5 @@
1
+ module ArOpenidStore
2
+ class Nonce < ActiveRecord::Base
3
+ set_table_name 'open_id_nonces'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ar_openid_store
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dan Webb
8
+ autorequire: ar_openid_store
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-06-30 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: ruby-openid
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.0
24
+ version:
25
+ description: Merb plugin that provides ...
26
+ email: dan@danwebb.net
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README
33
+ - LICENSE
34
+ - NOTICE
35
+ files:
36
+ - LICENSE
37
+ - README
38
+ - Rakefile
39
+ - NOTICE
40
+ - lib/ar_openid_store
41
+ - lib/ar_openid_store/association.rb
42
+ - lib/ar_openid_store/migration.rb
43
+ - lib/ar_openid_store/nonce.rb
44
+ - lib/ar_openid_store.rb
45
+ has_rdoc: true
46
+ homepage: http://merb-plugins.rubyforge.org/ar_openid_store/
47
+ post_install_message:
48
+ rdoc_options: []
49
+
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ requirements: []
65
+
66
+ rubyforge_project:
67
+ rubygems_version: 1.2.0
68
+ signing_key:
69
+ specification_version: 2
70
+ summary: Merb plugin that provides ...
71
+ test_files: []
72
+