Jump to content

hackalive

Members
  • Posts

    652
  • Joined

  • Last visited

Everything posted by hackalive

  1. Apologies if I offended you or anyone else.
  2. And forever shall it never be answered in the forgotten misc section of general discussions. Here's to hoping thats not the case.
  3. Hi guys, Many of you are saying use oAuth code that works. So the hunt is on - oAuth2 PHP code does not use stuff like Composer or Zend frameworks and WORKS! Im sick of and frankly so are you of hearing of oAuth2 related issues form me. So please lend us a hand Cheers
  4. Hi ignace, I am being the oAuth provider. Can you suggest works out of the box oAuth? That is PHP and dosent need Composer etc? Yet to find one. Cheer
  5. I do understand WHY its doing it: Because class OAuth2StoragePDO is missing some functions from the interface and extends, but HOW do I resolve it? Im very confused as to where to go from here and what to do.
  6. I was kinda hoping for some more direct advice - reading http://php.net/manual/en/language.oop5.abstract.php so far is not really giving me any ideas on what to do.
  7. Doing the above returns Fatal error: Cannot instantiate abstract class OAuth2StoragePDO in A:\public\index.php on line 19 so that dosent work anyway. How can I fix this? This is really annoying me now ... grrrrr :/ Code of oAuth2StoragePdo.php <?php /** * @file * Sample OAuth2 Library PDO DB Implementation. * * Simply pass in a configured PDO class, eg: * new PDOOAuth2( new PDO('mysql:dbname=mydb;host=localhost', 'user', 'pass') ); */ //namespace OAuth2; require 'OAuth2/IOAuth2GrantCode.php'; require 'OAuth2/IOAuth2RefreshTokens.php'; /** * PDO storage engine for the OAuth2 Library. */ class OAuth2StoragePDO implements IOAuth2GrantCode, IOAuth2RefreshTokens { /**@#+ * Centralized table names * * @var string */ const TABLE_CLIENTS = 'clients'; const TABLE_CODES = 'auth_codes'; const TABLE_TOKENS = 'access_tokens'; const TABLE_REFRESH = 'refresh_tokens'; /**@#-*/ /** * @var PDO */ private $db; /** * @var string */ private $salt; /** * Implements OAuth2::__construct(). */ public function __construct(PDO $db, $salt = 'CHANGE_ME!') { $this->db = $db; } /** * Handle PDO exceptional cases. */ private function handleException($e) { throw $e; } /** * Little helper function to add a new client to the database. * * Do NOT use this in production! This sample code stores the secret * in plaintext! * * @param $client_id * Client identifier to be stored. * @param $client_secret * Client secret to be stored. * @param $redirect_uri * Redirect URI to be stored. */ public function addClient($client_id, $client_secret, $redirect_uri) { try { $client_secret = $this->hash($client_secret, $client_id); $sql = 'INSERT INTO '.self::TABLE_CLIENTS.' (client_id, client_secret, redirect_uri) VALUES (:client_id, :client_secret, :redirect_uri)'; $stmt = $this->db->prepare($sql); $stmt->bindParam(':client_id', $client_id, PDO::PARAM_STR); $stmt->bindParam(':client_secret', $client_secret, PDO::PARAM_STR); $stmt->bindParam(':redirect_uri', $redirect_uri, PDO::PARAM_STR); $stmt->execute(); } catch (PDOException $e) { $this->handleException($e); } } /** * Implements IOAuth2Storage::checkClientCredentials(). * */ public function checkClientCredentials(IOAuth2Client $client_id, $client_secret = NULL) { try { $sql = 'SELECT client_secret FROM '.self::TABLE_CLIENTS.' WHERE client_id = :client_id'; $stmt = $this->db->prepare($sql); $stmt->bindParam(':client_id', $client_id, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); if ($client_secret === NULL) return $result !== FALSE; return $this->checkPassword($client_secret, $result['client_secret'], $client_id); } catch (PDOException $e) { $this->handleException($e); } } /** * Implements IOAuth2Storage::getRedirectUri(). */ public function getClientDetails($client_id) { try { $sql = 'SELECT redirect_uri FROM '.self::TABLE_CLIENTS.' WHERE client_id = :client_id'; $stmt = $this->db->prepare($sql); $stmt->bindParam(':client_id', $client_id, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); if ($result === FALSE) return FALSE; return isset($result['redirect_uri']) && $result['redirect_uri'] ? $result : NULL; } catch (PDOException $e) { $this->handleException($e); } } /** * Implements IOAuth2Storage::getAccessToken(). */ public function getAccessToken($oauth_token) { return $this->getToken($oauth_token, FALSE); } /** * Implements IOAuth2Storage::setAccessToken(). */ public function setAccessToken($oauth_token, $client_id, $user_id, $expires, $scope = NULL) { $this->setToken($oauth_token, $client_id, $user_id, $expires, $scope, FALSE); } /** * @see IOAuth2Storage::getRefreshToken() */ public function getRefreshToken($refresh_token) { return $this->getToken($refresh_token, TRUE); } /** * @see IOAuth2Storage::setRefreshToken() */ public function setRefreshToken($refresh_token, $client_id, $user_id, $expires, $scope = NULL) { return $this->setToken($refresh_token, $client_id, $user_id, $expires, $scope, TRUE); } /** * @see IOAuth2Storage::unsetRefreshToken() */ public function unsetRefreshToken($refresh_token) { try { $sql = 'DELETE FROM '.self::TABLE_TOKENS.' WHERE refresh_token = :refresh_token'; $stmt = $this->db->prepare($sql); $stmt->bindParam(':refresh_token', $refresh_token, PDO::PARAM_STR); $stmt->execute(); } catch (PDOException $e) { $this->handleException($e); } } /** * Implements IOAuth2Storage::getAuthCode(). */ public function getAuthCode($code) { try { $sql = 'SELECT code, client_id, user_id, redirect_uri, expires, scope FROM '.self::TABLE_CODES.' auth_codes WHERE code = :code'; $stmt = $this->db->prepare($sql); $stmt->bindParam(':code', $code, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result !== FALSE ? $result : NULL; } catch (PDOException $e) { $this->handleException($e); } } /** * Implements IOAuth2Storage::setAuthCode(). */ public function setAuthCode($code, $client_id, $user_id, $redirect_uri, $expires, $scope = NULL) { try { $sql = 'INSERT INTO '.self::TABLE_CODES.' (code, client_id, user_id, redirect_uri, expires, scope) VALUES (:code, :client_id, :user_id, :redirect_uri, :expires, :scope)'; $stmt = $this->db->prepare($sql); $stmt->bindParam(':code', $code, PDO::PARAM_STR); $stmt->bindParam(':client_id', $client_id, PDO::PARAM_STR); $stmt->bindParam(':user_id', $user_id, PDO::PARAM_STR); $stmt->bindParam(':redirect_uri', $redirect_uri, PDO::PARAM_STR); $stmt->bindParam(':expires', $expires, PDO::PARAM_INT); $stmt->bindParam(':scope', $scope, PDO::PARAM_STR); $stmt->execute(); } catch (PDOException $e) { $this->handleException($e); } } /** * @see IOAuth2Storage::checkRestrictedGrantType() */ public function checkRestrictedGrantType(IOAuth2Client $client_id, $grant_type) { return TRUE; // Not implemented } /** * Creates a refresh or access token * * @param string $token - Access or refresh token id * @param string $client_id * @param mixed $user_id * @param int $expires * @param string $scope * @param bool $isRefresh */ protected function setToken($token, $client_id, $user_id, $expires, $scope, $isRefresh = TRUE) { try { $tableName = $isRefresh ? self::TABLE_REFRESH : self::TABLE_TOKENS; $sql = "INSERT INTO $tableName (oauth_token, client_id, user_id, expires, scope) VALUES (:token, :client_id, :user_id, :expires, :scope)"; $stmt = $this->db->prepare($sql); $stmt->bindParam(':token', $token, PDO::PARAM_STR); $stmt->bindParam(':client_id', $client_id, PDO::PARAM_STR); $stmt->bindParam(':user_id', $user_id, PDO::PARAM_STR); $stmt->bindParam(':expires', $expires, PDO::PARAM_INT); $stmt->bindParam(':scope', $scope, PDO::PARAM_STR); $stmt->execute(); } catch (PDOException $e) { $this->handleException($e); } } /** * Retrieves an access or refresh token. * * @param string $token * @param bool $refresh */ protected function getToken($token, $isRefresh = true) { try { $tableName = $isRefresh ? self::TABLE_REFRESH : self::TABLE_TOKENS; $tokenName = $isRefresh ? 'refresh_token' : 'oauth_token'; $sql = "SELECT oauth_token AS $tokenName, client_id, expires, scope, user_id FROM $tableName WHERE oauth_token = :token"; $stmt = $this->db->prepare($sql); $stmt->bindParam(':token', $token, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result !== FALSE ? $result : NULL; } catch (PDOException $e) { $this->handleException($e); } } /** * Change/override this to whatever your own password hashing method is. * * @param string $secret * @return string */ protected function hash($client_secret, $client_id) { return hash('sha1', $client_id.$client_secret.$this->salt); } /** * Checks the password. * Override this if you need to * * @param string $client_id * @param string $client_secret * @param string $actualPassword */ protected function checkPassword($try, $client_secret, $client_id) { return $client_secret == $this->hash($try, $client_id); } }
  8. I added the IOAuth2Client where it needed to be in OAuth2StoragePdo.php but now im getting this http://www.phpfreaks.com/forums/index.php?topic=361124.0 which you have helped me with but I still have not managed to resolve.
  9. So currently OAuth2StoragePDO is like this: class OAuth2StoragePDO implements IOAuth2GrantCode, IOAuth2RefreshTokens { Are you saying make it abstract class OAuth2StoragePDO implements IOAuth2GrantCode, IOAuth2RefreshTokens { ?
  10. Hi guys, What does this error mean: Fatal error: Class OAuth2StoragePDO contains 4 abstract methods and must therefore be declared abstract or implement the remaining methods (IOAuth2GrantCode::createAuthCode, IOAuth2Storage::getClient, IOAuth2Storage::createAccessToken, ...) in A:\public\lib\OAuth2StoragePdo.php on line 288 and how do I resolve it? Cheers
  11. Hi Guys, Managed to resolve most my oAuth issues. I am suing this library https://github.com/vbardales/oauth2-php - except im removing its reliance on Composer. However - I am having an issue. I get this error: Fatal error: Declaration of OAuth2\OAuth2StoragePDO::checkClientCredentials() must be compatible with that of OAuth2\IOAuth2Storage::checkClientCredentials() in A:\public\lib\OAuth2StoragePdo.php on line 19 when you visit protected_resource.php (PDO). Any ideas why this error occurs? Whats its reasoning? Code for OAuth2StoragePDO <?php /** * @file * Sample OAuth2 Library PDO DB Implementation. * * Simply pass in a configured PDO class, eg: * new PDOOAuth2( new PDO('mysql:dbname=mydb;host=localhost', 'user', 'pass') ); */ namespace OAuth2; require 'OAuth2/IOAuth2GrantCode.php'; require 'OAuth2/IOAuth2RefreshTokens.php'; /** * PDO storage engine for the OAuth2 Library. */ class OAuth2StoragePDO implements IOAuth2GrantCode, IOAuth2RefreshTokens { /**@#+ * Centralized table names * * @var string */ const TABLE_CLIENTS = 'clients'; const TABLE_CODES = 'auth_codes'; const TABLE_TOKENS = 'access_tokens'; const TABLE_REFRESH = 'refresh_tokens'; /**@#-*/ /** * @var PDO */ private $db; /** * @var string */ private $salt; /** * Implements OAuth2::__construct(). */ public function __construct(PDO $db, $salt = 'CHANGE_ME!') { $this->db = $db; } /** * Handle PDO exceptional cases. */ private function handleException($e) { throw $e; } /** * Little helper function to add a new client to the database. * * Do NOT use this in production! This sample code stores the secret * in plaintext! * * @param $client_id * Client identifier to be stored. * @param $client_secret * Client secret to be stored. * @param $redirect_uri * Redirect URI to be stored. */ public function addClient($client_id, $client_secret, $redirect_uri) { try { $client_secret = $this->hash($client_secret, $client_id); $sql = 'INSERT INTO '.self::TABLE_CLIENTS.' (client_id, client_secret, redirect_uri) VALUES (:client_id, :client_secret, :redirect_uri)'; $stmt = $this->db->prepare($sql); $stmt->bindParam(':client_id', $client_id, PDO::PARAM_STR); $stmt->bindParam(':client_secret', $client_secret, PDO::PARAM_STR); $stmt->bindParam(':redirect_uri', $redirect_uri, PDO::PARAM_STR); $stmt->execute(); } catch (PDOException $e) { $this->handleException($e); } } /** * Implements IOAuth2Storage::checkClientCredentials(). * */ public function checkClientCredentials($client_id, $client_secret = NULL) { try { $sql = 'SELECT client_secret FROM '.self::TABLE_CLIENTS.' WHERE client_id = :client_id'; $stmt = $this->db->prepare($sql); $stmt->bindParam(':client_id', $client_id, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); if ($client_secret === NULL) return $result !== FALSE; return $this->checkPassword($client_secret, $result['client_secret'], $client_id); } catch (PDOException $e) { $this->handleException($e); } } /** * Implements IOAuth2Storage::getRedirectUri(). */ public function getClientDetails($client_id) { try { $sql = 'SELECT redirect_uri FROM '.self::TABLE_CLIENTS.' WHERE client_id = :client_id'; $stmt = $this->db->prepare($sql); $stmt->bindParam(':client_id', $client_id, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); if ($result === FALSE) return FALSE; return isset($result['redirect_uri']) && $result['redirect_uri'] ? $result : NULL; } catch (PDOException $e) { $this->handleException($e); } } /** * Implements IOAuth2Storage::getAccessToken(). */ public function getAccessToken($oauth_token) { return $this->getToken($oauth_token, FALSE); } /** * Implements IOAuth2Storage::setAccessToken(). */ public function setAccessToken($oauth_token, $client_id, $user_id, $expires, $scope = NULL) { $this->setToken($oauth_token, $client_id, $user_id, $expires, $scope, FALSE); } /** * @see IOAuth2Storage::getRefreshToken() */ public function getRefreshToken($refresh_token) { return $this->getToken($refresh_token, TRUE); } /** * @see IOAuth2Storage::setRefreshToken() */ public function setRefreshToken($refresh_token, $client_id, $user_id, $expires, $scope = NULL) { return $this->setToken($refresh_token, $client_id, $user_id, $expires, $scope, TRUE); } /** * @see IOAuth2Storage::unsetRefreshToken() */ public function unsetRefreshToken($refresh_token) { try { $sql = 'DELETE FROM '.self::TABLE_TOKENS.' WHERE refresh_token = :refresh_token'; $stmt = $this->db->prepare($sql); $stmt->bindParam(':refresh_token', $refresh_token, PDO::PARAM_STR); $stmt->execute(); } catch (PDOException $e) { $this->handleException($e); } } /** * Implements IOAuth2Storage::getAuthCode(). */ public function getAuthCode($code) { try { $sql = 'SELECT code, client_id, user_id, redirect_uri, expires, scope FROM '.self::TABLE_CODES.' auth_codes WHERE code = :code'; $stmt = $this->db->prepare($sql); $stmt->bindParam(':code', $code, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result !== FALSE ? $result : NULL; } catch (PDOException $e) { $this->handleException($e); } } /** * Implements IOAuth2Storage::setAuthCode(). */ public function setAuthCode($code, $client_id, $user_id, $redirect_uri, $expires, $scope = NULL) { try { $sql = 'INSERT INTO '.self::TABLE_CODES.' (code, client_id, user_id, redirect_uri, expires, scope) VALUES (:code, :client_id, :user_id, :redirect_uri, :expires, :scope)'; $stmt = $this->db->prepare($sql); $stmt->bindParam(':code', $code, PDO::PARAM_STR); $stmt->bindParam(':client_id', $client_id, PDO::PARAM_STR); $stmt->bindParam(':user_id', $user_id, PDO::PARAM_STR); $stmt->bindParam(':redirect_uri', $redirect_uri, PDO::PARAM_STR); $stmt->bindParam(':expires', $expires, PDO::PARAM_INT); $stmt->bindParam(':scope', $scope, PDO::PARAM_STR); $stmt->execute(); } catch (PDOException $e) { $this->handleException($e); } } /** * @see IOAuth2Storage::checkRestrictedGrantType() */ public function checkRestrictedGrantType($client_id, $grant_type) { return TRUE; // Not implemented } /** * Creates a refresh or access token * * @param string $token - Access or refresh token id * @param string $client_id * @param mixed $user_id * @param int $expires * @param string $scope * @param bool $isRefresh */ protected function setToken($token, $client_id, $user_id, $expires, $scope, $isRefresh = TRUE) { try { $tableName = $isRefresh ? self::TABLE_REFRESH : self::TABLE_TOKENS; $sql = "INSERT INTO $tableName (oauth_token, client_id, user_id, expires, scope) VALUES (:token, :client_id, :user_id, :expires, :scope)"; $stmt = $this->db->prepare($sql); $stmt->bindParam(':token', $token, PDO::PARAM_STR); $stmt->bindParam(':client_id', $client_id, PDO::PARAM_STR); $stmt->bindParam(':user_id', $user_id, PDO::PARAM_STR); $stmt->bindParam(':expires', $expires, PDO::PARAM_INT); $stmt->bindParam(':scope', $scope, PDO::PARAM_STR); $stmt->execute(); } catch (PDOException $e) { $this->handleException($e); } } /** * Retrieves an access or refresh token. * * @param string $token * @param bool $refresh */ protected function getToken($token, $isRefresh = true) { try { $tableName = $isRefresh ? self::TABLE_REFRESH : self::TABLE_TOKENS; $tokenName = $isRefresh ? 'refresh_token' : 'oauth_token'; $sql = "SELECT oauth_token AS $tokenName, client_id, expires, scope, user_id FROM $tableName WHERE oauth_token = :token"; $stmt = $this->db->prepare($sql); $stmt->bindParam(':token', $token, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result !== FALSE ? $result : NULL; } catch (PDOException $e) { $this->handleException($e); } } /** * Change/override this to whatever your own password hashing method is. * * @param string $secret * @return string */ protected function hash($client_secret, $client_id) { return hash('sha1', $client_id.$client_secret.$this->salt); } /** * Checks the password. * Override this if you need to * * @param string $client_id * @param string $client_secret * @param string $actualPassword */ protected function checkPassword($try, $client_secret, $client_id) { return $client_secret == $this->hash($try, $client_id); } } AND IOAuth2Storage.php <?php namespace OAuth2; require_once 'Model/IOAuth2Client.php'; /** * All storage engines need to implement this interface in order to use OAuth2 server * * @author David Rochwerger <catch.dave@gmail.com> */ interface IOAuth2Storage { /** * @return IOAuth2Client */ public function getClient($client_id); /** * Make sure that the client credentials is valid. * * @param $client_id * Client identifier to be check with. * @param $client_secret * (optional) If a secret is required, check that they've given the right one. * * @return * TRUE if the client credentials are valid, and MUST return FALSE if it isn't. * @endcode * * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-20#section-3.1 * * @ingroup oauth2_section_3 */ public function checkClientCredentials(IOAuth2Client $client, $client_secret = NULL); /** * Look up the supplied oauth_token from storage. * * We need to retrieve access token data as we create and verify tokens. * * @param $oauth_token * oauth_token to be check with. * * @return IOAuth2AccessToken * * @ingroup oauth2_section_7 */ public function getAccessToken($oauth_token); /** * Store the supplied access token values to storage. * * We need to store access token data as we create and verify tokens. * * @param $oauth_token * oauth_token to be stored. * @param $client_id * Client identifier to be stored. * @param $user_id * User identifier to be stored. * @param $expires * Expiration to be stored. * @param $scope * (optional) Scopes to be stored in space-separated string. * * @ingroup oauth2_section_4 */ public function createAccessToken($oauth_token, IOAuth2Client $client, $data, $expires, $scope = NULL); /** * Check restricted grant types of corresponding client identifier. * * If you want to restrict clients to certain grant types, override this * function. * * @param IOAuth2Client $client * Client to be check with. * @param $grant_type * Grant type to be check with, would be one of the values contained in * OAuth2::GRANT_TYPE_REGEXP. * * @return * TRUE if the grant type is supported by this client identifier, and * FALSE if it isn't. * * @ingroup oauth2_section_4 */ public function checkRestrictedGrantType(IOAuth2Client $client, $grant_type); } Many many thanks in advance. UPDATE: Someone suggested remove namespaces - so I did - error is now Fatal error: Declaration of OAuth2StoragePDO::checkClientCredentials() must be compatible with that of IOAuth2Storage::checkClientCredentials() in A:\public\lib\OAuth2StoragePdo.php on line 19
  12. Hi guys, I am using this oAuth library https://github.com/vbardales/oauth2-php, but have taken out the dependencies on Composer. I have one issue. I keep getting this error (on protected_resource.php PDO). This is the code of IOAuth2GrantCode.php <?php require_once 'Model/IOAuth2Client.php'; require 'OAuth2/IOAuth2Storage.php'; /** * Storage engines that support the "Authorization Code" * grant type should implement this interface * * @author Dave Rochwerger <catch.dave@gmail.com> * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-20#section-4.1 */ interface IOAuth2GrantCode extends IOAuth2Storage { /** * The Authorization Code grant type supports a response type of "code". * * @var string * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-20#section-1.4.1 * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-20#section-4.2 */ const RESPONSE_TYPE_CODE = OAuth2::RESPONSE_TYPE_AUTH_CODE; /** * Fetch authorization code data (probably the most common grant type). * * Retrieve the stored data for the given authorization code. * * Required for OAuth2::GRANT_TYPE_AUTH_CODE. * * @param $code * Authorization code to be check with. * * @return IOAuth2AuthCode * * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-20#section-4.1 * * @ingroup oauth2_section_4 */ public function getAuthCode($code); /** * Take the provided authorization code values and store them somewhere. * * This function should be the storage counterpart to getAuthCode(). * * If storage fails for some reason, we're not currently checking for * any sort of success/failure, so you should bail out of the script * and provide a descriptive fail message. * * Required for OAuth2::GRANT_TYPE_AUTH_CODE. * * @param $code * Authorization code to be stored. * @param IOAuth2Client $client * Client identifier to be stored. * @param $data * Application data * @param $redirect_uri * Redirect URI to be stored. * @param $expires * Expiration to be stored. * @param $scope * (optional) Scopes to be stored in space-separated string. * * @ingroup oauth2_section_4 */ public function createAuthCode($code, IOAuth2Client $client, $data, $redirect_uri, $expires, $scope = NULL); } And the code of IOAuth2Storage.php <?php namespace OAuth2; require_once 'Model/IOAuth2Client.php'; /** * All storage engines need to implement this interface in order to use OAuth2 server * * @author David Rochwerger <catch.dave@gmail.com> */ interface IOAuth2Storage { /** * @return IOAuth2Client */ public function getClient($client_id); /** * Make sure that the client credentials is valid. * * @param $client_id * Client identifier to be check with. * @param $client_secret * (optional) If a secret is required, check that they've given the right one. * * @return * TRUE if the client credentials are valid, and MUST return FALSE if it isn't. * @endcode * * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-20#section-3.1 * * @ingroup oauth2_section_3 */ public function checkClientCredentials(IOAuth2Client $client, $client_secret = NULL); /** * Look up the supplied oauth_token from storage. * * We need to retrieve access token data as we create and verify tokens. * * @param $oauth_token * oauth_token to be check with. * * @return IOAuth2AccessToken * * @ingroup oauth2_section_7 */ public function getAccessToken($oauth_token); /** * Store the supplied access token values to storage. * * We need to store access token data as we create and verify tokens. * * @param $oauth_token * oauth_token to be stored. * @param $client_id * Client identifier to be stored. * @param $user_id * User identifier to be stored. * @param $expires * Expiration to be stored. * @param $scope * (optional) Scopes to be stored in space-separated string. * * @ingroup oauth2_section_4 */ public function createAccessToken($oauth_token, IOAuth2Client $client, $data, $expires, $scope = NULL); /** * Check restricted grant types of corresponding client identifier. * * If you want to restrict clients to certain grant types, override this * function. * * @param IOAuth2Client $client * Client to be check with. * @param $grant_type * Grant type to be check with, would be one of the values contained in * OAuth2::GRANT_TYPE_REGEXP. * * @return * TRUE if the grant type is supported by this client identifier, and * FALSE if it isn't. * * @ingroup oauth2_section_4 */ public function checkRestrictedGrantType(IOAuth2Client $client, $grant_type); } Hopefully its not too hard to solve Many thanks in advance.
  13. I assume you meant switch($data->getMethod()) As that worked Had to change all $data->XX to $data->XX() THANKS VERY MUCH!
  14. Hi guys, When using http://www.gen-x-design.com/archives/create-a-rest-api-with-php/ And implementing this part: $data = RestUtils::processRequest(); switch($data->getMethod) { // this is a request for all users, not one in particular case 'get': $user_list = getUserList(); // assume this returns an array if($data->getHttpAccept == 'json') { RestUtils::sendResponse(200, json_encode($user_list), 'application/json'); } else if ($data->getHttpAccept == 'xml') { // using the XML_SERIALIZER Pear Package $options = array ( 'indent' => ' ', 'addDecl' => false, 'rootName' => $fc->getAction(), XML_SERIALIZER_OPTION_RETURN_RESULT => true ); $serializer = new XML_Serializer($options); RestUtils::sendResponse(200, $serializer->serialize($user_list), 'application/xml'); } break; // new user create case 'post': $user = new User(); $user->setFirstName($data->getData()->first_name); // just for example, this should be done cleaner // and so on... $user->save(); // just send the new ID as the body RestUtils::sendResponse(201, $user->getId()); break; } I get an error; Any ideas why or how I can fix it? Cheers in advance
  15. Why would you need to do that? Deleting the session variable that your code uses to indicate the logged in state is enough. Also, php cannot actually delete a cookie. All you are actually doing is setting the cookie's expire time in the past so that the browser no longer sends it to the server with the page request. The cookie is still present on the client's computer. The only actual way of deleting a cookie is to delete the cookie file by going to the computer and using the browser or the file system to delete it. To 'delete' a cookie you must use the same name, path, domain, secure, and httponly parameters in the setcookie() statement that were used when the cookie was created. Otherwise, you are actually trying to set a different cookie. Of course your going to provide a link to a login script that matches all of this and the db stuff your discussed previously.
  16. How about the stronger bcrypt?
  17. Hi guys, I am looking at using scrypt in my PHP to hash passwords however there are not good PHP libraries for this. However there are some good C libraries and apparently it is best to load vis C rather than PHP because: So how can I take a C library and hash my password through PHP or turn a C library into Assembly then hash via PHP? PS - Was looking at this http://ftp.de.debian.org/debian/pool/main/s/scrypt/scrypt_1.1.6.orig.tar.gz but no idea about it too much, still in research phase. Thanks very much in advance.
  18. Well when I log-out the cookie should delete - it is currently not deleting no matter all the code I try (above). @PFMaBiSmAd If you can provide a link to a script/tutorial for the correct login/logout procedure you outlined before that uses db & sessions/cookies I am more than willing to chuck my code out and use yours. (As a side note what do you think of this http://www.devshed.com/c/a/PHP/Creating-a-Secure-PHP-Login-Script/)
  19. Look at reply #16 - login.php (Issue STILL not resolved).
  20. I have included part of the login process above if you take a look.
  21. As part of the logoff process - like FB does
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.