Registry / auth-security / jose
library1.0.0pypypiunverified

The `jose` library by Demonware is an older Python implementation of the JSON Object Signing and Encryption (JOSE) framework, supporting JSON Web Signatures (JWS) and JSON Web Encryptions (JWE). Last released in 2015 with version 1.0.0, it was primarily developed for Python 2 and relies on the unmaintained `pycrypto` library. Due to its inactivity and dependency on outdated cryptographic components, it is not recommended for new projects or secure applications.

pip install jose
INSTALL
IMPORT
SIG · JOSE
J
jose
auth-securitypythonv1.0.0
Install
2.4s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.4s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sign
from jose import sign
from jose import sign

This quickstart demonstrates basic JWS signing/verification and JWE encryption/decryption using the `jose` library (Demonware). It illustrates how to define headers, use RSA keys (generated for demonstration), and call the core `sign`, `verify`, `encrypt`, and `decrypt` functions. Note the explicit requirement for `pycrypto` and the caveats regarding its suitability for modern, secure applications.

import jose from time import time # NOTE: For modern Python and security, consider `pip install python-jose[cryptography]` instead. # This example is for the *Demonware jose* library, which uses the deprecated `pycrypto`. # Ensure `pycrypto` is installed (e.g., `pip install pycrypto==2.6.1`) # For generating RSA keys safely, a more robust library like `cryptography` or `PyCryptodome` # would be used in a real application, not the raw `Crypto.PublicKey.RSA` as it relies on pycrypto. try: from Crypto.PublicKey import RSA except ImportError: print("Error: `pycrypto` not found. Please install it (pip install pycrypto==2.6.1).") # Exit or handle error gracefully in a real script exit(1) # Generate a new RSA key pair for demonstration purposes # In a real app, you would load pre-existing keys securely. key = RSA.generate(2048) # Generates an RSA key with 2048 bits claims = { 'iss': 'http://www.example.com', 'exp': int(time() + 3600), # Expiration time (1 hour from now) 'aud': 'http://www.example.org', 'sub': 'testuser', 'nbf': int(time()) # Not Before time } # --- JWS (JSON Web Signature) Example --- # Define JWS Protected Header protected_jws_header = { 'alg': 'RS256' # RSA Signature with SHA-256 } try: # Sign the claims with the private key signed_jws = jose.sign(protected_jws_header, claims, key) print("Signed JWS:", signed_jws) # Verify the JWS with the public key verified_claims = jose.verify(signed_jws, key.publickey()) print("Verified JWS Claims:", verified_claims) # --- JWE (JSON Web Encryption) Example --- # Define JWE Protected Header protected_jwe_header = { 'alg': 'RSA-OAEP', # Algorithm for Content Encryption Key (CEK) encryption 'enc': 'A128CBC-HS256' # Algorithm for content encryption } # Encrypt the claims with the recipient's public key encrypted_jwe = jose.encrypt(protected_jwe_header, claims, key.publickey()) print("Encrypted JWE:", encrypted_jwe) # Decrypt the JWE with the recipient's private key decrypted_jwe_payload = jose.decrypt(encrypted_jwe, key) print("Decrypted JWE Payload:", decrypted_jwe_payload) except jose.Error as e: print(f"JOSE Error: {e}") except Exception as e: print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingVersion 1.0.0 introduced a backward-incompatible change related to authentication tag computation for JWE. Tokens produced by `jose < 1.0.0` cannot be decrypted by `jose 1.0.0` due to a change in the JWE hash string calculation.
fix
Ensure all parties use `jose` version 1.0.0 or higher, or re-issue tokens compatible with the newer standard. Consider migrating to a more actively maintained library for forward compatibility and security.
affects: < 1.0.0
gotchaThe `jose` library (Demonware) is often confused with `python-jose`, a separate, more actively maintained library with a similar purpose but a different API. The Demonware `jose` is imported directly (e.g., `import jose`), while `python-jose` typically uses `from jose import jwt`.
fix
Verify the project's GitHub repository (`github.com/Demonware/jose`) to confirm you are using the correct library. Be aware of the distinct import patterns and APIs.
affects: All
breakingThis library explicitly targets Python 2, as indicated by its PyPI classifiers (`Programming Language :: Python :: 2 :: Only`). While it might run on some Python 3 environments, it has unresolved issues and is not officially supported or tested for Python 3, leading to potential unexpected behavior or errors.
fix
For new projects or Python 3 environments, strongly consider using actively maintained JOSE libraries like `python-jose` or `Authlib` which provide Python 3 compatibility and modern security practices.
affects: Python 3.x
breakingThe `jose` library relies on `pycrypto` for its cryptographic operations, which is an outdated, unmaintained, and potentially insecure library with known vulnerabilities. Using `jose` in production for sensitive data is a significant security risk.
fix
Migrate to a modern, actively maintained JOSE library that uses up-to-date and secure cryptographic backends (e.g., `cryptography` library), such as `python-jose[cryptography]` or `Authlib`.
affects: All
Upgrade
Version history
1.0.0latest on PyPI · released Nov 13, 2015
Audit
Dependencies
pycryptorequiredCore cryptographic operations. This library is deprecated and has known security vulnerabilities, making `jose` unsuitable for secure applications.
Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources