toyokumo / jwt-bundle
生成和解析JWT令牌的Symfony支持。
v1.3.0
2024-05-29 04:19 UTC
Requires
- php: ^7.4|^8.0
- sensio/framework-extra-bundle: ~3.0|~4.0|~5.0|~6.0
- symfony/config: ^4.3|~5.0|~6.0
- symfony/dependency-injection: ^4.4|~5.0|~6.0
- web-token/jwt-framework: ^3.4
Requires (Dev)
- phpunit/phpunit: ^8.5
- roave/security-advisories: dev-master
README
生成和解析JWT令牌。
使用方法
JWTService
- 通过.yml文件设置JWK信息。
# key_info.yml
parameters:
jwt_keys:
# for HS256
key_name_for_HS256_key:
kid: current_kid
alg: HS256
secret: 'secret string with more than 32 chars.'
# for RS256 or ES256
key_name_for_RS256_or_ES256_key:
kid: current_kid
alg: RS256 or ES256
filename: 'public or private key filename'
passphrase: 'passphrase to decode key'
-
将.yml文件和密钥文件放在同一目录下。
-
设置参数
# jwt.yml
services:
Toyokumo\JWTBundle\JWTService:
arguments:
$keyDirPath: 'path/to/key_info.yml and key files'
$jwkInfos: '%jwt_keys%' # JWK information defined in key_info.yml