title: No identifier/primary key specified for User entity, without connection to database
body: <p>Im getting error about identifier/primary key for my User entity after im trying to log in.</p>
  
  <p>I searched for the answer, but nothing helped in my case.</p>
  
  <p>This is my user entity, im not using any database, all data is comming with json responses from request's to external application.</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  declare(strict_types=1);
  
  namespace App\Entity;
  
  use Symfony\Component\Security\Core\User\UserInterface;
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * @ORM\Entity
   */
  class User implements UserInterface
  {
      /**
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="NONE")
       */
      private $id;
  
      private $username;
  
      private $password;
  
      private $email;
  
      private $roles;
  
      public function __construct()
      {
          $this-&gt;roles = ['ROLE_USER'];
      }
  
      /**
       * @param $id
       */
      public function setId($id)
      {
          $this-&gt;id = $id;
      }
  
      /**
       * @return string $id
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * @param string $username
       */
      public function setUsername(string $username): void
      {
          $this-&gt;username = $username;
      }
  
      /**
       * @return string
       */
      public function getUsername(): string
      {
          return $this-&gt;username;
      }
  
      /**
       * @param string $password
       */
      public function setPassword(string $password): void
      {
          $this-&gt;password = $password;
      }
  
      /**
       * @return string|null
       */
      public function getPassword(): ?string
      {
          return $this-&gt;password;
      }
  
      /**
       * @param string $email
       */
      public function setEmail(string $email): void
      {
          $this-&gt;email = $email;
      }
  
      /**
       * @return string|null
       */
      public function getEmail(): ?string
      {
          return $this-&gt;email;
      }
  
      /**
       * @return string[]
       */
      public function getRoles(): array
      {
          return $this-&gt;roles;
      }
  
      /**
       * @param string[] $roles
       */
      public function setRoles(array $roles): void
      {
          $this-&gt;roles = $roles;
      }
  
      /**
       * @return null
       */
      public function getSalt()
      {
          return null;
      }
  
      /**
       * Removes sensitive data from the user.
       *
       * This is important if, at any given point, sensitive information like
       * the plain-text password is stored on this object.
       */
      public function eraseCredentials()
      {
          $this-&gt;password = null;
      }
  }
  </code></pre>
  
  <p>This is my login from, im trying to use UsernamePasswordToken, to hold the session with basic informations about my user (thats why im trying to create User entity).</p>
  
  <pre class="lang-php prettyprint-override"><code>public function loginAction(Request $request): JsonResponse
      {
          $client = new CurlHttpClient();
          $response = $client-&gt;request(
              'GET',
              'http://dal/user/'.$request-&gt;request-&gt;get('username'),
              [
                  'auth_basic' =&gt; ['our_user', 'our_password']
              ]
          );
  
          if ($response-&gt;getStatusCode() === 200) {
              $response = $response-&gt;toArray();
              if (password_verify($request-&gt;request-&gt;get('password'), $response['password_hash'])) {
  
                  $user = new User();
                  $user-&gt;setId($response['_id']);
                  $user-&gt;setUsername($request-&gt;request-&gt;get('username'));
                  $user-&gt;setEmail($request-&gt;request-&gt;get('email'));
  
                  $token = new UsernamePasswordToken(
                      $user,
                      null,
                      'main',
                      $user-&gt;getRoles()
                  );
                  $this-&gt;get('security.token_storage')-&gt;setToken($token);
                  $this-&gt;get('session')-&gt;set('_security_main', serialize($token));
                  $event = new InteractiveLoginEvent($request, $token);
                  $this-&gt;get("event_dispatcher")-&gt;dispatch("security.interactive_login", $event);
              }
          } else {
              return new JsonResponse(
                  'Username or password doesn\'t match',
                  JsonResponse::HTTP_UNAUTHORIZED
              );
          }
  
          return new JsonResponse($response);
      }
  </code></pre>
  
  <p>Basicly the only answer im getting from external application is do user with given username and password exists.</p>
  
  <p>Also, this is my security.yaml.</p>
  
  <pre><code>security:
      providers:
          in_memory: { memory: ~ }
          users:
              entity:
                  class: App\Entity\User
                  property: username
      firewalls:
          dev:
              pattern: ^/(_(profiler|wdt)|css|images|js)/
              security: false
          main:
              anonymous: ~
              provider: users
  
              logout:
                  path: /api/security/logout
  </code></pre>