-
Notifications
You must be signed in to change notification settings - Fork 789
[13.x] Release Passport 13.x #1797
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
Conversation
|
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 With the switching of Passport to a headless approach, have you taken into account Inertia external redirects yet? Specifically in |
|
@jonerickson currently external redirect happens when utilizing "implicit" and "auth code" grants on different places / scenarios:
So it's not easily possible to just bind a response for each case to handle Inertia redirect. But 2 solutions come to mind:
|
|
@hafezdivandari Right - I understand the various locations of all external redirects - was just giving you an exact example of where this can happen. I am not a fan of the This removes the responsibility from the app developer into the framework, hopefully reducing the potential for implementation errors. Whatcha think? |
|
@jonerickson As you know, Passport is headless and not dependent on Inertia, so it is not the right place to handle this edge case. You may refer to laravel/jetstream#1521 and laravel/breeze#398 for more. |
|
@hafezdivandari I have to say, this is amazing work man 🫡 |
|
Hi @taylorotwell just a reminder that this PR is ready for review whenever you have time. Thanks. cc @crynobone |
|
There is nothing in the upgrade guide about the table structure change v12.4.2...v13.0.0#diff-f04f4d4afe9cb4e808417738c29eb3a975e7b8afbae2720ebb6f9eae5a0c530fL15-L24 v12.4.2...v13.0.0#diff-1f43488d747e018afbadd0065346fa6b3da68a5efb3a4471f1df1e5dbbad8712R1 From what I understand this means the previous table structure is incompatible and a migration is needed I have made the following public function up()
{
if (! Schema::hasColumn('oauth_clients', 'owner_type')) {
Schema::dropIfExists('oauth_personal_access_clients');
DB::table('oauth_clients')->update(['provider' => 'admins']); // Needs a default provider now
Schema::table('oauth_clients', function (Blueprint $table) {
$table->text('grant_types')->default('[]')->after('provider');
});
DB::table('oauth_clients')
->where('personal_access_client', 1)
->update(['grant_types' => ['personal_access']]);
DB::table('oauth_clients')
->where('password_client', 1)
->update(['grant_types' => ['password', 'refresh_token']]);
DB::table('oauth_clients')
->where('password_client', 0)
->where('personal_access_client', 0)
->update(['grant_types' => ['client_credentials']]);
// This could be optimized to run all the updates in the eachById
DB::table('oauth_clients')->eachById(function ($client) {
DB::table('oauth_clients')->where('id', $client->id)->update(['secret' => Hash::make($client->secret)]);
});
Schema::table('oauth_clients', function (Blueprint $table) {
$table->renameColumn('user_id', 'owner_id');
$table->string('owner_type')->after('owner_id')->nullable();
$table->dropForeign(['user_id']);
$table->index(['owner_id', 'owner_type']);
$table->dropColumn('redirect');
$table->text('redirect_uris')->default('[]'); // Without the default, a php error will be thrown on all previous clients about array expected
$table->dropColumn('personal_access_client');
$table->dropColumn('password_client');
});
}
}And also added the oauth_device_code migration Am I doing the migration correctly? If so this should be added to the migration guide |
@Tofandel All changes on the schema are backward compatible, so you don't have to change anything, that's why there is no upgarde entry for that. |
|
I see, I still ran into some issues upgrading though. Mainly the secret is now hashed, but before the default was that it wasn't so a migration is needed to hash all the secrets There is also one file the oauth-public.key in storage, that used to be created with 644, but now the app requires that it has 600, and completely errors out if it doesn't have the 600 permissions |
@Tofandel Already explained on upgrade guide: https://github.com/laravel/passport/blob/13.x/UPGRADE.md#client-secrets-hashed-by-default You may run
This is a security enhancement, the check is being done by You may:
|
|
@Tofandel Is the migration that you provided in #1797 (comment) still usable? |

Before Release
After Release
This PR does final touches and improvements that makes Passport ready for release:
OAuthenticatableinterface. Implemented byHasApiTokenstrait.ScopeAuthorizableinterface. Implemented byAccessTokenandTransientTokenclasses.HasApiTokensand theClientmodels:user_idcolumn on theoauth_clientstable and can continue usingHasApiTokens::clients()andClient::user()relation methods.owner_idandowner_typecolumns on theoauth_clientstable and will use newHasApiTokens::oauthApps()andClient::owner()relation methods.HasApiTokenstrait can be used on anyAuthenticatablemodel, but the old relation method were guessing the related models based on the user provider which is wrong. For example, the owner of the client can be an admin but the client's provider is a regular user. New relations are morphable that fixes this bug.clientsrelation method on theHasApiTokenstrait that typically will be used onUsermodel, has a very general name! It's very likely that developers use this relation name on theirUsermodel, which causes conflict. The newoauthAppsandownernames are much clearer for this relationship: The owner has many registered OAuth apps and each OAuth app has an owner.HasApiTokens::clients()method, in favor of the newoauthApps()relation method.Client::user()method, in favor of the newowner()relation method.components.Datefacade instead of Carbon.HasUuidtrait on theClientmodel.nyholm/psr7package. Not needed anymore.EnsureClientIsResourceOwnermiddleware, whereoauth_user_idwasnullprior to version 9.0 ofleague/oauth2-server.$user->tokenCant()method to determine a missing scope. (Sanctum has the same method).lcobucci/jwtpackage. Not needed anymore.expinstead of non-standardexpiryclaim on JWT cookie.Passport::$ignoreCsrfTokenwas set to true.AuthenticationExceptionwhen thrown onAuthorizationController.User::getProvider()method has been renamed togetProviderName().ResolvesInheritedScopes::scopeExists()method has been renamed toscopeExistsIn().