php-istio/jwt-authentication-bundle
最新稳定版本:v2.0.0
Composer 安装命令:
composer require php-istio/jwt-authentication-bundle
包简介
Symfony bundle to help authenticate JWT payload from Istio Envoy proxy.
README 文档
README
About
The Symfony bundle provides JWT authentication for request forwarded by Istio sidecar.
To use this bundle, make sure your K8S application pod had injected Istio sidecar and configured RequestAuthentication CRD, if not your application IS NOT SECURE.
The main difference between the awesome Lexik JWT Authentication bundle and this bundle is it's NOT validate JWT token because Istio sidecar had validated before forward request to your application, so that your application don't need to hold public key and double validate JWT token.
Requirements
PHP versions:
- PHP 8.0
Symfony versions:
- Symfony 5.3
Installation
composer require php-istio/jwt-authentication-bundle
Configuration
Enable the authenticator manager setting:
# config/packages/security.yaml security: enable_authenticator_manager: true # ...
Then, configure your config/packages/security.yaml:
security: enable_authenticator_manager: true access_control: - path: ^/ roles: IS_AUTHENTICATED_FULLY firewalls: #... main: stateless: true istio_jwt_authenticator: rules: - issuer: issuer_1 # Required user_identifier_claim: sub #Default is `sub` claim origin_token_headers: [authorization] #Required at least once of `origin_token_headers`, `origin_token_query_params` or `base64_headers`. Use this option when your Istio JWTRule CRD using `forwardOriginalToken`. origin_token_query_params: [token] #Use this option when your Istio JWTRule CRD using `forwardOriginalToken` and your JWT token in query param. base64_headers: [x-istio-jwt-payload] # Use this option when your Istio JWTRule CRD using `outputPayloadToHeader`. prefix: "Bearer " #Token prefix of origin token passthrough by default blank ("") if not set.
In case your application have multi issuers:
#.... main: stateless: true istio_jwt_authenticator: rules: - issuer: issuer_1 origin_token_headers: [authorization] prefix: "Bearer " - issuer: issuer_2 user_identifier_claim: aud base64_headers: [x-istio-jwt-payload] #....
Usage
#!/bin/bash #Generate mock JWT token forwarded by Istio sidecar payload='{"issuer":"issuer_1", "sub": "test"}'; base64_payload=$(echo -n $payload | base64 -); origin_token=$(echo "header.$base64_payload.signature"); #You can test authenticate origin token with curl: curl -H "Authorization: Bearer $origin_token" http://localhost/ #Or authenticate base64 payload header: curl -H "X-Istio-JWT-Payload: $base64_payload" http://localhost/
Further readings
Credits
php-istio/jwt-authentication-bundle 适用场景与选型建议
php-istio/jwt-authentication-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 30.63k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 06 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 php-istio/jwt-authentication-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 php-istio/jwt-authentication-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 30.63k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-27