root / drupal7 / modules / openid / openid.api.php @ db2d93dd
1 |
<?php
|
---|---|
2 |
|
3 |
/**
|
4 |
* @file
|
5 |
* Hooks provided by the OpenID module.
|
6 |
*/
|
7 |
|
8 |
/**
|
9 |
* @addtogroup hooks
|
10 |
* @{
|
11 |
*/
|
12 |
|
13 |
/**
|
14 |
* Allow modules to modify the OpenID request parameters.
|
15 |
*
|
16 |
* @param $op
|
17 |
* The operation to be performed.
|
18 |
* Possible values:
|
19 |
* - request: Modify parameters before they are sent to the OpenID provider.
|
20 |
* @param $request
|
21 |
* An associative array of parameter defaults to which to modify or append.
|
22 |
* @return
|
23 |
* An associative array of parameters to be merged with the default list.
|
24 |
*
|
25 |
*/
|
26 |
function hook_openid($op, $request) { |
27 |
if ($op == 'request') { |
28 |
$request['openid.identity'] = 'http://myname.myopenid.com/'; |
29 |
} |
30 |
return $request; |
31 |
} |
32 |
|
33 |
/**
|
34 |
* Allow modules to act upon a successful OpenID login.
|
35 |
*
|
36 |
* @param $response
|
37 |
* Response values from the OpenID Provider.
|
38 |
* @param $account
|
39 |
* The Drupal user account that logged in
|
40 |
*
|
41 |
*/
|
42 |
function hook_openid_response($response, $account) { |
43 |
if (isset($response['openid.ns.ax'])) { |
44 |
_mymodule_store_ax_fields($response, $account); |
45 |
} |
46 |
} |
47 |
|
48 |
/**
|
49 |
* Allow modules to declare OpenID discovery methods.
|
50 |
*
|
51 |
* The discovery function callbacks will be called in turn with an unique
|
52 |
* parameter, the claimed identifier. They have to return an associative array
|
53 |
* with array of services and claimed identifier in the same form as returned by
|
54 |
* openid_discover(). The resulting array must contain following keys:
|
55 |
* - 'services' (required) an array of discovered services (including OpenID
|
56 |
* version, endpoint URI, etc).
|
57 |
* - 'claimed_id' (optional) new claimed identifer, found by following HTTP
|
58 |
* redirects during the services discovery.
|
59 |
*
|
60 |
* The first discovery method that succeed (return at least one services) will
|
61 |
* stop the discovery process.
|
62 |
*
|
63 |
* @return
|
64 |
* An associative array which keys are the name of the discovery methods and
|
65 |
* values are function callbacks.
|
66 |
*
|
67 |
* @see hook_openid_discovery_method_info_alter()
|
68 |
*/
|
69 |
function hook_openid_discovery_method_info() { |
70 |
return array( |
71 |
'new_discovery_idea' => '_my_discovery_method', |
72 |
); |
73 |
} |
74 |
|
75 |
/**
|
76 |
* Allow modules to alter discovery methods.
|
77 |
*/
|
78 |
function hook_openid_discovery_method_info_alter(&$methods) { |
79 |
// Remove XRI discovery scheme.
|
80 |
unset($methods['xri']); |
81 |
} |
82 |
|
83 |
/**
|
84 |
* Allow modules to declare OpenID normalization methods.
|
85 |
*
|
86 |
* The discovery function callbacks will be called in turn with an unique
|
87 |
* parameter, the identifier to normalize. They have to return a normalized
|
88 |
* identifier, or NULL if the identifier is not in a form they can handle.
|
89 |
*
|
90 |
* The first normalization method that succeed (return a value that is not NULL)
|
91 |
* will stop the normalization process.
|
92 |
*
|
93 |
* @return
|
94 |
* An array with a set of function callbacks, that will be called in turn
|
95 |
* when normalizing an OpenID identifier. The normalization functions have
|
96 |
* to return a normalized identifier, or NULL if the identifier is not in
|
97 |
* a form they can handle.
|
98 |
* @see hook_openid_normalization_method_info_alter()
|
99 |
*/
|
100 |
function hook_openid_normalization_method_info() { |
101 |
return array( |
102 |
'new_normalization_idea' => '_my_normalization_method', |
103 |
); |
104 |
} |
105 |
|
106 |
/**
|
107 |
* Allow modules to alter normalization methods.
|
108 |
*/
|
109 |
function hook_openid_normalization_method_info_alter(&$methods) { |
110 |
// Remove Google IDP normalization.
|
111 |
unset($methods['google_idp']); |
112 |
} |
113 |
|
114 |
/**
|
115 |
* @} End of "addtogroup hooks".
|
116 |
*/
|