gpt4 book ai didi

laravel - 是否可以更改/修改 Laravel Passport 中的预定义路线?

转载 作者:行者123 更新时间:2023-12-02 15:57:35 27 4
gpt4 key购买 nike

你知道,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

如果是,怎么做?

我一直在寻找答案......

最佳答案

是的,确实如此。您可以在 Passport::routes() 方法中声明自己的路由。

将其包含在 app/Providers/AuthServiceProvider 文件的 boot() 方法中。

app/Providers/AuthServiceProvider.php

public function boot()
{
Passport::routes(null, ['prefix' => 'api/v1/oauth']);
}

关于laravel - 是否可以更改/修改 Laravel Passport 中的预定义路线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52874091/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com