Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,31 +11,39 @@
|
||||
namespace IPS\Login\Handler\OAuth2;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Login;
|
||||
use IPS\Login\Exception;
|
||||
use IPS\Login\Handler\OAuth2;
|
||||
use IPS\Member;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open ID Connect
|
||||
*/
|
||||
abstract class _OpenID extends \IPS\Login\Handler\OAuth2
|
||||
abstract class OpenID extends OAuth2
|
||||
{
|
||||
/**
|
||||
* @brief ID Token
|
||||
*/
|
||||
protected $_idToken = array();
|
||||
protected array $_idToken = array();
|
||||
|
||||
/**
|
||||
* Process an Access Token
|
||||
*
|
||||
* @param \IPS\Login $login The login object
|
||||
* @param array $accessToken Access Token
|
||||
* @return \IPS\Member
|
||||
* @throws \IPS\Login\Exception
|
||||
* @param Login $login The login object
|
||||
* @param array $accessToken Access Token
|
||||
* @return Member
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _processAccessToken( \IPS\Login $login, $accessToken )
|
||||
protected function _processAccessToken( Login $login, array $accessToken ): Member
|
||||
{
|
||||
/* Set up ID token */
|
||||
if( isset( $accessToken['id_token'] ) )
|
||||
@@ -50,16 +58,16 @@ abstract class _OpenID extends \IPS\Login\Handler\OAuth2
|
||||
/* Store the id token */
|
||||
if( $this->_idToken[ $accessToken['access_token'] ] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_login_links', array( 'token_id_token' => $this->_idToken[ $accessToken['access_token'] ] ), array( 'token_login_method=? and token_member=?', $this->id, $member->member_id ) );
|
||||
Db::i()->update( 'core_login_links', array( 'token_id_token' => $this->_idToken[ $accessToken['access_token'] ] ), array( 'token_login_method=? and token_member=?', $this->id, $member->member_id ) );
|
||||
}
|
||||
|
||||
return $member;
|
||||
}
|
||||
catch ( \Exception $exception )
|
||||
{
|
||||
if ( $exception->getCode() === \IPS\Login\Exception::MERGE_SOCIAL_ACCOUNT )
|
||||
if ( $exception->getCode() === Exception::MERGE_SOCIAL_ACCOUNT )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_login_links', array( 'token_id_token' => $this->_idToken[ $accessToken['access_token'] ] ), array( 'token_login_method=? and token_member=?', $this->id, $exception->member->member_id ) );
|
||||
Db::i()->update( 'core_login_links', array( 'token_id_token' => $this->_idToken[ $accessToken['access_token'] ] ), array( 'token_login_method=? and token_member=?', $this->id, $exception->member->member_id ) );
|
||||
}
|
||||
|
||||
throw $exception;
|
||||
@@ -69,14 +77,14 @@ abstract class _OpenID extends \IPS\Login\Handler\OAuth2
|
||||
/**
|
||||
* Retrieve the ID Token
|
||||
*
|
||||
* @param string $accessToken Access Token
|
||||
* @param string $accessToken Access Token
|
||||
* @return string
|
||||
*/
|
||||
protected function _getIdToken( $accessToken )
|
||||
protected function _getIdToken( string $accessToken ): string
|
||||
{
|
||||
if( !isset( $this->_idToken[ $accessToken ] ) or !$this->_idToken[ $accessToken ] )
|
||||
{
|
||||
$this->_idToken[ $accessToken ] = \IPS\Db::i()->select( 'token_id_token', 'core_login_links', array( 'token_login_method=? and token_access_token=?', $this->id, $accessToken ) )->first();
|
||||
$this->_idToken[ $accessToken ] = Db::i()->select( 'token_id_token', 'core_login_links', array( 'token_login_method=? and token_access_token=?', $this->id, $accessToken ) )->first();
|
||||
}
|
||||
|
||||
return $this->_idToken[ $accessToken ];
|
||||
|
||||
Reference in new issue
Block a user