DumbStore.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * This file supplies a dumb store backend for OpenID servers and
  4. * consumers.
  5. *
  6. * PHP versions 4 and 5
  7. *
  8. * LICENSE: See the COPYING file included in this distribution.
  9. *
  10. * @package OpenID
  11. * @author JanRain, Inc. <openid@janrain.com>
  12. * @copyright 2005-2008 Janrain, Inc.
  13. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache
  14. */
  15. /**
  16. * Import the interface for creating a new store class.
  17. */
  18. require_once 'Auth/OpenID/Interface.php';
  19. require_once 'Auth/OpenID/HMAC.php';
  20. /**
  21. * This is a store for use in the worst case, when you have no way of
  22. * saving state on the consumer site. Using this store makes the
  23. * consumer vulnerable to replay attacks, as it's unable to use
  24. * nonces. Avoid using this store if it is at all possible.
  25. *
  26. * Most of the methods of this class are implementation details.
  27. * Users of this class need to worry only about the constructor.
  28. *
  29. * @package OpenID
  30. */
  31. class Auth_OpenID_DumbStore extends Auth_OpenID_OpenIDStore {
  32. /**
  33. * Creates a new {@link Auth_OpenID_DumbStore} instance. For the security
  34. * of the tokens generated by the library, this class attempts to
  35. * at least have a secure implementation of getAuthKey.
  36. *
  37. * When you create an instance of this class, pass in a secret
  38. * phrase. The phrase is hashed with sha1 to make it the correct
  39. * length and form for an auth key. That allows you to use a long
  40. * string as the secret phrase, which means you can make it very
  41. * difficult to guess.
  42. *
  43. * Each {@link Auth_OpenID_DumbStore} instance that is created for use by
  44. * your consumer site needs to use the same $secret_phrase.
  45. *
  46. * @param string secret_phrase The phrase used to create the auth
  47. * key returned by getAuthKey
  48. */
  49. function Auth_OpenID_DumbStore($secret_phrase)
  50. {
  51. $this->auth_key = Auth_OpenID_SHA1($secret_phrase);
  52. }
  53. /**
  54. * This implementation does nothing.
  55. */
  56. function storeAssociation($server_url, $association)
  57. {
  58. }
  59. /**
  60. * This implementation always returns null.
  61. */
  62. function getAssociation($server_url, $handle = null)
  63. {
  64. return null;
  65. }
  66. /**
  67. * This implementation always returns false.
  68. */
  69. function removeAssociation($server_url, $handle)
  70. {
  71. return false;
  72. }
  73. /**
  74. * In a system truly limited to dumb mode, nonces must all be
  75. * accepted. This therefore always returns true, which makes
  76. * replay attacks feasible.
  77. */
  78. function useNonce($server_url, $timestamp, $salt)
  79. {
  80. return true;
  81. }
  82. /**
  83. * This method returns the auth key generated by the constructor.
  84. */
  85. function getAuthKey()
  86. {
  87. return $this->auth_key;
  88. }
  89. }