Fixes + make scope field optional.
This commit is contained in:
parent
e32f37bc67
commit
33dd519029
6 changed files with 26 additions and 17 deletions
|
@ -1,9 +1,6 @@
|
|||
<?php
|
||||
namespace Oatmeal;
|
||||
|
||||
use Index\Environment;
|
||||
use Index\Data\DbTools;
|
||||
|
||||
define('OAT_STARTUP', microtime(true));
|
||||
define('OAT_ROOT', __DIR__);
|
||||
define('OAT_DEBUG', is_file(OAT_ROOT . '/.debug'));
|
||||
|
@ -12,9 +9,9 @@ define('OAT_DIR_SOURCE', OAT_ROOT . '/src');
|
|||
|
||||
require_once OAT_ROOT . '/vendor/autoload.php';
|
||||
|
||||
Environment::setDebug(OAT_DEBUG);
|
||||
mb_internal_encoding('utf-8');
|
||||
date_default_timezone_set('utc');
|
||||
error_reporting(OAT_DEBUG ? -1 : 0);
|
||||
mb_internal_encoding('UTF-8');
|
||||
date_default_timezone_set('GMT');
|
||||
|
||||
$oatmeal = new OatmealContext((function() {
|
||||
$path = OAT_ROOT . '/.rng';
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<?php
|
||||
namespace Oatmeal;
|
||||
|
||||
use Index\XString;
|
||||
use Index\{CSRFP,UriBase64,XString};
|
||||
use Index\Http\Routing\{HttpGet,HttpPost,RouteHandler};
|
||||
use Index\Security\CSRFP;
|
||||
use Index\Serialisation\UriBase64;
|
||||
|
||||
final class AuthzCodeRoutes extends RouteHandler {
|
||||
public function __construct(
|
||||
|
@ -58,7 +56,7 @@ final class AuthzCodeRoutes extends RouteHandler {
|
|||
<div>
|
||||
<label>
|
||||
<span>Scope:</span>
|
||||
<input type=text name=scope required>
|
||||
<input type=text name=scope>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
|
@ -146,9 +144,10 @@ HTML;
|
|||
$query = [
|
||||
'response_type' => 'code',
|
||||
'client_id' => $clientId,
|
||||
'scope' => $scope,
|
||||
];
|
||||
|
||||
if($scope !== '')
|
||||
$query['scope'] = $scope;
|
||||
if($redirectUri !== '')
|
||||
$query['redirect_uri'] = $redirectUri;
|
||||
if($state !== '')
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
namespace Oatmeal;
|
||||
|
||||
use Index\CSRFP;
|
||||
use Index\Http\Routing\{HttpGet,HttpPost,RouteHandler};
|
||||
use Index\Security\CSRFP;
|
||||
|
||||
final class ClientCredsRoutes extends RouteHandler {
|
||||
public function __construct(
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
namespace Oatmeal;
|
||||
|
||||
use Index\CSRFP;
|
||||
use Index\Http\Routing\{HttpGet,HttpPost,RouteHandler};
|
||||
use Index\Security\CSRFP;
|
||||
|
||||
final class DeviceCodeRoutes extends RouteHandler {
|
||||
public function __construct(
|
||||
|
@ -53,7 +53,7 @@ final class DeviceCodeRoutes extends RouteHandler {
|
|||
<div>
|
||||
<label>
|
||||
<span>Scope:</span>
|
||||
<input type=text name=scope required>
|
||||
<input type=text name=scope>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
|
@ -93,7 +93,10 @@ HTML;
|
|||
$scope = (string)$content->getParam('scope');
|
||||
|
||||
$headers = [];
|
||||
$body = ['scope' => $scope];
|
||||
$body = [];
|
||||
|
||||
if($scope !== '')
|
||||
$body['scope'] = $scope;
|
||||
|
||||
if($clientSecret === '')
|
||||
$body['client_id'] = $clientId;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
namespace Oatmeal;
|
||||
|
||||
use Index\CSRFP;
|
||||
use Index\Http\Routing\{HttpRouter,IRouter,IRouteHandler};
|
||||
use Index\Security\CSRFP;
|
||||
|
||||
class OatmealContext {
|
||||
private CSRFP $csrfp;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
namespace Oatmeal;
|
||||
|
||||
use Index\CSRFP;
|
||||
use Index\Http\Routing\{HttpGet,HttpPost,RouteHandler};
|
||||
use Index\Security\CSRFP;
|
||||
|
||||
final class RefreshTokenRoutes extends RouteHandler {
|
||||
public function __construct(
|
||||
|
@ -50,6 +50,12 @@ final class RefreshTokenRoutes extends RouteHandler {
|
|||
<input type=password name=client_secret>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<span>Scope:</span>
|
||||
<input type=text name=scope>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<span>Authentication:</span>
|
||||
<label>
|
||||
|
@ -101,6 +107,7 @@ HTML;
|
|||
$clientSecret = (string)$content->getParam('client_secret');
|
||||
$refreshToken = (string)$content->getParam('refresh_token');
|
||||
$auth = (string)$content->getParam('auth');
|
||||
$scope = (string)$content->getParam('scope');
|
||||
|
||||
$headers = [];
|
||||
$body = [
|
||||
|
@ -108,6 +115,9 @@ HTML;
|
|||
'refresh_token' => $refreshToken,
|
||||
];
|
||||
|
||||
if($scope !== '')
|
||||
$body['scope'] = $scope;
|
||||
|
||||
if($clientSecret === '')
|
||||
$body['client_id'] = $clientId;
|
||||
elseif($auth === 'body' || ($auth !== 'header' && mt_rand(0, 10) > 5)) {
|
||||
|
|
Loading…
Reference in a new issue