2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Laravel Passportでgrant_typeを制限する

Posted at

https://qiita.com/h1na/items/25a08122418df782d2b9
ここにほとんど書いてある

Laravel公式に追加しろって書いてあるPassport::routes(); ←これ

public function boot()
    {
        $this->registerPolicies();

        Passport::routes();
    }

たどってPassport.phpをみてみると、 デフォルトのコールバックが$router->all();

public static function routes($callback = null, array $options = [])
    {
        $callback = $callback ?: function ($router) {
            $router->all();
        };
    }

all()って何?って思ったら\Laravel\Passport\RouteRegisterに書いてあった

public function all()
    {
        $this->forAuthorization();
        $this->forAccessTokens();
        $this->forTransientTokens();
        $this->forClients();
        $this->forPersonalAccessTokens();
    }

じゃあ例えば、forAuthorizationforAccessTokensだけ使いたい!ってなったとき

        Passport::routes(function (RouteRegistrar $router) {
            $router->forAuthorization();
            $router->forAccessTokens();
        });

こうすればいい

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?