Add dedicated token lifetime for client credentials grant#1880
Add dedicated token lifetime for client credentials grant#1880taylorotwell merged 2 commits intolaravel:13.xfrom
Conversation
|
Related to #1847 (comment) Being able to set a custom expiration time for client credential tokens is useful, but my suggestion is to set the default to 1 year as is, and send it against 13.x without a breaking change. Then you can send another PR/issue to request for 1 hour default in the next major version. |
I think that is fair. I will do just that later today. Thanks. |
0b0b1d3 to
9637ccf
Compare
|
Took me a while to come back to this - apologies. The PR has been fixed/updated. |
Summary
This PR adds a
Passport::clientCredentialsTokensExpireIn()method for configuring token lifetimes specifically for the client credentials grant, mirroring the existingpersonalAccessTokensExpireIn()pattern.This is a non-breaking change. When not explicitly configured, client credentials tokens continue to use
Passport::tokensExpireIn()as before.Motivation
The client credentials grant is designed for autonomous machine-to-machine interactions where tokens are regenerated automatically. Currently there is no way to configure token lifetime specifically for this grant type without affecting all other grants.
Many developers using Laravel Passport may not be familiar with the security implications of long-lived tokens or the nuances between OAuth 2.0 grant types. Providing a dedicated configuration method helps guide them toward better security practices.
Industry Guidance
Usage
Changes
Passport::$clientCredentialsTokensExpireInproperty andPassport::clientCredentialsTokensExpireIn()methodclientCredentialsTokensExpireIn() ?? tokensExpireIn()for backwards compatibility