title: Symfony 5 - How implement basic authentication on REST call
body: <p>I have created a URL that take a request in method POST. He take a JSON and he return me a XML converted file.</p>
  <p>I would like, before the request, a basic authorization ( just a password , i need not registered user )on this URL to allow the user make the request. But i don't understand how the authorization working on symfony.</p>
  <p>I think that all i need is in this page of <a href="https://symfony.com/doc/current/reference/configuration/framework.html#reference-http-client" rel="nofollow noreferrer">documentation</a>
  but i get some errors and i not understand how it work (what is realme? What does it mean with Secured Area?)</p>
  <p>This is my controller, how can i implement a basic authentication on this REST call ?</p>
  <pre><code>class IndexController extends AbstractController
  {
  
      /**
       * @Route(&quot;/converter-hl7&quot;, name=&quot;converter&quot;, methods={&quot;POST&quot;})
       */
  
      public function index(Request $request) {
  
          $json = $request-&gt;getContent();
  
          $converter = new HL7ConverterService($json, new ErrorService());
          $xml = $converter-&gt;outputXML();
  
  
          $response = new Response($xml);
          $response-&gt;headers-&gt;set('Content-Type', 'xml');
  
          return $response;
      }
      
  
  }
  </code></pre>