Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| GoogleSignInConfigController | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| config | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Identity\Infrastructure\Controllers; |
| 6 | |
| 7 | use OpenApi\Attributes as OA; |
| 8 | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
| 9 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 10 | use Symfony\Component\Routing\Attribute\Route; |
| 11 | |
| 12 | /** |
| 13 | * What the browser needs to start a Google sign-in. The client id is public by |
| 14 | * design (it ships in the page and is the ID token's `aud`), but it lives in the |
| 15 | * backend's environment: serving it keeps ONE source of truth, so it can never |
| 16 | * drift from the value the authenticator checks `aud` against. |
| 17 | * |
| 18 | * Same path as the POST the authenticator handles: GET asks what to sign in |
| 19 | * with, POST signs in. GoogleAuthenticator::supports() is POST-only, so this |
| 20 | * controller is reached normally, and the unanchored `^/login` access_control |
| 21 | * rule already makes it public. |
| 22 | */ |
| 23 | #[OA\Tag(name: 'Auth')] |
| 24 | class GoogleSignInConfigController extends AbstractController |
| 25 | { |
| 26 | public function __construct(private readonly string $googleClientId) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | #[Route('/login/google', name: 'auth_login_google_config', methods: ['GET'])] |
| 31 | public function config(): JsonResponse |
| 32 | { |
| 33 | return new JsonResponse(['clientId' => $this->googleClientId]); |
| 34 | } |
| 35 | } |