您知道,Laravel Passport具有以下预定路线:
php artisan route:list
+--------+----------+-----------------------------------------+------+---------------------------------------------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+-----------------------------------------+------+---------------------------------------------+--------------+
| | GET|HEAD | / | | Closure | web |
| | POST | oauth/authorize | | ...\ApproveAuthorizationController@approve | web,auth |
| | GET|HEAD | oauth/authorize | | ...\AuthorizationController@authorize | web,auth |
| | DELETE | oauth/authorize | | ...\DenyAuthorizationController@deny | web,auth |
| | GET|HEAD | oauth/clients | | ...\ClientController@forUser | web,auth |
| | POST | oauth/clients | | ...\ClientController@store | web,auth |
| | PUT | oauth/clients/{client_id} | | ...\ClientController@update | web,auth |
| | DELETE | oauth/clients/{client_id} | | ...\ClientController@destroy | web,auth |
| | GET|HEAD | oauth/personal-access-tokens | | ...\PersonalAccessTokenController@forUser | web,auth |
| | POST | oauth/personal-access-tokens | | ...\PersonalAccessTokenController@store | web,auth |
| | DELETE | oauth/personal-access-tokens/{token_id} | | ...\PersonalAccessTokenController@destroy | web,auth |
| | GET|HEAD | oauth/scopes | | ...\ScopeController@all | web,auth |
| | POST | oauth/token | | ...\AccessTokenController@issueToken | throttle |
| | POST | oauth/token/refresh | | ...\TransientTokenController@refresh | web,auth |
| | GET|HEAD | oauth/tokens | | ...\AuthorizedAccessTokenController@forUser | web,auth |
| | DELETE | oauth/tokens/{token_id} | | ...\AuthorizedAccessTokenController@destroy | web,auth |
+--------+----------+-----------------------------------------+------+---------------------------------------------+--------------+
是否可以修改该路线?
例如oauth/authorize
成为api/v1/oauth/authorize
如果是,怎么办?
我一直在寻找答案...
答案 0 :(得分:6)
是的。您可以使用Passport::routes()
方法声明自己的路由。
将此包含在boot()
文件的app/Providers/AuthServiceProvider
方法中。
app / Providers / AuthServiceProvider.php
public function boot()
{
Passport::routes(null, ['prefix' => 'api/v1/oauth']);
}