如何生成带有幼仔护照的短令牌?
我使用的是Laravel Passport和密码授予模式,我发现它生成的访问令牌很长,如下所示:
{
"token_type": "Bearer",
"expires_in": 31536000,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjRmOTlkNDI2ZmIxN2I5OGVmNzExYzMyOGQ2YzMwODBhOGY4OGVjYWI4Yjg3Zjg2MmFkNWFlNGI5MzdiYjg0MGQ3MDk2NWI2OWY4NDk3MTE0In0.eyJhdWQiOiIyIiwianRpIjoiNGY5OWQ0MjZmYjE3Yjk4ZWY3MTFjMzI4ZDZjMzA4MGE4Zjg4ZWNhYjhiODdmODYyYWQ1YWU0YjkzN2JiODQwZDcwOTY1YjY5Zjg0OTcxMTQiLCJpYXQiOjE0ODk0NDAzODEsIm5iZiI6MTQ4OTQ0MDM4MSwiZXhwIjoxNTIwOTc2MzgxLCJzdWIiOiIyIiwic2NvcGVzIjpbXX0.XEY0vMoUt6Z9cWMkELQhfcaC2uab8odQLmIVTh8YWULSYOPuw4vpTDFurgU2vflM8-5PYuIIOnw8-8CQVZvetkYLpp2r0GqdNPIcCwlZNh9zRFLLigJ1vm4GKsbGozoDieR9FBpvQ2K9gFM0V4kwjSwx74fdlC1imC1rZ8qRYy5e1zctrMSrVcGcT5F4PTm4DdTN50IRcsOIJK9T6Wgec-iYmey0-xKg0UQroCF6rZUtC0VlH8XwhW_1QfrCl7dkKIcEbWi4pgzDpwrLMZgLAQpPktCP2G9SujC99e7M_L3C8Y647enwUQSTKtp6xNyTyyHSqS0NAxU4U0TFTICMPH5D_L_WaTeBCLS3MdwM3cmTQdkjdXjljjurHld3yEvVemo7oAr2Wb_HOC1uFET0ndeVGI1ZhgM-AuUBy1dJrV4a0iyUIiVtO12LadFIK2m9h0YQlawN1me_HQy6FxdBQuMJ3WIuR3Mwp79RHkoYKFQGvfxTTK8N0emZzmLl5rODp6n7I1UKDb_g7weHdmFP2paTJCApikIXidYA-QXa1i2qMfCwB7gF_kqBvrOyL29wFFRBc_ACRA-0I8iEhZ18vF7htKkPgWoYyPzBKHjVJ4vrxV_VxbGcszIC5byAJKcmpcXEOnFXkFV7NF-tOb___hw9THTjYQmznM1OS__U8zA",
"refresh_token": "RXFyjx21XaLKgkOXa5zZyVbhRqXDsRZbfsFZmxst4Un0+VWtl0xTn/jIOPzApdqFFoTBCH08Ytjxf6SlcEOIUuHhN5+V7wuun/nFCuKIoC2T1xg9Ny2KkzRq0IF+bSBgtZ5QXfu+ILkCSZ/uh39rRxpoO4aqcnJp2Bvj5wuVcFra2nnPCu/Rfs+AN7MA5H8WgzfLmsIFsh3/rtzU4KboFR0rQE4MrDecrJCmCjvAJS52LLdFhDnNi/KdjhxBXY7jpgXZF+HOLAribGPn9COoC7B9zGoYHA3zaOMopsJ+NaRTHsuf2VbXlrQ4eXME5XVB4+TpgU8LGipK1jv5Ndhfu/VJaxgRk94VEuAcYu4vWUEdNl5Y4sRPDSlIpwjnXxdiiAUuNnvbrUaRD/qStJmmzQiWe7M07qVTHp4PNrVOVhjZkIsFMWoMsRHWtDu0eRbde3tBOhIWUCwxndp9Ma9DlSwuq6jmhv/mi62QboYjgZrWJAqLSIeP13mRyH0kNR4LCauCpiXgaPPTywBBfYpEIn34DQeo9QQfvnnut9ky8hRgniQjhGbvgeyIOS7WgmDR0Wmbt0jwLY5MWl5WuyhAJztQPnt0sTLxWzey0ZCRC5DWMSzt/g8cTL7cfjCxPYYdLCsAYE6eXTEaA3zZLre2GnBJwwE0+3bIRctQDH9zYRE="
}
我知道长令牌会更安全,但超过1000个字符似乎有点可怕。在我的印象中,JWT通常很小,但在这里,这个生成的令牌是如此长、如此大。
我想生成更短的令牌,有什么好方法可以做到这一点?
如果Laravel Passport能够指定令牌长度?
解决方案
如果您觉得需要缩短令牌长度,或许应该使用以下命令重新生成密钥对文件:
php artisan passport:keys --length=512 --force
相关文章