@@ -21,27 +21,45 @@ public function up(): void
2121 $ table ->renameColumn ('user_id ' , 'owner_id ' );
2222 $ table ->string ('owner_type ' )->after ('owner_id ' )->nullable ();
2323 });
24+
2425 DB ::table ('oauth_clients ' )
25- ->where ('personal_access_client ' , 1 )
26- ->update (['grant_types ' => ['personal_access ' ]]);
27- DB ::table ('oauth_clients ' )
28- ->where ('password_client ' , 1 )
29- ->update (['grant_types ' => ['password ' , 'refresh_token ' ]]);
30- DB ::table ('oauth_clients ' )
31- ->where ('password_client ' , 0 )
32- ->where ('personal_access_client ' , 0 )
33- ->update (['grant_types ' => ['client_credentials ' ]]);
26+ ->where ('redirect ' , '= ' , 'http://localhost ' )
27+ ->where ('personal_access_client ' , '= ' , true )
28+ ->update (['redirect ' => '' ]);
3429
3530 DB ::table ('oauth_clients ' )
3631 ->whereNotNull ('owner_id ' )
3732 ->update (['owner_type ' => 'user ' ]); // Value might be class name of the owner model, depends on if you use "enforceMorphMap"
3833
3934 DB ::table ('oauth_clients ' )->eachById (function ($ client ): void {
40- $ redirectUris = [$ client ->redirect ];
35+ $ grantTypes = ['urn:ietf:params:oauth:grant-type:device_code ' , 'refresh_token ' ];
36+ $ confidential = ! empty ($ client ->secret );
37+ $ noRedirect = empty ($ client ->redirect );
38+ $ redirectUris = $ noRedirect ? [] : [$ client ->redirect ];
39+ $ firstParty = empty ($ client ->owner_id );
40+
41+ if (! $ noRedirect ) {
42+ $ grantTypes [] = 'authorization_code ' ;
43+ $ grantTypes [] = 'implicit ' ;
44+ }
45+
46+ if ($ confidential && $ firstParty ) {
47+ $ grantTypes [] = 'client_credentials ' ;
48+ }
49+
50+ if ($ client ->personal_access_client && $ confidential ) {
51+ $ grantTypes [] = 'personal_access ' ;
52+ }
53+
54+ if ($ client ->password_client ) {
55+ $ grantTypes [] = 'password ' ;
56+ }
57+
4158 DB ::table ('oauth_clients ' )
4259 ->where ('id ' , $ client ->id )
4360 ->update ([
4461 'redirect_uris ' => $ redirectUris ,
62+ 'grant_types ' => $ grantTypes ,
4563 ]);
4664 });
4765
0 commit comments