mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-15 17:56:14 +05:30
Lots of small documentation updates and clarifications
This commit is contained in:
parent
fead044830
commit
958eab33a7
@ -6,30 +6,42 @@ interface Database
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Validate a client
|
* Validate a client
|
||||||
*
|
*
|
||||||
* Database query:
|
* Database query:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* # Client ID + redirect URI
|
* # Client ID + redirect URI
|
||||||
* SELECT clients.id FROM clients LEFT JOIN client_endpoints ON
|
* SELECT clients.id FROM clients LEFT JOIN client_endpoints ON
|
||||||
* client_endpoints.client_id = clients.id WHERE clients.id = $clientId AND
|
* client_endpoints.client_id = clients.id WHERE clients.id = $clientId AND
|
||||||
* client_endpoints.redirect_uri = $redirectUri
|
* client_endpoints.redirect_uri = $redirectUri
|
||||||
*
|
*
|
||||||
* # Client ID + client secret
|
* # Client ID + client secret
|
||||||
* SELECT clients.id FROM clients WHERE clients.id = $clientId AND
|
* SELECT clients.id FROM clients WHERE clients.id = $clientId AND
|
||||||
* clients.secret = $clientSecret
|
* clients.secret = $clientSecret
|
||||||
*
|
*
|
||||||
* # Client ID + client secret + redirect URI
|
* # Client ID + client secret + redirect URI
|
||||||
* SELECT clients.id FROM clients LEFT JOIN client_endpoints ON
|
* SELECT clients.id FROM clients LEFT JOIN client_endpoints ON
|
||||||
* client_endpoints.client_id = clients.id WHERE clients.id = $clientId AND
|
* client_endpoints.client_id = clients.id WHERE clients.id = $clientId AND
|
||||||
* clients.secret = $clientSecret AND client_endpoints.redirect_uri =
|
* clients.secret = $clientSecret AND client_endpoints.redirect_uri =
|
||||||
* $redirectUri
|
* $redirectUri
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param string $clientId The client's ID
|
* Response:
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* Array
|
||||||
|
* (
|
||||||
|
* [client_id] => (string) The client ID
|
||||||
|
* [client secret] => (string) The client secret
|
||||||
|
* [redirect_uri] => (string) The redirect URI used in this request
|
||||||
|
* [name] => (string) The name of the client
|
||||||
|
* )
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @param string $clientId The client's ID
|
||||||
* @param string $clientSecret The client's secret (default = "null")
|
* @param string $clientSecret The client's secret (default = "null")
|
||||||
* @param string $redirectUri The client's redirect URI (default = "null")
|
* @param string $redirectUri The client's redirect URI (default = "null")
|
||||||
* @return [type] [description]
|
* @return bool|array Returns false if the validation fails, array on success
|
||||||
*/
|
*/
|
||||||
public function validateClient(
|
public function validateClient(
|
||||||
$clientId,
|
$clientId,
|
||||||
@ -39,16 +51,16 @@ interface Database
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new OAuth session
|
* Create a new OAuth session
|
||||||
*
|
*
|
||||||
* Database query:
|
* Database query:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* INSERT INTO oauth_sessions (client_id, redirect_uri, owner_type,
|
* INSERT INTO oauth_sessions (client_id, redirect_uri, owner_type,
|
||||||
* owner_id, auth_code, access_token, stage, first_requested, last_updated)
|
* owner_id, auth_code, access_token, stage, first_requested, last_updated)
|
||||||
* VALUES ($clientId, $redirectUri, $type, $typeId, $authCode,
|
* VALUES ($clientId, $redirectUri, $type, $typeId, $authCode,
|
||||||
* $accessToken, $stage, UNIX_TIMESTAMP(NOW()), UNIX_TIMESTAMP(NOW()))
|
* $accessToken, $stage, UNIX_TIMESTAMP(NOW()), UNIX_TIMESTAMP(NOW()))
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param string $clientId The client ID
|
* @param string $clientId The client ID
|
||||||
* @param string $redirectUri The redirect URI
|
* @param string $redirectUri The redirect URI
|
||||||
* @param string $type The session owner's type (default = "user")
|
* @param string $type The session owner's type (default = "user")
|
||||||
@ -56,7 +68,7 @@ interface Database
|
|||||||
* @param string $authCode The authorisation code (default = "null")
|
* @param string $authCode The authorisation code (default = "null")
|
||||||
* @param string $accessToken The access token (default = "null")
|
* @param string $accessToken The access token (default = "null")
|
||||||
* @param string $stage The stage of the session (default ="request")
|
* @param string $stage The stage of the session (default ="request")
|
||||||
* @return [type] [description]
|
* @return int The session ID
|
||||||
*/
|
*/
|
||||||
public function newSession(
|
public function newSession(
|
||||||
$clientId,
|
$clientId,
|
||||||
@ -71,20 +83,20 @@ interface Database
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update an OAuth session
|
* Update an OAuth session
|
||||||
*
|
*
|
||||||
* Database query:
|
* Database query:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* UPDATE oauth_sessions SET auth_code = $authCode, access_token =
|
* UPDATE oauth_sessions SET auth_code = $authCode, access_token =
|
||||||
* $accessToken, stage = $stage, last_updated = UNIX_TIMESTAMP(NOW()) WHERE
|
* $accessToken, stage = $stage, last_updated = UNIX_TIMESTAMP(NOW()) WHERE
|
||||||
* id = $sessionId
|
* id = $sessionId
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param string $sessionId The session ID
|
* @param string $sessionId The session ID
|
||||||
* @param string $authCode The authorisation code (default = "null")
|
* @param string $authCode The authorisation code (default = "null")
|
||||||
* @param string $accessToken The access token (default = "null")
|
* @param string $accessToken The access token (default = "null")
|
||||||
* @param string $stage The stage of the session (default ="request")
|
* @param string $stage The stage of the session (default ="request")
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function updateSession(
|
public function updateSession(
|
||||||
$sessionId,
|
$sessionId,
|
||||||
@ -96,16 +108,16 @@ interface Database
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an OAuth session
|
* Delete an OAuth session
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* DELETE FROM oauth_sessions WHERE client_id = $clientId AND owner_type =
|
* DELETE FROM oauth_sessions WHERE client_id = $clientId AND owner_type =
|
||||||
* $type AND owner_id = $typeId
|
* $type AND owner_id = $typeId
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param string $clientId The client ID
|
* @param string $clientId The client ID
|
||||||
* @param string $type The session owner's type
|
* @param string $type The session owner's type
|
||||||
* @param string $typeId The session owner's ID
|
* @param string $typeId The session owner's ID
|
||||||
* @return [type] [description]
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function deleteSession(
|
public function deleteSession(
|
||||||
$clientId,
|
$clientId,
|
||||||
@ -115,16 +127,16 @@ interface Database
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate that an authorisation code is valid
|
* Validate that an authorisation code is valid
|
||||||
*
|
*
|
||||||
* Database query:
|
* Database query:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* SELECT id FROM oauth_sessions WHERE client_id = $clientID AND
|
* SELECT id FROM oauth_sessions WHERE client_id = $clientID AND
|
||||||
* redirect_uri = $redirectUri AND auth_code = $authCode
|
* redirect_uri = $redirectUri AND auth_code = $authCode
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* Response:
|
* Response:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* Array
|
* Array
|
||||||
* (
|
* (
|
||||||
@ -141,12 +153,12 @@ interface Database
|
|||||||
* last updated
|
* last updated
|
||||||
* )
|
* )
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param string $clientId The client ID
|
* @param string $clientId The client ID
|
||||||
* @param string $redirectUri The redirect URI
|
* @param string $redirectUri The redirect URI
|
||||||
* @param string $authCode The authorisation code
|
* @param string $authCode The authorisation code
|
||||||
* @return int|bool Returns the session ID if the auth code
|
* @return int|bool Returns the session ID if the auth code
|
||||||
* is valid otherwise returns false
|
* is valid otherwise returns false
|
||||||
*/
|
*/
|
||||||
public function validateAuthCode(
|
public function validateAuthCode(
|
||||||
$clientId,
|
$clientId,
|
||||||
@ -156,18 +168,18 @@ interface Database
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the session ID for a given session owner and client combination
|
* Return the session ID for a given session owner and client combination
|
||||||
*
|
*
|
||||||
* Database query:
|
* Database query:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* SELECT id FROM oauth_sessions WHERE client_id = $clientId
|
* SELECT id FROM oauth_sessions WHERE client_id = $clientId
|
||||||
* AND owner_type = $type AND owner_id = $typeId
|
* AND owner_type = $type AND owner_id = $typeId
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param string $type The session owner's type
|
* @param string $type The session owner's type
|
||||||
* @param string $typeId The session owner's ID
|
* @param string $typeId The session owner's ID
|
||||||
* @param string $clientId The client ID
|
* @param string $clientId The client ID
|
||||||
* @return string|null Return the session ID as an integer if
|
* @return string|null Return the session ID as an integer if
|
||||||
* found otherwise returns false
|
* found otherwise returns false
|
||||||
*/
|
*/
|
||||||
public function hasSession(
|
public function hasSession(
|
||||||
@ -178,13 +190,13 @@ interface Database
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the access token for a given session
|
* Return the access token for a given session
|
||||||
*
|
*
|
||||||
* Database query:
|
* Database query:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* SELECT access_token FROM oauth_sessions WHERE id = $sessionId
|
* SELECT access_token FROM oauth_sessions WHERE id = $sessionId
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param int $sessionId The OAuth session ID
|
* @param int $sessionId The OAuth session ID
|
||||||
* @return string|null Returns the access token as a string if
|
* @return string|null Returns the access token as a string if
|
||||||
* found otherwise returns null
|
* found otherwise returns null
|
||||||
@ -193,13 +205,13 @@ interface Database
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an authorisation code associated with a session
|
* Removes an authorisation code associated with a session
|
||||||
*
|
*
|
||||||
* Database query:
|
* Database query:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* UPDATE oauth_sessions SET auth_code = NULL WHERE id = $sessionId
|
* UPDATE oauth_sessions SET auth_code = NULL WHERE id = $sessionId
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param int $sessionId The OAuth session ID
|
* @param int $sessionId The OAuth session ID
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -207,14 +219,14 @@ interface Database
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a sessions access token
|
* Sets a sessions access token
|
||||||
*
|
*
|
||||||
* Database query:
|
* Database query:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* UPDATE oauth_sessions SET access_token = $accessToken WHERE id =
|
* UPDATE oauth_sessions SET access_token = $accessToken WHERE id =
|
||||||
* $sessionId
|
* $sessionId
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param int $sessionId The OAuth session ID
|
* @param int $sessionId The OAuth session ID
|
||||||
* @param string $accessToken The access token
|
* @param string $accessToken The access token
|
||||||
* @return void
|
* @return void
|
||||||
@ -226,14 +238,14 @@ interface Database
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Associates a session with a scope
|
* Associates a session with a scope
|
||||||
*
|
*
|
||||||
* Database query:
|
* Database query:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* INSERT INTO oauth_session_scopes (session_id, scope) VALUE ($sessionId,
|
* INSERT INTO oauth_session_scopes (session_id, scope) VALUE ($sessionId,
|
||||||
* $scope)
|
* $scope)
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param int $sessionId The session ID
|
* @param int $sessionId The session ID
|
||||||
* @param string $scope The scope
|
* @param string $scope The scope
|
||||||
* @return void
|
* @return void
|
||||||
@ -245,15 +257,15 @@ interface Database
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return information about a scope
|
* Return information about a scope
|
||||||
*
|
*
|
||||||
* Database query:
|
* Database query:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* SELECT * FROM scopes WHERE scope = $scope
|
* SELECT * FROM scopes WHERE scope = $scope
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* Response:
|
* Response:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* Array
|
* Array
|
||||||
* (
|
* (
|
||||||
@ -263,22 +275,22 @@ interface Database
|
|||||||
* [description] => (string) The scope's description
|
* [description] => (string) The scope's description
|
||||||
* )
|
* )
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param string $scope The scope
|
* @param string $scope The scope
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getScope($scope);
|
public function getScope($scope);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate a session's scopes with an access token
|
* Associate a session's scopes with an access token
|
||||||
*
|
*
|
||||||
* Database query:
|
* Database query:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* UPDATE oauth_session_scopes SET access_token = $accessToken WHERE
|
* UPDATE oauth_session_scopes SET access_token = $accessToken WHERE
|
||||||
* session_id = $sessionId
|
* session_id = $sessionId
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param int $sessionId The session ID
|
* @param int $sessionId The session ID
|
||||||
* @param string $accessToken The access token
|
* @param string $accessToken The access token
|
||||||
* @return void
|
* @return void
|
||||||
@ -290,17 +302,17 @@ interface Database
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the scopes associated with an access token
|
* Return the scopes associated with an access token
|
||||||
*
|
*
|
||||||
* Database query:
|
* Database query:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* SELECT scopes.scope, scopes.name, scopes.description FROM
|
* SELECT scopes.scope, scopes.name, scopes.description FROM
|
||||||
* oauth_session_scopes JOIN scopes ON oauth_session_scopes.scope =
|
* oauth_session_scopes JOIN scopes ON oauth_session_scopes.scope =
|
||||||
* scopes.scope WHERE access_token = $accessToken
|
* scopes.scope WHERE access_token = $accessToken
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* Response:
|
* Response:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* Array
|
* Array
|
||||||
* (
|
* (
|
||||||
@ -312,7 +324,7 @@ interface Database
|
|||||||
* )
|
* )
|
||||||
* )
|
* )
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param string $accessToken The access token
|
* @param string $accessToken The access token
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user