thephpleague / oauth2-server

A spec compliant, secure by default PHP OAuth 2.0 Server
https://oauth2.thephpleague.com
MIT License
6.49k stars 1.12k forks source link

Testing v9-rc1 on Laravel Passport #1398

Closed hafezdivandari closed 1 month ago

hafezdivandari commented 3 months ago

Trying to add support and test v9-rc1 before stable release on Laravel Passport, PR laravel/passport#1734, there are 2 issues:

  1. User ID doesn't accept integer
  2. Client ID doesn't accept integer

You may check the failed tests here: https://github.com/laravel/passport/actions/runs/8482967241/job/23243211337?pr=1734

Both User and Client classes of Laravel Passport are using League\OAuth2\Server\Entities\Traits\EntityTrait.

Sephster commented 3 months ago

Thanks so much for this @hafezdivandari. This is super useful. I suspected the change of IDs might cause issues downstream so great to have something concrete to work with. Really appreciate you doing this

hafezdivandari commented 3 months ago

Thank you @Sephster for your hard work in maintaining this package and the new major release. I'll keep an eye on this issue until it is resolved. Please let me know when we are able to move the PR forward. Thanks.

Sephster commented 2 months ago

I think I've fixed all the issues raised here now @hafezdivandari - thanks again for creating the PR for Passport. Would you be able to check if this has resolved all issues now? Once we have a working, v9 compatible version of Passport, I will look to tag v9 proper. Thanks again for progressing this. Much appreciated.

hafezdivandari commented 2 months ago

@Sephster I applied the latest changes. I'm checking failed test...

hafezdivandari commented 2 months ago

@Sephster all tests are passing. We may close this issue as completed now, Thank you.

eugene-borovov commented 2 months ago

Hi, @Sephster This library should treat any identifiers as strings. This will avoid constant conversions to a string when composing a response. The only thing that needs to be provided is the conversion of identifiers from a query to a string in order to avoid type mismatch errors. Knowing the true data type of the identifier is the task of the application that uses this library.

The introduction of an integer identifier is a step back in the implementation of typing.

Sephster commented 2 months ago

I can see the case for this argument. Part of the reason I originally had the identifiers as strings initially was to avoid casting when things come in from http requests.

@hafezdivandari what are your thoughts on this? Would a simple case of casting fix most compatibility issues with Passport?

You still raised some excellent points so I won't revert all changes but I'm leaning towards treating identifiers as strings only as @eugene-borovov suggests

eugene-borovov commented 2 months ago

@Sephster I`d like to remind about this issue. This change help to cast all request parameters to string.

hafezdivandari commented 2 months ago

No problem @Sephster, let's make the types more strict and see what happens on Laravel Passport tests. I'll try to cast the arguments.

Sephster commented 2 months ago

Changes made now @hafezdivandari - if you can see how you get on with the PR, I can merge this into main assuming all is ok. Apologies for the delay with this as well, I was travelling with my family.

hafezdivandari commented 2 months ago

Thank you @Sephster, have a nice trip. Just commented a little issue on the PR: https://github.com/thephpleague/oauth2-server/pull/1402#issuecomment-2071005717

Sephster commented 2 months ago

It was great thank you. Thanks for spotting that. I've fixed the issue reported now.

hafezdivandari commented 2 months ago

@Sephster 6 tests are failing on Laravel Passport rn, I added a comment on the PR: https://github.com/thephpleague/oauth2-server/pull/1402#issuecomment-2071030766 I hope this is the last one.