<?php

namespace App\Controller;

use App\Service\KeycloakClientService;
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class SecurityController extends AbstractController
{
    private KeycloakClientService $keycloakClientService;

    public function __construct(KeycloakClientService $keycloakClientService)
    {
        $this->keycloakClientService = $keycloakClientService;
    }

    #[Route('/connect/keycloak', name: 'connect_keycloak')]
    public function connectKeycloak(ClientRegistry $clientRegistry): RedirectResponse
    {
        $client = $clientRegistry->getClient('keycloak');

        return $client->redirect(['openid', 'profile', 'email'], []);
    }
}
