openid.api.php 3.3 KB

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