Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
+23
-10
@@ -532,7 +532,7 @@ class _OAuthClient extends \IPS\Node\Model
|
||||
* @param array $tokenToRefresh If we are refreshing, the existing access token to refresh
|
||||
* @return array
|
||||
*/
|
||||
public function generateAccessToken( \IPS\Member $member = NULL, $scopes, $grantType, $skipRefreshToken = FALSE, $authorizationCode = NULL, $authUserAgent = NULL, $grantUserAgent = NULL, \IPS\Member\Device $device = NULL, $tokenToRefresh = NULL )
|
||||
public function generateAccessToken( ?\IPS\Member $member, $scopes, $grantType, $skipRefreshToken = FALSE, $authorizationCode = NULL, $authUserAgent = NULL, $grantUserAgent = NULL, \IPS\Member\Device $device = NULL, $tokenToRefresh = NULL )
|
||||
{
|
||||
do
|
||||
{
|
||||
@@ -552,7 +552,8 @@ class _OAuthClient extends \IPS\Node\Model
|
||||
'issued' => time(),
|
||||
'auth_user_agent' => $authUserAgent,
|
||||
'issue_user_agent' => $grantUserAgent,
|
||||
'device_key' => $device ? $device->device_key : NULL
|
||||
'device_key' => $device ? $device->device_key : NULL,
|
||||
'status' => 'active',
|
||||
);
|
||||
|
||||
if ( $this->use_refresh_tokens )
|
||||
@@ -574,16 +575,12 @@ class _OAuthClient extends \IPS\Node\Model
|
||||
$data['refresh_token_expires'] = NULL;
|
||||
}
|
||||
}
|
||||
elseif ( $tokenToRefresh )
|
||||
{
|
||||
$data['refresh_token'] = $tokenToRefresh['refresh_token'];
|
||||
$data['refresh_token_expires'] = $tokenToRefresh['refresh_token_expires'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $grantType === 'refresh_token' and $tokenToRefresh )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_oauth_server_access_tokens', $data, array( 'client_id=? AND access_token=?', $tokenToRefresh['client_id'], $tokenToRefresh['access_token'] ) );
|
||||
\IPS\Db::i()->update( 'core_oauth_server_access_tokens', array( 'status' => 'revoked' ), array( 'client_id=? AND access_token=?', $tokenToRefresh['client_id'], $tokenToRefresh['access_token'] ) );
|
||||
\IPS\Db::i()->insert( 'core_oauth_server_access_tokens', $data );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -624,6 +621,10 @@ class _OAuthClient extends \IPS\Node\Model
|
||||
}
|
||||
|
||||
$return = \IPS\Db::i()->select( '*', 'core_oauth_server_access_tokens', array( 'client_id=? AND access_token=?', $exploded[0], $exploded[1] ) )->first();
|
||||
if ( $return['status'] == 'revoked' )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'REVOKED_ACCESS_TOKEN', '1S290/F', 401, 'invalid_token' );
|
||||
}
|
||||
if ( $return['access_token_expires'] and $return['access_token_expires'] < time() )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'EXPIRED_ACCESS_TOKEN', '1S290/E', 401, 'invalid_token' );
|
||||
@@ -643,6 +644,10 @@ class _OAuthClient extends \IPS\Node\Model
|
||||
try
|
||||
{
|
||||
$row = \IPS\Db::i()->select( array( 'member_id', 'access_token_expires' ), 'core_oauth_server_access_tokens', array( 'client_id=? AND access_token=?', $this->client_id, $accessToken ) )->first();
|
||||
if ( $row['status'] == 'revoked' )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ( $row['access_token_expires'] and $row['access_token_expires'] < time() )
|
||||
{
|
||||
return;
|
||||
@@ -668,6 +673,10 @@ class _OAuthClient extends \IPS\Node\Model
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_oauth_server_access_tokens', array( 'client_id=? AND member_id=?', $this->client_id, $member->member_id ) ) as $row )
|
||||
{
|
||||
if ( $row['status'] == 'revoked' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( $this->use_refresh_tokens )
|
||||
{
|
||||
if ( $row['refresh_token_expires'] and $row['refresh_token_expires'] < time() )
|
||||
@@ -703,6 +712,10 @@ class _OAuthClient extends \IPS\Node\Model
|
||||
try
|
||||
{
|
||||
$row = \IPS\Db::i()->select( '*', 'core_oauth_server_access_tokens', array( 'client_id=? AND refresh_token=?', $this->client_id, $refreshToken ) )->first();
|
||||
if ( $row['status'] == 'revoked' )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ( $row['refresh_token_expires'] and $row['refresh_token_expires'] < time() )
|
||||
{
|
||||
return;
|
||||
@@ -775,10 +788,10 @@ class _OAuthClient extends \IPS\Node\Model
|
||||
*/
|
||||
final public static function mobileAppValues()
|
||||
{
|
||||
$redirect_uris = [ \IPS\APP_MULTICOMMUNITY_SCHEMA . ':///auth' ];
|
||||
$redirect_uris = [ \IPS\APP_MULTICOMMUNITY_SCHEMA . '://auth' ];
|
||||
if ( \IPS\Settings::i()->mobile_app_redirect_scheme )
|
||||
{
|
||||
$redirect_uris[] = \IPS\Settings::i()->mobile_app_redirect_scheme . ':///auth';
|
||||
$redirect_uris[] = \IPS\Settings::i()->mobile_app_redirect_scheme . '://auth';
|
||||
}
|
||||
|
||||
return array(
|
||||
|
||||
Reference in new issue
Block a user