Skip to content

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.

@github-actions
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
@hettiger
Copy link
Contributor

hettiger commented Oct 8, 2025

Jetstream and the new starter kits are very opinionated. I would not make the assumption of anyone using these when making such decisions. I've been using Passport since v7 in my app. Changes like these are very annoying and I think @taylorotwell had a very good point:

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

The given answer is rather disappointing to be honest:

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.

Some apps need third-party client registration. There was a perfectly fine API for them …

Please reconsider the deprecation. If it's just simple CRUD code, it won't be too challenging to maintain this moving forward.

@hafezdivandari
Copy link
Contributor Author

hafezdivandari commented Oct 8, 2025

Jetstream and the new starter kits are very opinionated.

@hettiger The deprectated JSON API was very opinionated too. Also it wasn't customizable. The CRUD must be on the app side.

Some apps need third-party client registration. There was a perfectly fine API for them…

The ClientRepository class is not deprecated, you may see the sample implementation of client registeration on laravel/mcp package:

https://github.com/laravel/mcp/blob/232386959b7df5518484e2b7ccbb6b81451ff436/src/Server/Registrar.php#L105-L128

You may need to add other client metadata according to RFC7591: OAuth 2.0 Dynamic Client Registration Protocol.

If it's just simple CRUD code, it won't be too challenging to maintain this moving forward.

As mentioned above the current API implementation wasn't RFC compatible, not customizable and too opinionated.

@hettiger
Copy link
Contributor

hettiger commented Oct 8, 2025

Jetstream and the new starter kits are very opinionated.

@hettiger The deprectated JSON API was very opinionated too. Also it wasn't customizable. The CRUD must be on the app side.

Some apps need third-party client registration. There was a perfectly fine API for them…

The ClientRepository class is not deprecated, you may see the sample implementation of client registeration on laravel/mcp package:

https://github.com/laravel/mcp/blob/232386959b7df5518484e2b7ccbb6b81451ff436/src/Server/Registrar.php#L105-L128

You may need to add other client metadata according to RFC7591: OAuth 2.0 Dynamic Client Registration Protocol.

If it's just simple CRUD code, it won't be too challenging to maintain this moving forward.

As mentioned above the current API implementation wasn't RFC compatible, not customizable and too opinionated.

We have very different opinions on this and that is totally fine — I understand your arguments from a technical perspective.

However, suggestions like

The ClientRepository class is not deprecated, you may see the sample implementation of client registeration on laravel/mcp package:

https://github.com/laravel/mcp/blob/232386959b7df5518484e2b7ccbb6b81451ff436/src/Server/Registrar.php#L105-L128

You may need to add other client metadata according to RFC7591: OAuth 2.0 Dynamic Client Registration Protocol.

and

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.

are not user friendly at all. Passport offered these features for years. This is not about adding new features that might bloat the package. I think you're too focused on your own interests to be honest.

@hafezdivandari
Copy link
Contributor Author

@hettiger I’m sorry to hear you feel that way. Passport is an open-source project, and I’m just a contributor trying to clarify the reasoning behind the current PR. If you believe a different approach would serve the package better, feel free to open a PR.

That said, it’s important that we stay aligned with RFC7591, and fully supporting that standard through built-in CRUD endpoints isn’t really practical IMHO.

@hettiger
Copy link
Contributor

hettiger commented Oct 8, 2025

@hettiger I’m sorry to hear you feel that way. Passport is an open-source project, and I’m just a contributor trying to clarify the reasoning behind the current PR. If you believe a different approach would serve the package better, feel free to open a PR.

That said, it’s important that we stay aligned with RFC7591, and fully supporting that standard through built-in CRUD endpoints isn’t really practical IMHO.

Thank you for taking the time to answer in-depth on my feedback. Really appreciate it.

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.

4 participants