nov-ruby-openid 2.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +215 -0
- data/CHANGES-2.1.0 +36 -0
- data/INSTALL +47 -0
- data/LICENSE +210 -0
- data/NOTICE +2 -0
- data/README +81 -0
- data/Rakefile +98 -0
- data/UPGRADE +127 -0
- data/VERSION +1 -0
- data/contrib/google/ruby-openid-apps-discovery-1.0.gem +0 -0
- data/contrib/google/ruby-openid-apps-discovery-1.01.gem +0 -0
- data/examples/README +32 -0
- data/examples/active_record_openid_store/README +58 -0
- data/examples/active_record_openid_store/XXX_add_open_id_store_to_db.rb +24 -0
- data/examples/active_record_openid_store/XXX_upgrade_open_id_store.rb +26 -0
- data/examples/active_record_openid_store/init.rb +8 -0
- data/examples/active_record_openid_store/lib/association.rb +10 -0
- data/examples/active_record_openid_store/lib/nonce.rb +3 -0
- data/examples/active_record_openid_store/lib/open_id_setting.rb +4 -0
- data/examples/active_record_openid_store/lib/openid_ar_store.rb +57 -0
- data/examples/active_record_openid_store/test/store_test.rb +212 -0
- data/examples/discover +49 -0
- data/examples/rails_openid/README +153 -0
- data/examples/rails_openid/Rakefile +10 -0
- data/examples/rails_openid/app/controllers/application.rb +4 -0
- data/examples/rails_openid/app/controllers/consumer_controller.rb +122 -0
- data/examples/rails_openid/app/controllers/login_controller.rb +45 -0
- data/examples/rails_openid/app/controllers/server_controller.rb +265 -0
- data/examples/rails_openid/app/helpers/application_helper.rb +3 -0
- data/examples/rails_openid/app/helpers/login_helper.rb +2 -0
- data/examples/rails_openid/app/helpers/server_helper.rb +9 -0
- data/examples/rails_openid/app/views/consumer/index.rhtml +81 -0
- data/examples/rails_openid/app/views/layouts/server.rhtml +68 -0
- data/examples/rails_openid/app/views/login/index.rhtml +56 -0
- data/examples/rails_openid/app/views/server/decide.rhtml +26 -0
- data/examples/rails_openid/config/boot.rb +19 -0
- data/examples/rails_openid/config/database.yml +74 -0
- data/examples/rails_openid/config/environment.rb +54 -0
- data/examples/rails_openid/config/environments/development.rb +19 -0
- data/examples/rails_openid/config/environments/production.rb +19 -0
- data/examples/rails_openid/config/environments/test.rb +19 -0
- data/examples/rails_openid/config/routes.rb +24 -0
- data/examples/rails_openid/doc/README_FOR_APP +2 -0
- data/examples/rails_openid/public/.htaccess +40 -0
- data/examples/rails_openid/public/404.html +8 -0
- data/examples/rails_openid/public/500.html +8 -0
- data/examples/rails_openid/public/dispatch.cgi +12 -0
- data/examples/rails_openid/public/dispatch.fcgi +26 -0
- data/examples/rails_openid/public/dispatch.rb +12 -0
- data/examples/rails_openid/public/favicon.ico +0 -0
- data/examples/rails_openid/public/images/openid_login_bg.gif +0 -0
- data/examples/rails_openid/public/javascripts/controls.js +750 -0
- data/examples/rails_openid/public/javascripts/dragdrop.js +584 -0
- data/examples/rails_openid/public/javascripts/effects.js +854 -0
- data/examples/rails_openid/public/javascripts/prototype.js +1785 -0
- data/examples/rails_openid/public/robots.txt +1 -0
- data/examples/rails_openid/script/about +3 -0
- data/examples/rails_openid/script/breakpointer +3 -0
- data/examples/rails_openid/script/console +3 -0
- data/examples/rails_openid/script/destroy +3 -0
- data/examples/rails_openid/script/generate +3 -0
- data/examples/rails_openid/script/performance/benchmarker +3 -0
- data/examples/rails_openid/script/performance/profiler +3 -0
- data/examples/rails_openid/script/plugin +3 -0
- data/examples/rails_openid/script/process/reaper +3 -0
- data/examples/rails_openid/script/process/spawner +3 -0
- data/examples/rails_openid/script/process/spinner +3 -0
- data/examples/rails_openid/script/runner +3 -0
- data/examples/rails_openid/script/server +3 -0
- data/examples/rails_openid/test/functional/login_controller_test.rb +18 -0
- data/examples/rails_openid/test/functional/server_controller_test.rb +18 -0
- data/examples/rails_openid/test/test_helper.rb +28 -0
- data/lib/hmac/hmac.rb +112 -0
- data/lib/hmac/sha1.rb +11 -0
- data/lib/hmac/sha2.rb +25 -0
- data/lib/openid.rb +20 -0
- data/lib/openid/association.rb +249 -0
- data/lib/openid/consumer.rb +395 -0
- data/lib/openid/consumer/associationmanager.rb +344 -0
- data/lib/openid/consumer/checkid_request.rb +186 -0
- data/lib/openid/consumer/discovery.rb +497 -0
- data/lib/openid/consumer/discovery_manager.rb +123 -0
- data/lib/openid/consumer/html_parse.rb +134 -0
- data/lib/openid/consumer/idres.rb +523 -0
- data/lib/openid/consumer/responses.rb +148 -0
- data/lib/openid/cryptutil.rb +115 -0
- data/lib/openid/dh.rb +89 -0
- data/lib/openid/extension.rb +39 -0
- data/lib/openid/extensions/ax.rb +539 -0
- data/lib/openid/extensions/oauth.rb +91 -0
- data/lib/openid/extensions/pape.rb +179 -0
- data/lib/openid/extensions/sreg.rb +277 -0
- data/lib/openid/extensions/ui.rb +53 -0
- data/lib/openid/extras.rb +11 -0
- data/lib/openid/fetchers.rb +258 -0
- data/lib/openid/kvform.rb +136 -0
- data/lib/openid/kvpost.rb +58 -0
- data/lib/openid/message.rb +553 -0
- data/lib/openid/protocolerror.rb +8 -0
- data/lib/openid/server.rb +1544 -0
- data/lib/openid/store/filesystem.rb +271 -0
- data/lib/openid/store/interface.rb +75 -0
- data/lib/openid/store/memcache.rb +107 -0
- data/lib/openid/store/memory.rb +84 -0
- data/lib/openid/store/nonce.rb +68 -0
- data/lib/openid/trustroot.rb +349 -0
- data/lib/openid/urinorm.rb +75 -0
- data/lib/openid/util.rb +110 -0
- data/lib/openid/yadis/accept.rb +148 -0
- data/lib/openid/yadis/constants.rb +21 -0
- data/lib/openid/yadis/discovery.rb +153 -0
- data/lib/openid/yadis/filters.rb +205 -0
- data/lib/openid/yadis/htmltokenizer.rb +305 -0
- data/lib/openid/yadis/parsehtml.rb +45 -0
- data/lib/openid/yadis/services.rb +42 -0
- data/lib/openid/yadis/xrds.rb +155 -0
- data/lib/openid/yadis/xri.rb +90 -0
- data/lib/openid/yadis/xrires.rb +99 -0
- data/setup.rb +1551 -0
- data/test/data/accept.txt +124 -0
- data/test/data/dh.txt +29 -0
- data/test/data/example-xrds.xml +14 -0
- data/test/data/linkparse.txt +587 -0
- data/test/data/n2b64 +650 -0
- data/test/data/test1-discover.txt +137 -0
- data/test/data/test1-parsehtml.txt +152 -0
- data/test/data/test_discover/malformed_meta_tag.html +19 -0
- data/test/data/test_discover/openid.html +11 -0
- data/test/data/test_discover/openid2.html +11 -0
- data/test/data/test_discover/openid2_xrds.xml +12 -0
- data/test/data/test_discover/openid2_xrds_no_local_id.xml +11 -0
- data/test/data/test_discover/openid_1_and_2.html +11 -0
- data/test/data/test_discover/openid_1_and_2_xrds.xml +16 -0
- data/test/data/test_discover/openid_1_and_2_xrds_bad_delegate.xml +17 -0
- data/test/data/test_discover/openid_and_yadis.html +12 -0
- data/test/data/test_discover/openid_no_delegate.html +10 -0
- data/test/data/test_discover/openid_utf8.html +11 -0
- data/test/data/test_discover/yadis_0entries.xml +12 -0
- data/test/data/test_discover/yadis_2_bad_local_id.xml +15 -0
- data/test/data/test_discover/yadis_2entries_delegate.xml +22 -0
- data/test/data/test_discover/yadis_2entries_idp.xml +21 -0
- data/test/data/test_discover/yadis_another_delegate.xml +14 -0
- data/test/data/test_discover/yadis_idp.xml +12 -0
- data/test/data/test_discover/yadis_idp_delegate.xml +13 -0
- data/test/data/test_discover/yadis_no_delegate.xml +11 -0
- data/test/data/test_xrds/=j3h.2007.11.14.xrds +25 -0
- data/test/data/test_xrds/README +12 -0
- data/test/data/test_xrds/delegated-20060809-r1.xrds +34 -0
- data/test/data/test_xrds/delegated-20060809-r2.xrds +34 -0
- data/test/data/test_xrds/delegated-20060809.xrds +34 -0
- data/test/data/test_xrds/no-xrd.xml +7 -0
- data/test/data/test_xrds/not-xrds.xml +2 -0
- data/test/data/test_xrds/prefixsometimes.xrds +34 -0
- data/test/data/test_xrds/ref.xrds +109 -0
- data/test/data/test_xrds/sometimesprefix.xrds +34 -0
- data/test/data/test_xrds/spoof1.xrds +25 -0
- data/test/data/test_xrds/spoof2.xrds +25 -0
- data/test/data/test_xrds/spoof3.xrds +37 -0
- data/test/data/test_xrds/status222.xrds +9 -0
- data/test/data/test_xrds/subsegments.xrds +58 -0
- data/test/data/test_xrds/valid-populated-xrds.xml +39 -0
- data/test/data/trustroot.txt +153 -0
- data/test/data/urinorm.txt +79 -0
- data/test/discoverdata.rb +131 -0
- data/test/test_accept.rb +170 -0
- data/test/test_association.rb +266 -0
- data/test/test_associationmanager.rb +917 -0
- data/test/test_ax.rb +690 -0
- data/test/test_checkid_request.rb +294 -0
- data/test/test_consumer.rb +257 -0
- data/test/test_cryptutil.rb +119 -0
- data/test/test_dh.rb +86 -0
- data/test/test_discover.rb +852 -0
- data/test/test_discovery_manager.rb +262 -0
- data/test/test_extension.rb +46 -0
- data/test/test_extras.rb +35 -0
- data/test/test_fetchers.rb +565 -0
- data/test/test_filters.rb +270 -0
- data/test/test_idres.rb +963 -0
- data/test/test_kvform.rb +165 -0
- data/test/test_kvpost.rb +65 -0
- data/test/test_linkparse.rb +101 -0
- data/test/test_message.rb +1116 -0
- data/test/test_nonce.rb +89 -0
- data/test/test_oauth.rb +175 -0
- data/test/test_openid_yadis.rb +178 -0
- data/test/test_pape.rb +247 -0
- data/test/test_parsehtml.rb +80 -0
- data/test/test_responses.rb +63 -0
- data/test/test_server.rb +2457 -0
- data/test/test_sreg.rb +479 -0
- data/test/test_stores.rb +298 -0
- data/test/test_trustroot.rb +113 -0
- data/test/test_ui.rb +93 -0
- data/test/test_urinorm.rb +35 -0
- data/test/test_util.rb +145 -0
- data/test/test_xrds.rb +169 -0
- data/test/test_xri.rb +48 -0
- data/test/test_xrires.rb +63 -0
- data/test/test_yadis_discovery.rb +220 -0
- data/test/testutil.rb +127 -0
- data/test/util.rb +53 -0
- metadata +336 -0
data/NOTICE
ADDED
data/README
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
=Ruby OpenID
|
2
|
+
|
3
|
+
A Ruby library for verifying and serving OpenID identities.
|
4
|
+
|
5
|
+
==Features
|
6
|
+
* Easy to use API for verifying OpenID identites - OpenID::Consumer
|
7
|
+
* Support for serving OpenID identites - OpenID::Server
|
8
|
+
* Does not depend on underlying web framework
|
9
|
+
* Supports multiple storage mechanisms (Filesystem, ActiveRecord, Memory)
|
10
|
+
* Example code to help you get started, including:
|
11
|
+
* Ruby on Rails based consumer and server
|
12
|
+
* OpenIDLoginGenerator for quickly getting creating a rails app that uses
|
13
|
+
OpenID for authentication
|
14
|
+
* ActiveRecordOpenIDStore plugin
|
15
|
+
* Comprehensive test suite
|
16
|
+
* Supports both OpenID 1 and OpenID 2 transparently
|
17
|
+
|
18
|
+
==Installing
|
19
|
+
Before running the examples or writing your own code you'll need to install
|
20
|
+
the library. See the INSTALL file or use rubygems:
|
21
|
+
|
22
|
+
gem install ruby-openid
|
23
|
+
|
24
|
+
Check the installation:
|
25
|
+
|
26
|
+
$ irb
|
27
|
+
irb> require 'rubygems'
|
28
|
+
irb> require_gem 'ruby-openid'
|
29
|
+
=> true
|
30
|
+
|
31
|
+
The library is known to work with Ruby 1.8.4 on Unix, Max OSX and
|
32
|
+
Win32. Examples have been tested with Rails 1.1 and 1.2, and 2.0.
|
33
|
+
|
34
|
+
==Getting Started
|
35
|
+
The best way to start is to look at the rails_openid example.
|
36
|
+
You can run it with:
|
37
|
+
cd examples/rails_openid
|
38
|
+
script/server
|
39
|
+
|
40
|
+
If you are writing an OpenID Relying Party, a good place to start is:
|
41
|
+
examples/rails_openid/app/controllers/consumer_controller.rb
|
42
|
+
|
43
|
+
And if you are writing an OpenID provider:
|
44
|
+
examples/rails_openid/app/controllers/server_controller.rb
|
45
|
+
|
46
|
+
The library code is quite well documented, so don't be squeamish, and
|
47
|
+
look at the library itself if there's anything you don't understand in
|
48
|
+
the examples.
|
49
|
+
|
50
|
+
==Homepage
|
51
|
+
http://github.com/openid/ruby-openid
|
52
|
+
|
53
|
+
See also:
|
54
|
+
http://openid.net/
|
55
|
+
|
56
|
+
==Community
|
57
|
+
Discussion regarding the Ruby OpenID library and other JanRain OpenID
|
58
|
+
libraries takes place on the the OpenID mailing list on
|
59
|
+
openid.net.
|
60
|
+
|
61
|
+
http://openid.net/developers/dev-mailing-lists/
|
62
|
+
|
63
|
+
Please join this list to discuss, ask implementation questions, report
|
64
|
+
bugs, etc. Also check out the openid channel on the freenode IRC
|
65
|
+
network.
|
66
|
+
|
67
|
+
If you have a bugfix or feature you'd like to contribute, don't
|
68
|
+
hesitate to send it to us. For more detailed information on how to
|
69
|
+
contribute, see
|
70
|
+
|
71
|
+
http://openidenabled.com/contribute/
|
72
|
+
|
73
|
+
==Author
|
74
|
+
Copyright 2006-2008, JanRain, Inc.
|
75
|
+
|
76
|
+
Contact openid@janrain.com or visit the OpenID channel on pibb.com:
|
77
|
+
|
78
|
+
http://pibb.com/go/openid
|
79
|
+
|
80
|
+
==License
|
81
|
+
Apache Software License. For more information see the LICENSE file.
|
data/Rakefile
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
|
7
|
+
class Jeweler
|
8
|
+
module Commands
|
9
|
+
class ReleaseGemspec
|
10
|
+
def run
|
11
|
+
unless clean_staging_area?
|
12
|
+
system "git status"
|
13
|
+
raise "Unclean staging area! Be sure to commit or .gitignore everything first. See `git status` above."
|
14
|
+
end
|
15
|
+
repo.checkout('releasable')
|
16
|
+
regenerate_gemspec!
|
17
|
+
commit_gemspec! if gemspec_changed?
|
18
|
+
output.puts "Pushing releasable to origin"
|
19
|
+
repo.push
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Jeweler
|
26
|
+
module Commands
|
27
|
+
class ReleaseToGit
|
28
|
+
def run
|
29
|
+
unless clean_staging_area?
|
30
|
+
system "git status"
|
31
|
+
raise "Unclean staging area! Be sure to commit or .gitignore everything first. See `git status` above."
|
32
|
+
end
|
33
|
+
repo.checkout('releasable')
|
34
|
+
repo.push
|
35
|
+
if release_not_tagged?
|
36
|
+
output.puts "Tagging #{release_tag}"
|
37
|
+
repo.add_tag(release_tag)
|
38
|
+
output.puts "Pushing #{release_tag} to origin"
|
39
|
+
repo.push('origin', release_tag)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Jeweler::Tasks.new do |gem|
|
47
|
+
gem.name = 'nov-ruby-openid'
|
48
|
+
gem.authors = ['nov matake']
|
49
|
+
gem.email = 'nov@matake.jp'
|
50
|
+
gem.homepage = 'http://github.com/nov/ruby-openid/'
|
51
|
+
gem.summary = 'A library for consuming and serving OpenID identities.'
|
52
|
+
gem.extra_rdoc_files = ["LICENSE", "README", "INSTALL","UPGRADE","CHANGELOG", "CHANGES-2.1.0", "UPGRADE"]
|
53
|
+
gem.files.exclude "admin","_darcs","coverage",".gitignore","gemspec"
|
54
|
+
end
|
55
|
+
Jeweler::GemcutterTasks.new
|
56
|
+
rescue LoadError
|
57
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
58
|
+
end
|
59
|
+
|
60
|
+
require 'rake/testtask'
|
61
|
+
Rake::TestTask.new(:test) do |test|
|
62
|
+
test.libs << 'lib' << 'test'
|
63
|
+
test.ruby_opts = ['-rtestutil']
|
64
|
+
test.pattern = 'test/**/test_*.rb'
|
65
|
+
test.verbose = true
|
66
|
+
end
|
67
|
+
|
68
|
+
begin
|
69
|
+
require 'rcov/rcovtask'
|
70
|
+
Rcov::RcovTask.new do |test|
|
71
|
+
test.libs << 'test'
|
72
|
+
test.ruby_opts = ['-rtestutil']
|
73
|
+
test.pattern = 'test/**/test_*.rb'
|
74
|
+
test.verbose = true
|
75
|
+
end
|
76
|
+
rescue LoadError
|
77
|
+
task :rcov do
|
78
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
task :test => :check_dependencies
|
83
|
+
|
84
|
+
task :default => :test
|
85
|
+
|
86
|
+
require 'rake/rdoctask'
|
87
|
+
Rake::RDocTask.new do |rdoc|
|
88
|
+
if File.exist?('VERSION')
|
89
|
+
version = File.read('VERSION')
|
90
|
+
else
|
91
|
+
version = ""
|
92
|
+
end
|
93
|
+
|
94
|
+
rdoc.rdoc_dir = 'rdoc'
|
95
|
+
rdoc.title = "ruby-openid #{version}"
|
96
|
+
rdoc.rdoc_files.include('README*')
|
97
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
98
|
+
end
|
data/UPGRADE
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
= Upgrading from the OpenID 1.x series library
|
2
|
+
|
3
|
+
== Consumer Upgrade
|
4
|
+
|
5
|
+
The flow is largely the same, however there are a number of significant
|
6
|
+
changes. The consumer example is helpful to look at:
|
7
|
+
examples/rails_openid/app/controllers/consumer_controller.rb
|
8
|
+
|
9
|
+
|
10
|
+
=== Stores
|
11
|
+
|
12
|
+
You will need to require the file for the store that you are using.
|
13
|
+
For the filesystem store, this is 'openid/stores/filesystem'
|
14
|
+
They are also now in modules. The filesystem store is
|
15
|
+
OpenID::Store::Filesystem
|
16
|
+
The format has changed, and you should remove your old store directory.
|
17
|
+
|
18
|
+
The ActiveRecord store ( examples/active_record_openid_store ) still needs
|
19
|
+
to be put in a plugin directory for your rails app. There's a migration
|
20
|
+
that needs to be run; examine the README in that directory.
|
21
|
+
|
22
|
+
Also, note that the stores now can be garbage collected with the method
|
23
|
+
store.cleanup
|
24
|
+
|
25
|
+
|
26
|
+
=== Starting the OpenID transaction
|
27
|
+
|
28
|
+
The OpenIDRequest object no longer has status codes. Instead,
|
29
|
+
consumer.begin raises an OpenID::OpenIDError if there is a problem
|
30
|
+
initiating the transaction, so you'll want something along the lines of:
|
31
|
+
|
32
|
+
begin
|
33
|
+
openid_request = consumer.begin(params[:openid_identifier])
|
34
|
+
rescue OpenID::OpenIDError => e
|
35
|
+
# display error e
|
36
|
+
return
|
37
|
+
end
|
38
|
+
#success case
|
39
|
+
|
40
|
+
Data regarding the OpenID server once lived in
|
41
|
+
openid_request.service
|
42
|
+
|
43
|
+
The corresponding object in the 2.0 lib can be retrieved with
|
44
|
+
openid_request.endpoint
|
45
|
+
|
46
|
+
Getting the unverified identifier: Where you once had
|
47
|
+
openid_request.identity_url
|
48
|
+
you will now want
|
49
|
+
openid_request.endpoint.claimed_id
|
50
|
+
which might be different from what you get at the end of the transaction,
|
51
|
+
since it is now possible for users to enter their server's url directly.
|
52
|
+
|
53
|
+
Arguments on the return_to URL are now verified, so if you want to add
|
54
|
+
additional arguments to the return_to url, use
|
55
|
+
openid_request.return_to_args['param'] = value
|
56
|
+
|
57
|
+
Generating the redirect is the same as before, but add any extensions
|
58
|
+
first.
|
59
|
+
|
60
|
+
If you need to set up an SSL certificate authority list for the fetcher,
|
61
|
+
use the 'ca_file' attr_accessor on the OpenID::StandardFetcher. This has
|
62
|
+
changed from 'ca_path' in the 1.x.x series library. That is, set
|
63
|
+
OpenID.fetcher.ca_file = '/path/to/ca.list'
|
64
|
+
before calling consumer.begin.
|
65
|
+
|
66
|
+
=== Requesting Simple Registration Data
|
67
|
+
|
68
|
+
You'll need to require the code for the extension
|
69
|
+
require 'openid/extensions/sreg'
|
70
|
+
|
71
|
+
The new code for adding an SReg request now looks like:
|
72
|
+
|
73
|
+
sreg_request = OpenID::SReg::Request.new
|
74
|
+
sreg_request.request_fields(['email', 'dob'], true) # required
|
75
|
+
sreg_request.request_fields(['nickname', 'fullname'], false) # optional
|
76
|
+
sreg_request.policy_url = policy_url
|
77
|
+
openid_request.add_extension(sreg_request)
|
78
|
+
|
79
|
+
The code for adding other extensions is similar. Code for the Attribute
|
80
|
+
Exchange (AX) and Provider Authentication Policy Extension (PAPE) are
|
81
|
+
included with the library, and additional extensions can be implemented
|
82
|
+
subclassing OpenID::Extension.
|
83
|
+
|
84
|
+
|
85
|
+
=== Completing the transaction
|
86
|
+
|
87
|
+
The return_to and its arguments are verified, so you need to pass in
|
88
|
+
the base URL and the arguments. With Rails, the params method mashes
|
89
|
+
together parameters from GET, POST, and the path, so you'll need to pull
|
90
|
+
off the path "parameters" with something like
|
91
|
+
|
92
|
+
return_to = url_for(:only_path => false,
|
93
|
+
:controller => 'openid',
|
94
|
+
:action => 'complete')
|
95
|
+
parameters = params.reject{|k,v| request.path_parameters[k] }
|
96
|
+
openid_response = consumer.complete(parameters, return_to)
|
97
|
+
|
98
|
+
The response still uses the status codes, but they are now namespaced
|
99
|
+
slightly differently, for example OpenID::Consumer::SUCCESS
|
100
|
+
|
101
|
+
In the case of failure, the error message is now found in
|
102
|
+
openid_response.message
|
103
|
+
|
104
|
+
The identifier to display to the user can be found in
|
105
|
+
openid_response.endpoint.display_identifier
|
106
|
+
|
107
|
+
The Simple Registration response can be read from the OpenID response
|
108
|
+
with
|
109
|
+
sreg_response = OpenID::SReg::Response.from_success_response(openid_response)
|
110
|
+
nickname = sreg_response['nickname']
|
111
|
+
# etc.
|
112
|
+
|
113
|
+
|
114
|
+
== Server Upgrade
|
115
|
+
|
116
|
+
The server code is mostly the same as before, with the exception of
|
117
|
+
extensions. Also, you must pass in the endpoint URL to the server
|
118
|
+
constructor:
|
119
|
+
@server = OpenID::Server.new(store, server_url)
|
120
|
+
|
121
|
+
I recommend looking at
|
122
|
+
examples/rails_openid/app/controllers/server_controller.rb
|
123
|
+
for an example of the new way of doing extensions.
|
124
|
+
|
125
|
+
--
|
126
|
+
Dag Arneson, JanRain Inc.
|
127
|
+
Please direct questions to openid@janrain.com
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.9
|
Binary file
|
Binary file
|
data/examples/README
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
This directory contains several examples that demonstrate use of the
|
2
|
+
OpenID library. Make sure you have properly installed the library
|
3
|
+
before running the examples. These examples are a great place to
|
4
|
+
start in integrating OpenID into your application.
|
5
|
+
|
6
|
+
==Rails example
|
7
|
+
|
8
|
+
The rails_openid contains a fully functional OpenID server and relying
|
9
|
+
party, and acts as a starting point for implementing your own
|
10
|
+
production rails server. You'll need the latest version of Ruby on
|
11
|
+
Rails installed, and then:
|
12
|
+
|
13
|
+
cd rails_openid
|
14
|
+
./script/server
|
15
|
+
|
16
|
+
Open a web browser to http://localhost:3000/ and follow the instructions.
|
17
|
+
|
18
|
+
The relevant code to work from when writing your Rails OpenID Relying
|
19
|
+
Party is:
|
20
|
+
rails_openid/app/controllers/consumer_controller.rb
|
21
|
+
If you are working on an OpenID provider, check out
|
22
|
+
rails_openid/app/controllers/server_controller.rb
|
23
|
+
|
24
|
+
Since the library and examples are Apache-licensed, don't be shy about
|
25
|
+
copy-and-paste.
|
26
|
+
|
27
|
+
==Rails ActiveRecord OpenIDStore plugin
|
28
|
+
|
29
|
+
For various reasons you may want or need to deploy your ruby openid
|
30
|
+
consumer/server using an SQL based store. The active_record_openid_store
|
31
|
+
is a plugin that makes using an SQL based store simple. Follow the
|
32
|
+
README inside the plugin's dir for usage.
|
@@ -0,0 +1,58 @@
|
|
1
|
+
=Active Record OpenID Store Plugin
|
2
|
+
|
3
|
+
A store is required by an OpenID server and optionally by the consumer
|
4
|
+
to store associations, nonces, and auth key information across
|
5
|
+
requests and processes. If rails is distributed across several
|
6
|
+
machines, they must must all have access to the same OpenID store
|
7
|
+
data, so the FilesystemStore won't do.
|
8
|
+
|
9
|
+
This directory contains a plugin for connecting your
|
10
|
+
OpenID enabled rails app to an ActiveRecord based OpenID store.
|
11
|
+
|
12
|
+
==Install
|
13
|
+
|
14
|
+
1) Copy this directory and all it's contents into your
|
15
|
+
RAILS_ROOT/vendor/plugins directory. You structure should look like
|
16
|
+
this:
|
17
|
+
|
18
|
+
RAILS_ROOT/vendor/plugins/active_record_openid_store/
|
19
|
+
|
20
|
+
2) Copy the migration, XXX_add_open_id_store_to_db.rb to your
|
21
|
+
RAILS_ROOT/db/migrate directory. Rename the XXX portion of the
|
22
|
+
file to next sequential migration number.
|
23
|
+
|
24
|
+
3) Run the migration:
|
25
|
+
|
26
|
+
rake migrate
|
27
|
+
|
28
|
+
4) Change your app to use the ActiveRecordOpenIDStore:
|
29
|
+
|
30
|
+
store = ActiveRecordOpenIDStore.new
|
31
|
+
consumer = OpenID::Consumer.new(session, store)
|
32
|
+
|
33
|
+
5) That's it! All your OpenID state will now be stored in the database.
|
34
|
+
|
35
|
+
==Upgrade
|
36
|
+
|
37
|
+
If you are upgrading from the 1.x ActiveRecord store, replace your old
|
38
|
+
RAILS_ROOT/vendor/plugins/active_record_openid_store/ directory with
|
39
|
+
the new one and run the migration XXX_upgrade_open_id_store.rb.
|
40
|
+
|
41
|
+
==What about garbage collection?
|
42
|
+
|
43
|
+
You may garbage collect unused nonces and expired associations using
|
44
|
+
the gc instance method of ActiveRecordOpenIDStore. Hook it up to a
|
45
|
+
task in your app's Rakefile like so:
|
46
|
+
|
47
|
+
desc 'GC OpenID store'
|
48
|
+
task :gc_openid_store => :environment do
|
49
|
+
ActiveRecordOpenIDStore.new.cleanup
|
50
|
+
end
|
51
|
+
|
52
|
+
Run it by typing:
|
53
|
+
|
54
|
+
rake gc_openid_store
|
55
|
+
|
56
|
+
|
57
|
+
==Questions?
|
58
|
+
Contact Dag Arneson: dag at janrain dot com
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Use this migration to create the tables for the ActiveRecord store
|
2
|
+
class AddOpenIdStoreToDb < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
create_table "open_id_associations", :force => true do |t|
|
5
|
+
t.column "server_url", :binary, :null => false
|
6
|
+
t.column "handle", :string, :null => false
|
7
|
+
t.column "secret", :binary, :null => false
|
8
|
+
t.column "issued", :integer, :null => false
|
9
|
+
t.column "lifetime", :integer, :null => false
|
10
|
+
t.column "assoc_type", :string, :null => false
|
11
|
+
end
|
12
|
+
|
13
|
+
create_table "open_id_nonces", :force => true do |t|
|
14
|
+
t.column :server_url, :string, :null => false
|
15
|
+
t.column :timestamp, :integer, :null => false
|
16
|
+
t.column :salt, :string, :null => false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.down
|
21
|
+
drop_table "open_id_associations"
|
22
|
+
drop_table "open_id_nonces"
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Use this migration to upgrade the old 1.1 ActiveRecord store schema
|
2
|
+
# to the new 2.0 schema.
|
3
|
+
class UpgradeOpenIdStore < ActiveRecord::Migration
|
4
|
+
def self.up
|
5
|
+
drop_table "open_id_settings"
|
6
|
+
drop_table "open_id_nonces"
|
7
|
+
create_table "open_id_nonces", :force => true do |t|
|
8
|
+
t.column :server_url, :string, :null => false
|
9
|
+
t.column :timestamp, :integer, :null => false
|
10
|
+
t.column :salt, :string, :null => false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
drop_table "open_id_nonces"
|
16
|
+
create_table "open_id_nonces", :force => true do |t|
|
17
|
+
t.column "nonce", :string
|
18
|
+
t.column "created", :integer
|
19
|
+
end
|
20
|
+
|
21
|
+
create_table "open_id_settings", :force => true do |t|
|
22
|
+
t.column "setting", :string
|
23
|
+
t.column "value", :binary
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|