Fix issuing of token during IndieAuth sign in
This commit is contained in:
parent
8d781b7009
commit
4a0bc6005a
2 changed files with 12 additions and 12 deletions
|
@ -10,6 +10,7 @@ use GuzzleHttp\Exception\BadResponseException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use IndieAuth\Client;
|
use IndieAuth\Client;
|
||||||
|
use JsonException;
|
||||||
|
|
||||||
class TokenEndpointController extends Controller
|
class TokenEndpointController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -68,13 +69,13 @@ class TokenEndpointController extends Controller
|
||||||
|
|
||||||
$scope = $auth['scope'] ?? '';
|
$scope = $auth['scope'] ?? '';
|
||||||
$tokenData = [
|
$tokenData = [
|
||||||
'me' => $request->input('me'),
|
'me' => config('app.url'),
|
||||||
'client_id' => $request->input('client_id'),
|
'client_id' => $request->input('client_id'),
|
||||||
'scope' => $scope,
|
'scope' => $scope,
|
||||||
];
|
];
|
||||||
$token = $this->tokenService->getNewToken($tokenData);
|
$token = $this->tokenService->getNewToken($tokenData);
|
||||||
$content = [
|
$content = [
|
||||||
'me' => $request->input('me'),
|
'me' => config('app.url'),
|
||||||
'scope' => $scope,
|
'scope' => $scope,
|
||||||
'access_token' => $token,
|
'access_token' => $token,
|
||||||
];
|
];
|
||||||
|
@ -106,7 +107,7 @@ class TokenEndpointController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$authData = json_decode((string) $response->getBody(), true, 512, JSON_THROW_ON_ERROR);
|
$authData = json_decode((string) $response->getBody(), true, 512, JSON_THROW_ON_ERROR);
|
||||||
} catch (\JsonException) {
|
} catch (JsonException) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,16 +31,15 @@ class TokenEndpointTest extends TestCase
|
||||||
$mockGuzzleClient = new Client(['handler' => $handlerStack]);
|
$mockGuzzleClient = new Client(['handler' => $handlerStack]);
|
||||||
$this->app->instance(Client::class, $mockGuzzleClient);
|
$this->app->instance(Client::class, $mockGuzzleClient);
|
||||||
$response = $this->post('/api/token', [
|
$response = $this->post('/api/token', [
|
||||||
'me' => config('app.url'),
|
'grant_type' => 'authorization_code',
|
||||||
'code' => 'abc123',
|
'code' => '1234567890',
|
||||||
'redirect_uri' => config('app.url') . '/indieauth-callback',
|
'redirect_uri' => 'https://example.com/auth/callback',
|
||||||
'client_id' => config('app.url') . '/micropub-client',
|
'client_id' => 'https://example.com',
|
||||||
'state' => random_int(1000, 10000),
|
'code_verifier' => '1234567890',
|
||||||
]);
|
|
||||||
$response->assertJson([
|
|
||||||
'me' => config('app.url'),
|
|
||||||
'scope' => 'create update',
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->assertSame(config('app.url'), $response->json('me'));
|
||||||
|
$this->assertNotEmpty($response->json('access_token'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue