markitosgv / JWTRefreshTokenBundle

Implements a Refresh Token system over Json Web Tokens in Symfony
MIT License
663 stars 159 forks source link

Support to doctrine/mongodb-odm-bundle 4.x still with errors #169

Open lcavero opened 5 years ago

lcavero commented 5 years ago

Hi, lookslike the new version 0.8 doesn't fix all errors. Now, when I require the library I get that:

The mapping file /xxx/vendor/gesdinet/jwt-refresh-token-bundle/Resources/config/mongodb/doctrine-document/RefreshToken.mongodb.xml is invalid:
!! Line 8:0: Element '{http://doctrine-project.org/schemas/odm/doctrine-mongo-
!! mapping}document', attribute 'repositoryClass': The attribute 'repositoryClass' is not allowed.
!!
!! Line 9:0: Element '{http://doctrine-project.org/schemas/odm/doctrine-mongo-
!! mapping}field', attribute 'fieldName': The attribute 'fieldName' is not allowed.

Thanks for updating the library so fast!

markitosgv commented 5 years ago

@lcavero could you please test against dev-master , I fix xml mapping

ghost commented 5 years ago

Hi, I really need this fix. When we can expect this amendment to be on the master?

markitosgv commented 5 years ago

@pandresp could you please update to dev-master to test if this fix is working?

ghost commented 5 years ago

@markitosgv on dev-master the previous error is not ocured, but new one exists I think.

Is the table name was changed? Base table or view not found: 1146 Table 'refresh_token' doesn't exist" Do you now something about this?

In data base I have table named as refresh_tokens with s on end. On version 0.7.1 working with refresh_tokens table.

markitosgv commented 5 years ago

Yes, but look at this:

https://github.com/markitosgv/JWTRefreshTokenBundle/blob/40f03d12d8167f5fd1124ef9befb8ac3b07e1f87/Resources/config/mongodb/doctrine-document/RefreshToken.mongodb.xml#L8

Are you checking against last dev-master?

lcavero commented 5 years ago

@markitosgv Hi, testing in dev-master solves the previous problem, a new problem happens now

No identifier/primary key specified for Document 'Gesdinet\JWTRefreshTokenB
!! undle\Document\RefreshToken'. Every Document must have an identifier/primar
!! y key.
Ty

markitosgv commented 5 years ago

Ok @lcavero

Could you please test changing line 9 of https://github.com/markitosgv/JWTRefreshTokenBundle/blob/40f03d12d8167f5fd1124ef9befb8ac3b07e1f87/Resources/config/mongodb/doctrine-document/RefreshToken.mongodb.xml#L9 to this:

<field field-name="id" type="id" id="true" />
ghost commented 5 years ago

@markitosgv, I think you do not understand exactly my case

In my project I use postgres DB for entity (and for refresh tokens). In last days I ad hybrid configuration postgres + mongoDB And then problems was started.

For clear, I want use postgres DB to store my entities and refresh tokens. Only for some dokuments I use mongoDB.

I see that you switch configuration form yaml to xml After switch the configuration is not the same

Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken:
  type: entity
  table: refresh_tokens
  repositoryClass: Gesdinet\JWTRefreshTokenBundle\Entity\RefreshTokenRepository
<entity name="Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken">

shouldbe:

<entity name="Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken" table="refresh_tokens">

I think you forgot the table name

markitosgv commented 5 years ago

You're right @pandresp , mistake was introduced in PR #167 . Solved in b05c321ccc24205966f90222307f1cc783d14dfa, f5472176b7599f0ea39c1b868d542cda722c33b3 and waiting for a new release when @lcavero confirms

lcavero commented 5 years ago

@markitosgv

The mapping file /home/luilli/FREELANCE/fly/core/vendor/gesdinet/jwt-refresh-token-bundle/Resources/config/mongodb/doctrine-document/RefreshToken.mongodb.xml is invalid:
Line 9:0: Element '{http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping}field', attribute 'id': The attribute 'id' is not allowed.

markitosgv commented 5 years ago

Ok sorry @lcavero try this:

<id field-name="id" />
lcavero commented 5 years ago

Lookslike it works, no errors in cache clear. Great!

lcavero commented 5 years ago

Yes, it generates the refresh token on login. Perfect!

lcavero commented 5 years ago

@markitosgv Hola Marcos, no sé si me he perdido algo pero te cuento. Para doctrine odm 4 si no me equivoco tienen que haber dos cosas. El archivo RefreshToken.mongodb.xml tiene que estar como lo pusiste antes, con el campo , pero el archivo AbstractRefreshToken tiene que estar el tipo "datetime" cambiado a "date". He buscado en varias ramas del proyecto y en unas pone una cosa y en otras la otra, pero no las dos a la vez. Se me ha escapado a mí algo o hay algo mal? Creo que a lo mejor lo habéis vuelto a poner como datetime, porque yo llegué a probarlo y funcionaba. Saludos y muchas gracias por actualizar el proyecto