public function createAuthTokenModel(BaseUser $user)
    {
        $privateKey = openssl_pkey_get_private(
            file_get_contents($this->projectDir . '/var/jwt/private.pem'),
            $this->passPhrase
        );

        $jws = new SimpleJWS([
            'alg' => self::ALG
        ]);

        $expirationDate = new \DateTime();
        $expirationDate->modify('+' . $this->authTokenTTL . ' seconds');
        $expirationTimestamp = $expirationDate->getTimestamp();

        $jws->setPayload(array_merge([
            self::USER_ID_KEY => $user->getId(),
            self::EXP_KEY => $expirationTimestamp,
            self::IAT_KEY => (new \DateTime())->getTimestamp()
        ], $user->getJWTPayload()));

        $jws->sign($privateKey);

        return new AuthTokenModel($jws->getTokenString(), $expirationTimestamp);
    }
public function createAuthTokenModel(BaseUser $user)
    {
        $privateKey = openssl_pkey_get_private(
            file_get_contents($this->projectDir . '/var/jwt/private.pem'),
            $this->passPhrase
        );

        $jws = new SimpleJWS([
            'alg' => self::ALG
        ]);

        $expirationDate = new \DateTime();
        $expirationDate->modify('+' . $this->authTokenTTL . ' seconds');
        $expirationTimestamp = $expirationDate->getTimestamp();

        $jws->setPayload(array_merge([
            self::USER_ID_KEY => $user->getId(),
            self::EXP_KEY => $expirationTimestamp,
            self::IAT_KEY => (new \DateTime())->getTimestamp()
        ], $user->getJWTPayload()));

        $jws->sign($privateKey);

        return new AuthTokenModel($jws->getTokenString(), $expirationTimestamp);
    }
public function createAuthTokenModel ( BaseUser $ user ) { $ privateKey = openssl_pkey_get_private ( file_get_contents ( $ this -> projectDir . '/var/jwt/private.pem' ) , $ this -> passPhrase ) ; $ jws = new SimpleJWS ( [ 'alg' => self :: ALG ] ) ; $ expirationDate = new \ DateTime ( ) ; $ expirationDate -> modify ( '+' . $ this -> authTokenTTL . ' seconds' ) ; $ expirationTimestamp = $ expirationDate -> getTimestamp ( ) ; $ jws -> setPayload ( array_merge ( [ self :: USER_ID_KEY => $ user -> getId ( ) , self :: EXP_KEY => $ expirationTimestamp , self :: IAT_KEY => ( new \ DateTime ( ) ) -> getTimestamp ( ) ] , $ user -> getJWTPayload ( ) ) ) ; $ jws -> sign ( $ privateKey ) ; return new AuthTokenModel ( $ jws -> getTokenString ( ) , $ expirationTimestamp ) ; }
Creates a jws token model

@param BaseUser $user
@return AuthTokenModel
Creates a jws token model