Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 127 lines (92 sloc) 4.511 kb
ae64c5a8 »
2012-07-07 Docfile changes
1 # Upgrading from the OpenID 1.x series library
9d67faaf »
2007-12-05 [project @ Add upgrade document]
2
ae64c5a8 »
2012-07-07 Docfile changes
3 ## Consumer Upgrade
9d67faaf »
2007-12-05 [project @ Add upgrade document]
4
ae64c5a8 »
2012-07-07 Docfile changes
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`
9d67faaf »
2007-12-05 [project @ Add upgrade document]
8
ae64c5a8 »
2012-07-07 Docfile changes
9 ### Stores
9d67faaf »
2007-12-05 [project @ Add upgrade document]
10
11 You will need to require the file for the store that you are using.
12 For the filesystem store, this is 'openid/stores/filesystem'
ae64c5a8 »
2012-07-07 Docfile changes
13 They are also now in modules. The filesystem store is
14 `OpenID::Store::Filesystem`
9d67faaf »
2007-12-05 [project @ Add upgrade document]
15 The format has changed, and you should remove your old store directory.
16
ae64c5a8 »
2012-07-07 Docfile changes
17 The ActiveRecord store (`examples/active_record_openid_store`) still needs
9d67faaf »
2007-12-05 [project @ Add upgrade document]
18 to be put in a plugin directory for your rails app. There's a migration
ae64c5a8 »
2012-07-07 Docfile changes
19 that needs to be run; examine the `README` in that directory.
9d67faaf »
2007-12-05 [project @ Add upgrade document]
20
21 Also, note that the stores now can be garbage collected with the method
ae64c5a8 »
2012-07-07 Docfile changes
22 `store.cleanup`
9d67faaf »
2007-12-05 [project @ Add upgrade document]
23
ae64c5a8 »
2012-07-07 Docfile changes
24 ### Starting the OpenID transaction
9d67faaf »
2007-12-05 [project @ Add upgrade document]
25
26 The OpenIDRequest object no longer has status codes. Instead,
27 consumer.begin raises an OpenID::OpenIDError if there is a problem
28 initiating the transaction, so you'll want something along the lines of:
29
ae64c5a8 »
2012-07-07 Docfile changes
30 begin
31 openid_request = consumer.begin(params[:openid_identifier])
32 rescue OpenID::OpenIDError => e
33 # display error e
34 return
35 end
36 #success case
9d67faaf »
2007-12-05 [project @ Add upgrade document]
37
38 Data regarding the OpenID server once lived in
ae64c5a8 »
2012-07-07 Docfile changes
39 `openid_request.service`
9d67faaf »
2007-12-05 [project @ Add upgrade document]
40
41 The corresponding object in the 2.0 lib can be retrieved with
ae64c5a8 »
2012-07-07 Docfile changes
42 `openid_request.endpoint`
9d67faaf »
2007-12-05 [project @ Add upgrade document]
43
44 Getting the unverified identifier: Where you once had
ae64c5a8 »
2012-07-07 Docfile changes
45 `openid_request.identity_url`
9d67faaf »
2007-12-05 [project @ Add upgrade document]
46 you will now want
ae64c5a8 »
2012-07-07 Docfile changes
47 `openid_request.endpoint.claimed_id`
9d67faaf »
2007-12-05 [project @ Add upgrade document]
48 which might be different from what you get at the end of the transaction,
49 since it is now possible for users to enter their server's url directly.
50
51 Arguments on the return_to URL are now verified, so if you want to add
52 additional arguments to the return_to url, use
ae64c5a8 »
2012-07-07 Docfile changes
53 `openid_request.return_to_args['param'] = value`
9d67faaf »
2007-12-05 [project @ Add upgrade document]
54
55 Generating the redirect is the same as before, but add any extensions
56 first.
57
32e872cc »
2008-06-05 [project @ Add a note about change to name of ca list instance var]
58 If you need to set up an SSL certificate authority list for the fetcher,
ae64c5a8 »
2012-07-07 Docfile changes
59 use the 'ca_file' attr_accessor on the `OpenID::StandardFetcher`. This has
60 changed from 'ca_path' in the 1.x.x series library. That is, set
61 `OpenID.fetcher.ca_file = '/path/to/ca.list'`
32e872cc »
2008-06-05 [project @ Add a note about change to name of ca list instance var]
62 before calling consumer.begin.
006899b9 »
2008-01-10 [project @ UPGRADE: formatting]
63
ae64c5a8 »
2012-07-07 Docfile changes
64 ### Requesting Simple Registration Data
9d67faaf »
2007-12-05 [project @ Add upgrade document]
65
66 You'll need to require the code for the extension
ae64c5a8 »
2012-07-07 Docfile changes
67
68 require 'openid/extensions/sreg'
9d67faaf »
2007-12-05 [project @ Add upgrade document]
69
70 The new code for adding an SReg request now looks like:
71
ae64c5a8 »
2012-07-07 Docfile changes
72 sreg_request = OpenID::SReg::Request.new
73 sreg_request.request_fields(['email', 'dob'], true) # required
74 sreg_request.request_fields(['nickname', 'fullname'], false) # optional
75 sreg_request.policy_url = policy_url
76 openid_request.add_extension(sreg_request)
9d67faaf »
2007-12-05 [project @ Add upgrade document]
77
78 The code for adding other extensions is similar. Code for the Attribute
79 Exchange (AX) and Provider Authentication Policy Extension (PAPE) are
80 included with the library, and additional extensions can be implemented
ae64c5a8 »
2012-07-07 Docfile changes
81 subclassing `OpenID::Extension`.
9d67faaf »
2007-12-05 [project @ Add upgrade document]
82
ae64c5a8 »
2012-07-07 Docfile changes
83 ### Completing the transaction
9d67faaf »
2007-12-05 [project @ Add upgrade document]
84
85 The return_to and its arguments are verified, so you need to pass in
86 the base URL and the arguments. With Rails, the params method mashes
87 together parameters from GET, POST, and the path, so you'll need to pull
88 off the path "parameters" with something like
89
ae64c5a8 »
2012-07-07 Docfile changes
90 return_to = url_for(:only_path => false,
91 :controller => 'openid',
92 :action => 'complete')
93 parameters = params.reject{|k,v| request.path_parameters[k] }
94 openid_response = consumer.complete(parameters, return_to)
9d67faaf »
2007-12-05 [project @ Add upgrade document]
95
96 The response still uses the status codes, but they are now namespaced
ae64c5a8 »
2012-07-07 Docfile changes
97 slightly differently, for example `OpenID::Consumer::SUCCESS`
9d67faaf »
2007-12-05 [project @ Add upgrade document]
98
99 In the case of failure, the error message is now found in
ae64c5a8 »
2012-07-07 Docfile changes
100 `openid_response.message`
9d67faaf »
2007-12-05 [project @ Add upgrade document]
101
102 The identifier to display to the user can be found in
ae64c5a8 »
2012-07-07 Docfile changes
103 `openid_response.endpoint.display_identifier`
9d67faaf »
2007-12-05 [project @ Add upgrade document]
104
105 The Simple Registration response can be read from the OpenID response
106 with
107
ae64c5a8 »
2012-07-07 Docfile changes
108 sreg_response = OpenID::SReg::Response.from_success_response(openid_response)
109 nickname = sreg_response['nickname']
110 # etc.
006899b9 »
2008-01-10 [project @ UPGRADE: formatting]
111
ae64c5a8 »
2012-07-07 Docfile changes
112 ## Server Upgrade
006899b9 »
2008-01-10 [project @ UPGRADE: formatting]
113
9d67faaf »
2007-12-05 [project @ Add upgrade document]
114 The server code is mostly the same as before, with the exception of
ae64c5a8 »
2012-07-07 Docfile changes
115 extensions. Also, you must pass in the endpoint URL to the server
9d67faaf »
2007-12-05 [project @ Add upgrade document]
116 constructor:
117
ae64c5a8 »
2012-07-07 Docfile changes
118 @server = OpenID::Server.new(store, server_url)
119
120 I recommend looking at
121 `examples/rails_openid/app/controllers/server_controller.rb`
9d67faaf »
2007-12-05 [project @ Add upgrade document]
122 for an example of the new way of doing extensions.
123
124 --
125 Dag Arneson, JanRain Inc.
126 Please direct questions to openid@janrain.com
Something went wrong with that request. Please try again.