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\Request;
|
||||
use IndieAuth\Client;
|
||||
use JsonException;
|
||||
|
||||
class TokenEndpointController extends Controller
|
||||
{
|
||||
|
@ -68,13 +69,13 @@ class TokenEndpointController extends Controller
|
|||
|
||||
$scope = $auth['scope'] ?? '';
|
||||
$tokenData = [
|
||||
'me' => $request->input('me'),
|
||||
'me' => config('app.url'),
|
||||
'client_id' => $request->input('client_id'),
|
||||
'scope' => $scope,
|
||||
];
|
||||
$token = $this->tokenService->getNewToken($tokenData);
|
||||
$content = [
|
||||
'me' => $request->input('me'),
|
||||
'me' => config('app.url'),
|
||||
'scope' => $scope,
|
||||
'access_token' => $token,
|
||||
];
|
||||
|
@ -106,7 +107,7 @@ class TokenEndpointController extends Controller
|
|||
|
||||
try {
|
||||
$authData = json_decode((string) $response->getBody(), true, 512, JSON_THROW_ON_ERROR);
|
||||
} catch (\JsonException) {
|
||||
} catch (JsonException) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,16 +31,15 @@ class TokenEndpointTest extends TestCase
|
|||
$mockGuzzleClient = new Client(['handler' => $handlerStack]);
|
||||
$this->app->instance(Client::class, $mockGuzzleClient);
|
||||
$response = $this->post('/api/token', [
|
||||
'me' => config('app.url'),
|
||||
'code' => 'abc123',
|
||||
'redirect_uri' => config('app.url') . '/indieauth-callback',
|
||||
'client_id' => config('app.url') . '/micropub-client',
|
||||
'state' => random_int(1000, 10000),
|
||||
]);
|
||||
$response->assertJson([
|
||||
'me' => config('app.url'),
|
||||
'scope' => 'create update',
|
||||
'grant_type' => 'authorization_code',
|
||||
'code' => '1234567890',
|
||||
'redirect_uri' => 'https://example.com/auth/callback',
|
||||
'client_id' => 'https://example.com',
|
||||
'code_verifier' => '1234567890',
|
||||
]);
|
||||
|
||||
$this->assertSame(config('app.url'), $response->json('me'));
|
||||
$this->assertNotEmpty($response->json('access_token'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue