Version 4.3.6

This commit is contained in:
Neo committed 2025-12-19 05:49:12 -08:00
1 parent fe1acf984a
commit 1a0c7fd3c2
609 files changed
+14707 -5726

No files matched your search

+21 -9
View File
@@ -56,9 +56,9 @@ abstract class _OAuth2 extends \IPS\Login\Handler
* @endcode
*/
public function acpForm()
{
{
$return = array(
array( 'login_handler_oauth_settings', static::getTitle() . '_info' ),
array( 'login_handler_oauth_settings', \IPS\Member::loggedIn()->language()->addToStack( static::getTitle() . '_info', FALSE, array( 'sprintf' => array( (string) $this->redirectionEndpoint() ) ) ) ),
'client_id' => new \IPS\Helpers\Form\Text( 'oauth_client_id', isset( $this->settings['client_id'] ) ? $this->settings['client_id'] : NULL, TRUE ),
'client_secret' => new \IPS\Helpers\Form\Text( 'oauth_client_client_secret', isset( $this->settings['client_secret'] ) ? $this->settings['client_secret'] : NULL, NULL, array(), NULL, NULL, NULL, 'client_secret' ),
);
@@ -92,6 +92,8 @@ abstract class _OAuth2 extends \IPS\Login\Handler
*/
public function testSettings()
{
parent::testSettings();
try
{
/* Authorization Code / Implicit */
@@ -159,7 +161,7 @@ abstract class _OAuth2 extends \IPS\Login\Handler
{
$target = $this->authorizationEndpoint( $login )->setQueryString( array(
'client_id' => $this->settings['client_id'],
'response_type' => $this->grantType() === 'authorization_code' ? 'code' : 'implicit',
'response_type' => $this->grantType() === 'authorization_code' ? 'code' : 'token',
'redirect_uri' => (string) $this->redirectionEndpoint(),
'state' => $this->id . '-' . base64_encode( $login->url ) . '-' . \IPS\Session::i()->csrfKey . '-' . \IPS\Request::i()->ref,
) );
@@ -501,11 +503,21 @@ abstract class _OAuth2 extends \IPS\Login\Handler
protected function _exchangeAuthorizationCodeForAccessToken( $code )
{
/* Make the request */
$response = $this->_authenticatedRequest( $this->tokenEndpoint(), array(
'grant_type' => 'authorization_code',
'code' => $code,
'redirect_uri' => (string) $this->redirectionEndpoint(),
) )->decodeJson();
$data = NULL;
$response = array();
try
{
$data = $this->_authenticatedRequest( $this->tokenEndpoint(), array(
'grant_type' => 'authorization_code',
'code' => $code,
'redirect_uri' => (string) $this->redirectionEndpoint(),
) );
$response = $data->decodeJson();
}
catch( \RuntimeException $e )
{
\IPS\Log::log( var_export( $data, true ), 'oauth' );
}
/* Check for any errors */
if ( isset( $response['error'] ) or !isset( $response['access_token'] ) or ( isset( $response['token_type'] ) and mb_strtolower( $response['token_type'] ) !== 'bearer' ) )
@@ -551,7 +563,7 @@ abstract class _OAuth2 extends \IPS\Login\Handler
}
if ( isset( $newAccessToken['expires_in'] ) )
{
$update['token_expires'] = $newAccessToken['expires_in'];
$update['token_expires'] = ( time() + $newAccessToken['expires_in'] );
}
if ( isset( $newAccessToken['refresh_token'] ) )
{