<commit_before><?php
namespace AuthBundle\Security;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface;
use Symfony\Component\Security\Http\HttpUtils;

class AuthTokenAuthenticator implements SimplePreAuthenticatorInterface, AuthenticationFailureHandlerInterface {

    protected $httpUtils;

    public function __construct(HttpUtils $httpUtils) {
        $this->httpUtils = $httpUtils;
    }

    public function createToken(Request $request, $providerKey) {
        $confirmUrl = '/auth/authtokens';
        $loginUrl = '/auth/login';
        $signUrl = '/auth/users';
        $imgLogoUrl = '/image/logo';
        $imgHeartUrl = '/image/heart';
        if (($request->getMethod() === "POST" && $this->httpUtils->checkRequestPath($request, $loginUrl))
            || ($request->getMethod() === "POST" && $this->httpUtils->checkRequestPath($request, $confirmUrl))
            || ($request->getMethod() === "POST" && $this->httpUtils->checkRequestPath($request, $signUrl))
            || ($request->getMethod() === "GET" && $this->httpUtils->checkRequestPath($request, $imgLogoUrl))
            || ($request->getMethod() === "GET" && $this->httpUtils->checkRequestPath($request, $imgHeartUrl))) {
            return;
        }
        $authTokenHeader = $request->query->get('token');
        if (!$authTokenHeader) {
            throw new BadCredentialsException('Le token d\'authentification est obligatoire');<commit_msg>[aouahidi]: Configuration du aws pour les photos<commit_after><?php
namespace AuthBundle\Security;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface;
use Symfony\Component\Security\Http\HttpUtils;

class AuthTokenAuthenticator implements SimplePreAuthenticatorInterface, AuthenticationFailureHandlerInterface {

    protected $httpUtils;

    public function __construct(HttpUtils $httpUtils) {
        $this->httpUtils = $httpUtils;
    }

    public function createToken(Request $request, $providerKey) {
        $confirmUrl = '/auth/authtokens';
        $loginUrl = '/auth/login';
        $signUrl = '/auth/users';
        if (($request->getMethod() === "POST" && $this->httpUtils->checkRequestPath($request, $loginUrl))
            || ($request->getMethod() === "POST" && $this->httpUtils->checkRequestPath($request, $confirmUrl))
            || ($request->getMethod() === "POST" && $this->httpUtils->checkRequestPath($request, $signUrl))) {
            return;
        }
        $authTokenHeader = $request->query->get('token');
        if (!$authTokenHeader) {
            throw new BadCredentialsException('Le token d\'authentification est obligatoire');
{'fraction_non_alphanumeric': 0.12964903090623364, 'fraction_numerical': 0.0, 'mean_word_length': 4.760180995475113, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4663694', 'n_tokens_mistral': 994, 'n_tokens_neox': 995, 'n_words': 161}