You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

29 lines
807 B

<?php
declare(strict_types=1);
/*
| JWT 配置
|
| 开发便利与生产安全的取舍:
| - APP_DEBUG=true 且未配置 → 用固定 dev 密钥,让开发者开箱能跑
| - APP_DEBUG=false 且未配置 → 留空,JwtService 会抛异常,拒绝启动
| 这样不存在「开发默认密钥被带上生产」的可能,因为生产启动就会失败
*/
$secret = (string) env('jwt.secret', '');
if ($secret === '') {
$is_debug = (bool) env('app_debug', false);
if ($is_debug) {
$secret = 'dev-only-secret-do-not-use-in-production-32+';
}
}
return [
// 签名密钥,必须 >= 32 位
'secret' => $secret,
// token 有效期(秒),默认 7 天;小程序端靠静默登录续期,不需要 refresh token
'ttl' => (int) env('jwt.ttl', 604800),
];