usso-jwt


Nameusso-jwt JSON
Version 0.2.4 PyPI version JSON
download
home_pageNone
SummaryA simple and lightweight Python package for handling JWT (JSON Web Token) operations with USSO (Unified Single Sign-On).
upload_time2025-07-14 10:21:07
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords usso usso-jwt sso authentication security jwt json-web-token token
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # USSO-JWT

A secure and flexible JWT (JSON Web Token) implementation for Python, designed to work seamlessly with the USSO authentication system. This library provides a robust set of tools for creating, signing, verifying, and managing JWTs with support for multiple cryptographic algorithms.

## Features

- **Multiple Algorithm Support**:
  - HMAC (HS256, HS384, HS512)
  - RSA (RS256, RS384, RS512, PS256, PS384, PS512)
  - ECDSA (ES256, ES384, ES512)
  - EdDSA (Ed25519)

- **JWK Support**: Full support for JSON Web Keys (JWK) format
- **PEM Support**: Load keys from PEM-encoded files
- **Type Safety**: Built with type hints for better IDE support and code safety
- **Comprehensive Testing**: Thorough test coverage for all algorithms and features

## Installation

Install using pip:

```bash
pip install usso-jwt
```

## Quick Start

### Creating and Signing a JWT

```python
from usso_jwt import JWT

# Create a JWT with a payload
jwt = JWT(
    payload={
        "sub": "1234567890",
        "name": "John Doe",
        "iat": 1516239022
    }
)

# Sign with HMAC
token = jwt.sign(hmac_key, "HS256")

# Sign with RSA
token = jwt.sign(rsa_private_key, "RS256")

# Sign with ECDSA
token = jwt.sign(ecdsa_private_key, "ES256")

# Sign with EdDSA
token = jwt.sign(eddsa_private_key, "Ed25519")
```

### Verifying a JWT

```python
from usso_jwt import JWT

# Verify with HMAC
jwt = JWT.verify(token, hmac_key, "HS256")

# Verify with RSA
jwt = JWT.verify(token, rsa_public_key, "RS256")

# Verify with ECDSA
jwt = JWT.verify(token, ecdsa_public_key, "ES256")

# Verify with EdDSA
jwt = JWT.verify(token, eddsa_public_key, "Ed25519")
```

### Working with JWKs

```python
from usso_jwt import JWT

# Create a JWT with a JWK
jwt = JWT(payload={"sub": "1234567890"})

# Sign with a JWK
token = jwt.sign(jwk, "RS256")

# Verify with a JWK
jwt = JWT.verify(token, jwk, "RS256")
```

## Supported Algorithms

### HMAC (Symmetric)
- HS256: HMAC with SHA-256
- HS384: HMAC with SHA-384
- HS512: HMAC with SHA-512

### RSA (Asymmetric)
- RS256: RSA with SHA-256
- RS384: RSA with SHA-384
- RS512: RSA with SHA-512
- PS256: RSA-PSS with SHA-256
- PS384: RSA-PSS with SHA-384
- PS512: RSA-PSS with SHA-512

### ECDSA (Asymmetric)
- ES256: ECDSA with P-256 and SHA-256
- ES384: ECDSA with P-384 and SHA-384
- ES512: ECDSA with P-521 and SHA-512

### EdDSA (Asymmetric)
- EdDSA: Ed25519

## Security Considerations

- Always use strong keys appropriate for your chosen algorithm
- For HMAC, use keys at least as long as the hash output (e.g., 32 bytes for HS256)
- For RSA, use keys of at least 2048 bits
- For ECDSA, use the recommended curves (P-256, P-384, P-521)
- Store private keys securely and never expose them
- Use appropriate key rotation policies

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

## License

This project is licensed under the MIT License - see the LICENSE file for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "usso-jwt",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Mahdi Kiani <mahdikiany@gmail.com>",
    "keywords": "usso, usso-jwt, sso, authentication, security, jwt, json-web-token, token",
    "author": null,
    "author_email": "Mahdi Kiani <mahdikiany@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/82/5f/2231867738e39536564b6dcde69b0715e600a2b9153c0903f0c97b2858ad/usso_jwt-0.2.4.tar.gz",
    "platform": null,
    "description": "# USSO-JWT\n\nA secure and flexible JWT (JSON Web Token) implementation for Python, designed to work seamlessly with the USSO authentication system. This library provides a robust set of tools for creating, signing, verifying, and managing JWTs with support for multiple cryptographic algorithms.\n\n## Features\n\n- **Multiple Algorithm Support**:\n  - HMAC (HS256, HS384, HS512)\n  - RSA (RS256, RS384, RS512, PS256, PS384, PS512)\n  - ECDSA (ES256, ES384, ES512)\n  - EdDSA (Ed25519)\n\n- **JWK Support**: Full support for JSON Web Keys (JWK) format\n- **PEM Support**: Load keys from PEM-encoded files\n- **Type Safety**: Built with type hints for better IDE support and code safety\n- **Comprehensive Testing**: Thorough test coverage for all algorithms and features\n\n## Installation\n\nInstall using pip:\n\n```bash\npip install usso-jwt\n```\n\n## Quick Start\n\n### Creating and Signing a JWT\n\n```python\nfrom usso_jwt import JWT\n\n# Create a JWT with a payload\njwt = JWT(\n    payload={\n        \"sub\": \"1234567890\",\n        \"name\": \"John Doe\",\n        \"iat\": 1516239022\n    }\n)\n\n# Sign with HMAC\ntoken = jwt.sign(hmac_key, \"HS256\")\n\n# Sign with RSA\ntoken = jwt.sign(rsa_private_key, \"RS256\")\n\n# Sign with ECDSA\ntoken = jwt.sign(ecdsa_private_key, \"ES256\")\n\n# Sign with EdDSA\ntoken = jwt.sign(eddsa_private_key, \"Ed25519\")\n```\n\n### Verifying a JWT\n\n```python\nfrom usso_jwt import JWT\n\n# Verify with HMAC\njwt = JWT.verify(token, hmac_key, \"HS256\")\n\n# Verify with RSA\njwt = JWT.verify(token, rsa_public_key, \"RS256\")\n\n# Verify with ECDSA\njwt = JWT.verify(token, ecdsa_public_key, \"ES256\")\n\n# Verify with EdDSA\njwt = JWT.verify(token, eddsa_public_key, \"Ed25519\")\n```\n\n### Working with JWKs\n\n```python\nfrom usso_jwt import JWT\n\n# Create a JWT with a JWK\njwt = JWT(payload={\"sub\": \"1234567890\"})\n\n# Sign with a JWK\ntoken = jwt.sign(jwk, \"RS256\")\n\n# Verify with a JWK\njwt = JWT.verify(token, jwk, \"RS256\")\n```\n\n## Supported Algorithms\n\n### HMAC (Symmetric)\n- HS256: HMAC with SHA-256\n- HS384: HMAC with SHA-384\n- HS512: HMAC with SHA-512\n\n### RSA (Asymmetric)\n- RS256: RSA with SHA-256\n- RS384: RSA with SHA-384\n- RS512: RSA with SHA-512\n- PS256: RSA-PSS with SHA-256\n- PS384: RSA-PSS with SHA-384\n- PS512: RSA-PSS with SHA-512\n\n### ECDSA (Asymmetric)\n- ES256: ECDSA with P-256 and SHA-256\n- ES384: ECDSA with P-384 and SHA-384\n- ES512: ECDSA with P-521 and SHA-512\n\n### EdDSA (Asymmetric)\n- EdDSA: Ed25519\n\n## Security Considerations\n\n- Always use strong keys appropriate for your chosen algorithm\n- For HMAC, use keys at least as long as the hash output (e.g., 32 bytes for HS256)\n- For RSA, use keys of at least 2048 bits\n- For ECDSA, use the recommended curves (P-256, P-384, P-521)\n- Store private keys securely and never expose them\n- Use appropriate key rotation policies\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A simple and lightweight Python package for handling JWT (JSON Web Token) operations with USSO (Unified Single Sign-On).",
    "version": "0.2.4",
    "project_urls": {
        "Bug Reports": "https://github.com/ussoio/usso-jwt/issues",
        "Funding": "https://github.com/ussoio/usso-jwt",
        "Homepage": "https://github.com/ussoio/usso-jwt",
        "Say Thanks!": "https://saythanks.io/to/mahdikiani",
        "Source": "https://github.com/ussoio/usso-jwt"
    },
    "split_keywords": [
        "usso",
        " usso-jwt",
        " sso",
        " authentication",
        " security",
        " jwt",
        " json-web-token",
        " token"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "41e63ff3350e7d15fc62ba6dadc68e5b4a000c79e9ea103f2e26210fe5bd71e4",
                "md5": "3f2cc052ae65ae7f6769d570cf3b4410",
                "sha256": "bfde7a54bf89137199852ebeb5accddf58ae94fbe4450d4e5d7b44ca1315be62"
            },
            "downloads": -1,
            "filename": "usso_jwt-0.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3f2cc052ae65ae7f6769d570cf3b4410",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 19449,
            "upload_time": "2025-07-14T10:21:06",
            "upload_time_iso_8601": "2025-07-14T10:21:06.832043Z",
            "url": "https://files.pythonhosted.org/packages/41/e6/3ff3350e7d15fc62ba6dadc68e5b4a000c79e9ea103f2e26210fe5bd71e4/usso_jwt-0.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "825f2231867738e39536564b6dcde69b0715e600a2b9153c0903f0c97b2858ad",
                "md5": "6b7530006c606fc3c3fa6d86405712ae",
                "sha256": "008dce78a8ea67b8429e3535b857c8d3b5e025cc852e5e8a945faf8c380d4ca3"
            },
            "downloads": -1,
            "filename": "usso_jwt-0.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "6b7530006c606fc3c3fa6d86405712ae",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 16492,
            "upload_time": "2025-07-14T10:21:07",
            "upload_time_iso_8601": "2025-07-14T10:21:07.972676Z",
            "url": "https://files.pythonhosted.org/packages/82/5f/2231867738e39536564b6dcde69b0715e600a2b9153c0903f0c97b2858ad/usso_jwt-0.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-14 10:21:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ussoio",
    "github_project": "usso-jwt",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "usso-jwt"
}
        
Elapsed time: 0.44628s