Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.x] Deprecate JSON API #1778

Merged
merged 18 commits into from
Oct 8, 2024

Conversation

hafezdivandari
Copy link
Contributor

@hafezdivandari hafezdivandari commented Aug 8, 2024

This PR fixes a few bugs in the current implementation of JSON API and deprecates it because:

  • It falls outside the core purpose of Passport as an OAuth2 server implementation.
  • Similarly, Sanctum doesn't offer a JSON API for managing PATs, and not every app needs third-party client registration.
  • It adds 10 web routes, 4 controllers, mostly not reusable, not customizable and too opinionated; Makes Passport feature bloated without adding much value.
  • We're already asking developers to create their own UI to use this API. Building the backend for this is a straightforward CRUD operation, which is simpler for developers to implement / customize on their side than feature bloating Passport.
  • Doesn't comply RFC specifications unlike rest of the code.

Deprecations

  • \Laravel\Passport\Http\Controllers\AuthorizedAccessTokenController controller class.
  • \Laravel\Passport\Http\Controllers\ClientController controller class.
  • \Laravel\Passport\Http\Controllers\PersonalAccessTokenController controller class.
  • \Laravel\Passport\Http\Controllers\ScopeController controller class
  • \Laravel\Passport\Http\Rules\RedirectRule rule class.
  • \Laravel\Passport\Http\Rules\UriRule rule class.
  • \Laravel\Passport\TokenRepository repository class and its findForUser and forUser methods.
  • \Laravel\Passport\ClientRepository::findForUser, forUser, update, and delete repository methods.

Removal

  • \Laravel\Passport\RefreshTokenRepository repository class has been removed as it was a duplicate of \Laravel\Passport\Bridge\RefreshTokenRepository class.
  • \Laravel\Passport\TokenRepository::isAccessTokenRevoked and revokeAccessToken, create, find, getValidToken, save, and findValidToken repository methods have been removed as they were duplicated on \Laravel\Passport\Bridge\AccessTokenRepository class or weren't used.
  • \Laravel\Passport\ClientRepository::activeForUser and revoked methods have been removed as they weren't used.

Changes

  • Adds Passport::$registersJsonApiRoutes = false.
  • Doesn't register JSON API routes by default anymore.

Upgrade Guide

You may call Passport::$registersJsonApiRoutes = true if you want to continue using deprecated JSON API.

Copy link

github-actions bot commented Aug 8, 2024

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@hafezdivandari
Copy link
Contributor Author

Hi @driesvints would you please merge 12.x into 13.x? thanks.

@hafezdivandari hafezdivandari marked this pull request as ready for review August 20, 2024 18:07
@taylorotwell
Copy link
Member

taylorotwell commented Aug 22, 2024

Can we really fully remove this API? If there are bugs we could just fix them? Not every Laravel application will be using Jetstream... how will those people use Passport?

@taylorotwell taylorotwell marked this pull request as draft August 22, 2024 13:00
@taylorotwell taylorotwell marked this pull request as ready for review August 22, 2024 13:01
@driesvints
Copy link
Member

@hafezdivandari done

@hafezdivandari hafezdivandari marked this pull request as draft August 22, 2024 13:03
@hafezdivandari hafezdivandari marked this pull request as ready for review August 22, 2024 13:45
@hafezdivandari
Copy link
Contributor Author

hafezdivandari commented Aug 22, 2024

Can we really fully remove this API? If there are bugs we could just fix them?

@taylorotwell This API falls outside the core purpose of Passport as an OAuth2 server implementation, which is why we can confidently remove it. Passport doesn't rely on this API for its primary functions, making it unnecessary.

Similarly, Sanctum doesn't offer a JSON API for managing PATs - we use Sanctum for issuing tokens and Jetstream for managing them.

Not every Laravel application will be using Jetstream... how will those people use Passport?

Not every app needs third-party client registration. We're deprecating this feature in favor of a more modern, opt-in alternative —the Jetstream OAuth feature— where this functionality naturally fits.

Moreover, we're already asking developers to create their own UI to use this API. Building the backend for this is a straightforward CRUD operation, which is simpler for developers to implement on their side (even by copy / pasting deprecated controllers) than feature bloating Passport.

@taylorotwell
Copy link
Member

We are redoing our starter kits so we shouldn't recommend Jetstream / Breeze for this UI.

@hafezdivandari
Copy link
Contributor Author

hafezdivandari commented Sep 22, 2024

@taylorotwell This PR is still applicable, as we are not recommending any UI on this PR, just deprecating the JSON API as we don't have any UI for it and it's falls outside the core purpose of Passport as I explained earlier.

but about redoing the starter kits, sorry I'm confused. You mean is there going to be a new starter kit to integrate Passport into? or the following 2 PRs on Jetstream / Breeze is going to be a waste of time even after this confirmation?

cc @driesvints

@taylorotwell
Copy link
Member

@hafezdivandari I think we would just want to repurpose that work towards our new starter kit work we take on this fall. 👍

@taylorotwell taylorotwell marked this pull request as draft September 24, 2024 14:43
@hafezdivandari
Copy link
Contributor Author

@taylorotwell the bugs I mentioned earlier are now fixed and the upgrade guide is updated.

@hafezdivandari hafezdivandari marked this pull request as ready for review October 8, 2024 10:32
@taylorotwell taylorotwell merged commit ef122ad into laravel:13.x Oct 8, 2024
4 checks passed
@hafezdivandari hafezdivandari deleted the 13.x-deprecate-json-api branch October 8, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants