File: _Auth---OpenID---Consumer.php.html

package info (click to toggle)
php-openid 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,284 kB
  • ctags: 6,733
  • sloc: php: 20,482; python: 346; xml: 333; sh: 130; perl: 103; makefile: 31
file content (466 lines) | stat: -rw-r--r-- 22,488 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos -->
			<title>Docs for page Consumer.php</title>
			<link rel="stylesheet" href="../media/stylesheet.css" />
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
		</head>
		<body>
			<div class="page-body">			

<h2 class="file-name">/Auth/OpenID/Consumer.php</h2>

<a name="sec-description"></a>
<div class="info-box">
	<div class="info-box-title">Description</div>
	<div class="nav-bar">
					<span class="disabled">Description</span> |
							<a href="#sec-classes">Classes</a>
			|							<a href="#sec-includes">Includes</a>
			|							<a href="#sec-constants">Constants</a>
			|									<a href="#sec-functions">Functions</a>
			</div>
	<div class="info-box-body">	
		<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">This module documents the main interface with the OpenID consumer</p>
<p class="description"><p>library.  The only part of the library which has to be used and  isn't documented in full here is the store required to create an  Auth_OpenID_Consumer instance.  More on the abstract store type and  concrete implementations of it that are provided in the  documentation for the Auth_OpenID_Consumer constructor.</p><p>OVERVIEW</p><p>The OpenID identity verification process most commonly uses the  following steps, as visible to the user of this library:</p><p><ol><li>The user enters their OpenID into a field on the consumer's
      site, and hits a login button.</li><li>The consumer site discovers the user's OpenID server using the
      YADIS protocol.</li><li>The consumer site sends the browser a redirect to the identity
      server.  This is the authentication request as described in
      the OpenID specification.</li><li>The identity server's site sends the browser a redirect back
      to the consumer site.  This redirect contains the server's
      response to the authentication request.</li></ol>  The most important part of the flow to note is the consumer's site  must handle two separate HTTP requests in order to perform the full  identity check.</p><p>LIBRARY DESIGN</p><p>This consumer library is designed with that flow in mind.  The goal  is to make it as easy as possible to perform the above steps  securely.</p><p>At a high level, there are two important parts in the consumer  library.  The first important part is this module, which contains  the interface to actually use this library.  The second is the  Auth_OpenID_Interface class, which describes the interface to use  if you need to create a custom method for storing the state this  library needs to maintain between requests.</p><p>In general, the second part is less important for users of the  library to know about, as several implementations are provided  which cover a wide variety of situations in which consumers may use  the library.</p><p>This module contains a class, Auth_OpenID_Consumer, with methods  corresponding to the actions necessary in each of steps 2, 3, and 4  described in the overview.  Use of this library should be as easy  as creating an Auth_OpenID_Consumer instance and calling the  methods appropriate for the action the site wants to take.</p><p>STORES AND DUMB MODE</p><p>OpenID is a protocol that works best when the consumer site is able  to store some state.  This is the normal mode of operation for the  protocol, and is sometimes referred to as smart mode.  There is  also a fallback mode, known as dumb mode, which is available when  the consumer site is not able to store state.  This mode should be  avoided when possible, as it leaves the implementation more  vulnerable to replay attacks.</p><p>The mode the library works in for normal operation is determined by  the store that it is given.  The store is an abstraction that  handles the data that the consumer needs to manage between http  requests in order to operate efficiently and securely.</p><p>Several store implementation are provided, and the interface is  fully documented so that custom stores can be used as well.  See  the documentation for the Auth_OpenID_Consumer class for more  information on the interface for stores.  The implementations that  are provided allow the consumer site to store the necessary data in  several different ways, including several SQL databases and normal  files on disk.</p><p>There is an additional concrete store provided that puts the system  in dumb mode.  This is not recommended, as it removes the library's  ability to stop replay attacks reliably.  It still uses time-based  checking to make replay attacks only possible within a small  window, but they remain possible within that window.  This store  should only be used if the consumer site has no way to retain data  between requests at all.</p><p>IMMEDIATE MODE</p><p>In the flow described above, the user may need to confirm to the  lidentity server that it's ok to authorize his or her identity.  The server may draw pages asking for information from the user  before it redirects the browser back to the consumer's site.  This  is generally transparent to the consumer site, so it is typically  ignored as an implementation detail.</p><p>There can be times, however, where the consumer site wants to get a  response immediately.  When this is the case, the consumer can put  the library in immediate mode.  In immediate mode, there is an  extra response possible from the server, which is essentially the  server reporting that it doesn't have enough information to answer  the question yet.</p><p>USING THIS LIBRARY</p><p>Integrating this library into an application is usually a  relatively straightforward process.  The process should basically  follow this plan:</p><p>Add an OpenID login field somewhere on your site.  When an OpenID  is entered in that field and the form is submitted, it should make  a request to the your site which includes that OpenID URL.</p><p>First, the application should instantiate the Auth_OpenID_Consumer  class using the store of choice (Auth_OpenID_FileStore or one of  the SQL-based stores).  If the application has a custom  session-management implementation, an object implementing the  <a href="../OpenID/Auth_Yadis_PHPSession.html">Auth_Yadis_PHPSession</a> interface should be passed as the  second parameter.  Otherwise, the default uses $_SESSION.</p><p>Next, the application should call the Auth_OpenID_Consumer object's  'begin' method.  This method takes the OpenID URL.  The 'begin'  method returns an Auth_OpenID_AuthRequest object.</p><p>Next, the application should call the 'redirectURL' method of the  Auth_OpenID_AuthRequest object.  The 'return_to' URL parameter is  the URL that the OpenID server will send the user back to after  attempting to verify his or her identity.  The 'trust_root' is the  URL (or URL pattern) that identifies your web site to the user when  he or she is authorizing it.  Send a redirect to the resulting URL  to the user's browser.</p><p>That's the first half of the authentication process.  The second  half of the process is done after the user's ID server sends the  user's browser a redirect back to your site to complete their  login.</p><p>When that happens, the user will contact your site at the URL given  as the 'return_to' URL to the Auth_OpenID_AuthRequest::redirectURL  call made above.  The request will have several query parameters  added to the URL by the identity server as the information  necessary to finish the request.</p><p>Lastly, instantiate an Auth_OpenID_Consumer instance as above and  call its 'complete' method, passing in all the received query  arguments.</p><p>There are multiple possible return types possible from that  method. These indicate the whether or not the login was successful,  and include any additional information appropriate for their type.</p><p>PHP versions 4 and 5</p><p>LICENSE: See the COPYING file included in this distribution.</p></p>
	<ul class="tags">
				<li><span class="field">author:</span> JanRain, Inc. &lt;<a href="mailto:openid@janrain.com">openid@janrain.com</a>&gt;</li>
				<li><span class="field">copyright:</span> 2005 Janrain, Inc.</li>
				<li><span class="field">license:</span> <a href="http://www.gnu.org/copyleft/lesser.html">LGPL</a></li>
			</ul>
		
			</div>
</div>
		
	<a name="sec-classes"></a>	
	<div class="info-box">
		<div class="info-box-title">Classes</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
			<span class="disabled">Classes</span>
			|							<a href="#sec-includes">Includes</a>
				|										<a href="#sec-constants">Constants</a>
				|													<a href="#sec-functions">Functions</a>
					</div>
		<div class="info-box-body">	
			<table cellpadding="2" cellspacing="0" class="class-table">
				<tr>
					<th class="class-table-header">Class</th>
					<th class="class-table-header">Description</th>
				</tr>
								<tr>
					<td style="padding-right: 2em; vertical-align: top">
						<a href="../OpenID/Auth_OpenID_Consumer.html">Auth_OpenID_Consumer</a>
					</td>
					<td>
											An OpenID consumer implementation that performs discovery and does  session management.  See the Consumer.php file documentation for  more information.
										</td>
				</tr>
								<tr>
					<td style="padding-right: 2em; vertical-align: top">
						<a href="../OpenID/Auth_OpenID_DiffieHellmanSHA1ConsumerSession.html">Auth_OpenID_DiffieHellmanSHA1ConsumerSession</a>
					</td>
					<td>
											A class implementing HMAC/DH-SHA1 consumer sessions.
										</td>
				</tr>
								<tr>
					<td style="padding-right: 2em; vertical-align: top">
						<a href="../OpenID/Auth_OpenID_DiffieHellmanSHA256ConsumerSession.html">Auth_OpenID_DiffieHellmanSHA256ConsumerSession</a>
					</td>
					<td>
											A class implementing HMAC/DH-SHA256 consumer sessions.
										</td>
				</tr>
								<tr>
					<td style="padding-right: 2em; vertical-align: top">
						<a href="../OpenID/Auth_OpenID_PlainTextConsumerSession.html">Auth_OpenID_PlainTextConsumerSession</a>
					</td>
					<td>
											A class implementing plaintext consumer sessions.
										</td>
				</tr>
								<tr>
					<td style="padding-right: 2em; vertical-align: top">
						<a href="../OpenID/Auth_OpenID_GenericConsumer.html">Auth_OpenID_GenericConsumer</a>
					</td>
					<td>
											This class is the interface to the OpenID consumer logic.
										</td>
				</tr>
								<tr>
					<td style="padding-right: 2em; vertical-align: top">
						<a href="../OpenID/Auth_OpenID_AuthRequest.html">Auth_OpenID_AuthRequest</a>
					</td>
					<td>
											This class represents an authentication request from a consumer to  an OpenID server.
										</td>
				</tr>
								<tr>
					<td style="padding-right: 2em; vertical-align: top">
						<a href="../OpenID/Auth_OpenID_ConsumerResponse.html">Auth_OpenID_ConsumerResponse</a>
					</td>
					<td>
											The base class for responses from the Auth_OpenID_Consumer.
										</td>
				</tr>
								<tr>
					<td style="padding-right: 2em; vertical-align: top">
						<a href="../OpenID/Auth_OpenID_SuccessResponse.html">Auth_OpenID_SuccessResponse</a>
					</td>
					<td>
											A response with a status of Auth_OpenID_SUCCESS. Indicates that
										</td>
				</tr>
								<tr>
					<td style="padding-right: 2em; vertical-align: top">
						<a href="../OpenID/Auth_OpenID_FailureResponse.html">Auth_OpenID_FailureResponse</a>
					</td>
					<td>
											A response with a status of Auth_OpenID_FAILURE. Indicates that the  OpenID protocol has failed. This could be locally or remotely  triggered.  This has three relevant attributes:
										</td>
				</tr>
								<tr>
					<td style="padding-right: 2em; vertical-align: top">
						<a href="../OpenID/Auth_OpenID_TypeURIMismatch.html">Auth_OpenID_TypeURIMismatch</a>
					</td>
					<td>
											A specific, internal failure used to detect type URI mismatch.
										</td>
				</tr>
								<tr>
					<td style="padding-right: 2em; vertical-align: top">
						<a href="../OpenID/Auth_OpenID_ServerErrorContainer.html">Auth_OpenID_ServerErrorContainer</a>
					</td>
					<td>
											Exception that is raised when the server returns a 400 response  code to a direct request.
										</td>
				</tr>
								<tr>
					<td style="padding-right: 2em; vertical-align: top">
						<a href="../OpenID/Auth_OpenID_CancelResponse.html">Auth_OpenID_CancelResponse</a>
					</td>
					<td>
											A response with a status of Auth_OpenID_CANCEL. Indicates that the  user cancelled the OpenID authentication request.  This has two  relevant attributes:
										</td>
				</tr>
								<tr>
					<td style="padding-right: 2em; vertical-align: top">
						<a href="../OpenID/Auth_OpenID_SetupNeededResponse.html">Auth_OpenID_SetupNeededResponse</a>
					</td>
					<td>
											A response with a status of Auth_OpenID_SETUP_NEEDED. Indicates  that the request was in immediate mode, and the server is unable to  authenticate the user without further interaction.
										</td>
				</tr>
							</table>
		</div>
	</div>

	<a name="sec-includes"></a>	
	<div class="info-box">
		<div class="info-box-title">Includes</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
							<a href="#sec-classes">Classes</a>
				|						<span class="disabled">Includes</span>
			|							<a href="#sec-constants">Constants</a>
				|													<a href="#sec-functions">Functions</a>
					</div>
		<div class="info-box-body">	
			<a name="_Auth/OpenID/Nonce_php"><!-- --></a>
<div class="oddrow">
	
	<div>
		<span class="include-title">
			<span class="include-type">require_once</span>
			(<span class="include-name"><a href="../OpenID/_Auth---OpenID---Nonce.php.html">"Auth/OpenID/Nonce.php"</a></span>)
			(line <span class="line-number">170</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	
</div>
<a name="_Auth/OpenID/DiffieHellman_php"><!-- --></a>
<div class="evenrow">
	
	<div>
		<span class="include-title">
			<span class="include-type">require_once</span>
			(<span class="include-name">"Auth/OpenID/DiffieHellman.php"</span>)
			(line <span class="line-number">168</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	
</div>
<a name="_Auth/OpenID/KVForm_php"><!-- --></a>
<div class="oddrow">
	
	<div>
		<span class="include-title">
			<span class="include-type">require_once</span>
			(<span class="include-name">"Auth/OpenID/KVForm.php"</span>)
			(line <span class="line-number">169</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	
</div>
<a name="_Auth/OpenID_php"><!-- --></a>
<div class="evenrow">
	
	<div>
		<span class="include-title">
			<span class="include-type">require_once</span>
			(<span class="include-name"><a href="../OpenID/_Auth---OpenID.php.html">"Auth/OpenID.php"</a></span>)
			(line <span class="line-number">163</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Require utility classes and functions for the consumer.</p>
	
</div>
<a name="_Auth/OpenID/CryptUtil_php"><!-- --></a>
<div class="oddrow">
	
	<div>
		<span class="include-title">
			<span class="include-type">require_once</span>
			(<span class="include-name">"Auth/OpenID/CryptUtil.php"</span>)
			(line <span class="line-number">167</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	
</div>
<a name="_Auth/OpenID/Discover_php"><!-- --></a>
<div class="evenrow">
	
	<div>
		<span class="include-title">
			<span class="include-type">require_once</span>
			(<span class="include-name">"Auth/OpenID/Discover.php"</span>)
			(line <span class="line-number">171</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	
</div>
<a name="_Auth/Yadis/XRI_php"><!-- --></a>
<div class="oddrow">
	
	<div>
		<span class="include-title">
			<span class="include-type">require_once</span>
			(<span class="include-name">"Auth/Yadis/XRI.php"</span>)
			(line <span class="line-number">173</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	
</div>
<a name="_Auth/Yadis/Manager_php"><!-- --></a>
<div class="evenrow">
	
	<div>
		<span class="include-title">
			<span class="include-type">require_once</span>
			(<span class="include-name"><a href="../OpenID/_Auth---Yadis---Manager.php.html">"Auth/Yadis/Manager.php"</a></span>)
			(line <span class="line-number">172</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	
</div>
<a name="_Auth/OpenID/Association_php"><!-- --></a>
<div class="oddrow">
	
	<div>
		<span class="include-title">
			<span class="include-type">require_once</span>
			(<span class="include-name"><a href="../OpenID/_Auth---OpenID---Association.php.html">"Auth/OpenID/Association.php"</a></span>)
			(line <span class="line-number">166</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	
</div>
<a name="_Auth/OpenID/HMACSHA1_php"><!-- --></a>
<div class="evenrow">
	
	<div>
		<span class="include-title">
			<span class="include-type">require_once</span>
			(<span class="include-name">"Auth/OpenID/HMACSHA1.php"</span>)
			(line <span class="line-number">165</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	
</div>
<a name="_Auth/OpenID/Message_php"><!-- --></a>
<div class="oddrow">
	
	<div>
		<span class="include-title">
			<span class="include-type">require_once</span>
			(<span class="include-name"><a href="../OpenID/_Auth---OpenID---Message.php.html">"Auth/OpenID/Message.php"</a></span>)
			(line <span class="line-number">164</span>)
		</span>
	</div>

	<!-- ========== Info from phpDoc block ========= -->
	
</div>
		</div>
	</div>
	
	<a name="sec-constants"></a>	
	<div class="info-box">
		<div class="info-box-title">Constants</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
							<a href="#sec-classes">Classes</a>
				|										<a href="#sec-includes">Includes</a>
				|						<span class="disabled">Constants</span>
			|										<a href="#sec-functions">Functions</a>
					</div>
		<div class="info-box-body">	
			<a name="defineAuth_OpenID_CANCEL"><!-- --></a>
<div class="evenrow">
	
	<div>
		<span class="const-title">
			<span class="const-name">Auth_OpenID_CANCEL</span> = 'cancel'
			(line <span class="line-number">184</span>)
		</span>
	</div>
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Status to indicate cancellation of OpenID authentication.</p>
	
		
</div>
<a name="defineAuth_OpenID_FAILURE"><!-- --></a>
<div class="oddrow">
	
	<div>
		<span class="const-title">
			<span class="const-name">Auth_OpenID_FAILURE</span> = 'failure'
			(line <span class="line-number">190</span>)
		</span>
	</div>
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">This is the status code completeAuth returns when the value it  received indicated an invalid login.</p>
	
		
</div>
<a name="defineAuth_OpenID_PARSE_ERROR"><!-- --></a>
<div class="evenrow">
	
	<div>
		<span class="const-title">
			<span class="const-name">Auth_OpenID_PARSE_ERROR</span> = 'parse error'
			(line <span class="line-number">205</span>)
		</span>
	</div>
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">This is the status code beginAuth returns when the page fetched  from the entered OpenID URL doesn't contain the necessary link tags  to function as an identity page.</p>
	
		
</div>
<a name="defineAuth_OpenID_SETUP_NEEDED"><!-- --></a>
<div class="oddrow">
	
	<div>
		<span class="const-title">
			<span class="const-name">Auth_OpenID_SETUP_NEEDED</span> = 'setup needed'
			(line <span class="line-number">198</span>)
		</span>
	</div>
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">This is the status code completeAuth returns when the  <a href="../OpenID/Auth_OpenID_Consumer.html">Auth_OpenID_Consumer</a> instance is in immediate mode, and the  identity server sends back a URL to send the user to to complete his  or her login.</p>
	
		
</div>
<a name="defineAuth_OpenID_SUCCESS"><!-- --></a>
<div class="evenrow">
	
	<div>
		<span class="const-title">
			<span class="const-name">Auth_OpenID_SUCCESS</span> = 'success'
			(line <span class="line-number">179</span>)
		</span>
	</div>
	
	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">This is the status code returned when the complete method returns  successfully.</p>
	
		
</div>
		</div>
	</div>
	
	
	<a name="sec-functions"></a>	
	<div class="info-box">
		<div class="info-box-title">Functions</div>
		<div class="nav-bar">
			<a href="#sec-description">Description</a> |
							<a href="#sec-classes">Classes</a>
				|										<a href="#sec-includes">Includes</a>
				|										<a href="#sec-constants">Constants</a>
				|									<span class="disabled">Functions</span>
		</div>
		<div class="info-box-body">	
			<a name="functionAuth_OpenID_getAvailableSessionTypes" id="functionAuth_OpenID_getAvailableSessionTypes"><!-- --></a>
<div class="oddrow">
	
	<div>
		<span class="method-title">Auth_OpenID_getAvailableSessionTypes</span> (line <span class="line-number">542</span>)
	</div> 

	<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Returns available session types.</p>
	
	<div class="method-signature">
		<span class="method-result">void</span>
		<span class="method-name">
			Auth_OpenID_getAvailableSessionTypes
		</span>
				()
			</div>

		
	
</div>
		</div>
	</div>
	
	<p class="notes" id="credit">
		Documentation generated on Wed, 05 Dec 2007 14:02:11 -0800 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.3.2</a>
	</p>
	</div></body>
</html>