spomky-labs/jose
最新稳定版本:v7.1.0
Composer 安装命令:
composer require spomky-labs/jose
包简介
JSON Object Signing and Encryption library for PHP.
关键字:
README 文档
README
If you really love that library, then you can help me out for a couple of ????!
⚠️⚠️⚠️
We highly recommend you to use the new JWT Framework project instead of this library.
- Active support of this library is provided until end of 2018.
- Security support will be provided from 2019 and up to end of 2020.
A migration guide will be/is available in the documentation of the new project.
⚠️⚠️⚠️
This library provides an implementation of:
- JWS JSON Web Signature (RFC 7515),
- JWT JSON Web Token (RFC 7519),
- JWE JSON Web Encryption (RFC 7516),
- JWA JSON Web Algorithms (RFC 7518).
- JWK JSON Web Key (RFC 7517).
- JSON Web Key Thumbprint (RFC 7638).
- Unencoded Payload Option RFC7797.
Provided Features
Supported Input Types:
JWS or JWE objects support every input that can be encoded into JSON:
string,array,integer,float...- Objects that implement the
\JsonSerializableinterface such asJWKInterfaceorJWKSetInterface
The detached content is also supported.
Unencoded payload is supported. This means you can sign and verify payload without base64 encoding operation.
As per the RFC7797, the b64 header MUST be protected.
When b64 header is set, the crit protected header with value b64 in its array of values is mandatory.
Supported Serialization Modes
- Compact JSON Serialization Syntax (JWS/JWE creation and loading)
- Flattened JSON Serialization Syntax (JWS/JWE creation and loading)
- General JSON Serialization Syntax (JWS/JWE creation and loading)
Supported Compression Methods
| Compression Method | Supported | Comment |
|---|---|---|
Deflate (DEF) |
YES | |
GZip (GZ) |
YES | This compression method is not described in the specification |
ZLib (ZLIB) |
YES | This compression method is not described in the specification |
Supported Key Types (JWK)
| Key Type | Supported | Comment |
|---|---|---|
none |
YES | None keys are for the none algorithm only |
oct |
YES | Symmetric keys |
RSA |
YES | RSA based asymmetric keys |
EC |
YES | Elliptic Curves based asymmetric keys |
OKP |
YES | Octet Key Pair based asymmetric keys |
JWK objects support JSON Web Key Thumbprint (RFC 7638).
Key Sets (JWKSet)
JWKSet is fully supported.
Supported Signature Algorithms
| Signature Algorithm | Supported | Comment |
|---|---|---|
HS256, HS384 and HS512 |
YES | |
HS256, ES384 and ES512 |
YES | |
RS256, RS384 and RS512 |
YES | |
PS256, PS384 and PS512 |
YES | |
none |
YES | Please note that this is not a secured algorithm. USE IT WITH CAUTION! |
EdDSA with Ed25519 curve |
YES | Third party extension required |
EdDSA with Ed448 curve |
NO |
Please note that the EdDSA signature algorithm specification
is not not yet approved. Support for algorithms Ed25518 and Ed448 may change. Use with caution.
Supported Key Encryption Algorithms
| Key Encryption Algorithm | Supported | Comment |
|---|---|---|
dir |
YES | |
RSA1_5, RSA-OAEP and RSA-OAEP-256 |
YES | |
ECDH-ES, ECDH-ES+A128KW, ECDH-ES+A192KW and ECDH-ES+A256KW |
YES | |
A128KW, A128KW and A128KW |
YES | |
PBES2-HS256+A128KW, PBES2-HS384+A192KW and PBES2-HS512+A256KW |
YES | |
A128GCMKW, A192GCMKW and A256GCMKW |
YES | For better performance, please use PHP 7.1+ or this third party extension |
EdDSA with X25519 curve |
YES | Third party extension required |
EdDSA with X448 curve |
NO |
Please note that the EdDSA encryption algorithm specification
is not not yet approved. Support for algorithms X25518 and X448 may change. Use with caution.
Supported Content Encryption Algorithms
| Content Encryption Algorithm | Supported | Comment |
|---|---|---|
A128CBC-HS256, A192CBC-HS384 and A256CBC-HS512 |
YES | |
A128GCM, A192GCM and A256GCM |
YES | For better performance, please use PHP 7.1+ or this third party extension |
The Release Process
The release process is described here.
Prerequisites
This library needs at least:
Please consider the following optional requirements:
- For AES-GCM based algorithms (
AxxxGCMandAxxxGCMKW) if not on PHP 7.1+: PHP Crypto Extension (at leastv0.2.1) is highly recommended as encryption/decryption is faster than the pure PHP implementation. - For Ed25519 algorithm: php-ed25519-ext required
- For X25519 algorithm: php-curve25519-ext required
Please read performance test results below concerning the ECC based algorithms. As the time needed to perform operation is long compared to the other algorithms, we do not recommend their use.
Continuous Integration
It has been successfully tested using PHP 7.0, PHP 7.1 and PHP7.2 with all algorithms.
If you use PHP 5.6, please install the version ^6.0 of this project.
Tests vectors from the RFC 7520 are fully implemented and all tests pass.
We also track bugs and code quality using Scrutinizer-CI and Sensio Insight.
Coding Standards are verified by StyleCI.
Code coverage is analyzed by Coveralls.io.
Installation
The preferred way to install this library is to rely on Composer:
composer require spomky-labs/jose
How to use
Have a look at How to use to know how to load your JWT and discover all possibilities provided by this library.
Performances
Please read the performance page to know how fast are the algorithms supported by this library.
Contributing
Requests for new features, bug fixed and all other ideas to make this library useful are welcome. If you feel comfortable writting code, you could try to fix opened issues where help is wanted or those that are easy to fix.
Do not forget to follow these best practices.
Licence
This software is release under MIT licence.
spomky-labs/jose 适用场景与选型建议
spomky-labs/jose 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.74M 次下载、GitHub Stars 达 426, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「jwt」 「JWS」 「JWE」 「JOSE」 「jwa」 「JWK」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 spomky-labs/jose 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 spomky-labs/jose 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 spomky-labs/jose 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
JWT, JWS and JWE implementation in PHP
A simple library to decode and parse Apple Sign In client tokens.
A library to work with JSON Web Token and JSON Web Signature.
JSON Web Token Authentication for 5.4+. Modification from Tymon's jwt-auth. For Lower version of Laravel. Please use 0.1.*
JWT, JWS and JWS implementation in PHP
JWT,JWS,JWE library
统计信息
- 总下载量: 2.74M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 428
- 点击次数: 27
- 依赖项目数: 24
- 推荐数: 2
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04