Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
GoogleSignInConfigController
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 config
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Identity\Infrastructure\Controllers;
6
7use OpenApi\Attributes as OA;
8use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
9use Symfony\Component\HttpFoundation\JsonResponse;
10use 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')]
24class 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}