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] Make Passport headless (Support Laravel Jetstream and Breeze) #1771

Merged

Conversation

hafezdivandari
Copy link
Contributor

@hafezdivandari hafezdivandari commented Jul 9, 2024

Passport has a view for authorization / consent, this view doesn't load correctly for many years (maybe since Mix / Bootstrap CSS are not installed on Laravel Skeleton by default). Also more views are needed for Device flow (#1750), makes user experience even worse!

This PR makes Passport headless just like Fortify because Passport doesn't have any pre-installed UI scaffolding. Therefore, we add support for Jetstream and Breeze that already have UI for different stacks:

Changes

  • Makes Passport headless.
    • New Passport::viewPrefix() method (inspired by Fortify).
    • New Passport::viewNamespace() (inspired by Fortify).
  • Add new methods to be compatible with Jetstream and interchangable with Sanctum:
    • New Passport::defaultScopes() method.
    • New Passport::validScopes() method.
    • New User::currentAccessToken() as an alias for User::token() to be interchange with Sanctum.
  • Fix view response and rename it to SimpleViewResponse (inspired by Fortify), to be generic for the future views.
  • Fix Client::firstParty() method. We consider a client first-party when it doesn't belong to any user.

Copy link

github-actions bot commented Jul 9, 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 sorry to bother you, I just wanted to ask your opinion before continuing my work on this.

I'm gonna add a passport:ui artisan command that installs stubs based on user UI preferences. Also I'm gonna add support for Jetstream "API Token Manager". What do you think?

@driesvints
Copy link
Member

Hey @hafezdivandari. That seems fine for us! Thank you so much for all your work on this 👏

@hafezdivandari hafezdivandari changed the title [13.x] Support Laravel Jetstream + Breeze + UI [13.x] Support Laravel Jetstream and Breeze Aug 2, 2024
@hafezdivandari hafezdivandari marked this pull request as ready for review August 5, 2024 14:36
@hafezdivandari hafezdivandari marked this pull request as draft August 5, 2024 22:09
@hafezdivandari hafezdivandari marked this pull request as ready for review August 6, 2024 09:25
@hafezdivandari hafezdivandari changed the title [13.x] Support Laravel Jetstream and Breeze [13.x] Make Passport headless (Support Laravel Jetstream and Breeze) Aug 15, 2024
@inmanturbo
Copy link

@hafezdivandari You've done a great deal of solid work on this throughout the ecosystem and it's much appreciated.

I maintain some custom in house sso servers for a handleful of privately owned businesses, and they all use Passort for oauth. They are all running on forge provisioned servers and so we try keep them up to date to stay in line with current forge offerings.

In the past the way to use passport with something like breeze or jetstream was to publish the view and modify to our needs, or otherwise place our own stub in the resources/views/vendor/passport/authorize.blade.php.

How would this change affect these existing applications?

@hafezdivandari
Copy link
Contributor Author

hafezdivandari commented Aug 18, 2024

Thank you @inmanturbo

When the view is on the resources/views/vendor/passport/authorize.blade.php path, Passport::viewNamespace('passport') should do the work.

As stated on the PR description, more views are comming for the new device flow. Each view will have its own method to render the view (just like Fortify) e.g Passport::authorizationView(), useful for Inertia stack. Also Passport::viewPrefix() and Passport::viewNamespace() helper methods are available to set the path for all views, useful for Livewire stack.

You may also check the upgrade guide entry for more info.

inmanturbo

This comment was marked as outdated.

@taylorotwell taylorotwell merged commit 6142f9c into laravel:13.x Sep 18, 2024
7 checks passed
@hafezdivandari hafezdivandari deleted the 13.x-support-jetstream-breeze-ui branch September 18, 2024 17:33
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