new changes
This commit is contained in:
29
panel-api/app/Modules/PublicApi/PublicApiController.php
Normal file
29
panel-api/app/Modules/PublicApi/PublicApiController.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\PublicApi;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class PublicApiController extends Controller
|
||||
{
|
||||
public function __construct(private readonly PublicTokenService $tokens)
|
||||
{
|
||||
}
|
||||
|
||||
public function issueToken(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'data' => $this->tokens->issue($request->all()),
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function introspect(Request $request): JsonResponse
|
||||
{
|
||||
$token = (string) $request->input('token', '');
|
||||
return response()->json([
|
||||
'data' => $this->tokens->introspect($token),
|
||||
]);
|
||||
}
|
||||
}
|
||||
23
panel-api/app/Modules/PublicApi/PublicTokenService.php
Normal file
23
panel-api/app/Modules/PublicApi/PublicTokenService.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\PublicApi;
|
||||
|
||||
class PublicTokenService
|
||||
{
|
||||
public function issue(array $input): array
|
||||
{
|
||||
return [
|
||||
'token' => 'public-token-placeholder',
|
||||
'scopes' => $input['scopes'] ?? [],
|
||||
'expires_in' => 3600,
|
||||
];
|
||||
}
|
||||
|
||||
public function introspect(string $token): array
|
||||
{
|
||||
return [
|
||||
'active' => $token !== '',
|
||||
'scopes' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user