two-fast-auth


Nametwo-fast-auth JSON
Version 1.0.5 PyPI version JSON
download
home_pagehttps://github.com/rennf93/two-fast-auth
SummaryFastAPI 2-Factor Authentication Middleware
upload_time2025-02-01 22:02:42
maintainerNone
docs_urlNone
authorRenzo Franceschini
requires_python>=3.10
licenseMIT
keywords fastapi security 2fa authentication middleware
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Two-Fast-Auth Logo](docs/assets/big_logo.svg)

---

[![PyPI version](https://badge.fury.io/py/two-fast-auth.svg?cache=none)](https://badge.fury.io/py/two-fast-auth)
[![Release](https://github.com/rennf93/two-fast-auth/actions/workflows/release.yml/badge.svg)](https://github.com/rennf93/two-fast-auth/actions/workflows/release.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![CI](https://github.com/rennf93/two-fast-auth/actions/workflows/ci.yml/badge.svg)](https://github.com/rennf93/two-fast-auth/actions/workflows/ci.yml)
[![CodeQL](https://github.com/rennf93/two-fast-auth/actions/workflows/code-ql.yml/badge.svg)](https://github.com/rennf93/two-fast-auth/actions/workflows/code-ql.yml)
[![Docs Update](https://github.com/rennf93/two-fast-auth/actions/workflows/docs.yml/badge.svg)](https://github.com/rennf93/two-fast-auth/actions/workflows/docs.yml)
[![Downloads](https://pepy.tech/badge/two-fast-auth)](https://pepy.tech/project/two-fast-auth)

`two-fast-auth` is a FastAPI middleware that provides seamless two-factor authentication implementation. It integrates with FastAPI to offer robust 2FA protection for your application routes.

---

## Documentation

📚 [Full Documentation](https://rennf93.github.io/two-fast-auth/) - Comprehensive technical documentation and API reference

## Features

- **QR Code Generation**: Automatic QR code creation for authenticator apps
- **TOTP Verification**: Time-based one-time password validation
- **Recovery Codes**: Secure recovery code generation and management
- **Middleware Integration**: Easy integration with FastAPI routes
- **Customizable Templates**: Flexible UI templates for 2FA setup and verification
- **Session Management**: Built-in session tracking for 2FA validation

## Installation

To install `two-fast-auth`, use pip:
```bash
pip install two-fast-auth
```

## Basic Usage

```python
from fastapi import FastAPI
from two_fast_auth import TwoFactorMiddleware, TwoFactorConfig

app = FastAPI()

config = TwoFactorConfig(
    issuer_name="Your App Name",
    excluded_paths=["/docs", "/redoc"],
    qr_code_size=200,
    recovery_codes_count=8
)

app.add_middleware(TwoFactorMiddleware, config=config)

@app.get("/protected-route")
async def protected_route():
    return {"message": "2FA protected content"}
```

## Configuration Options

### TwoFactorConfig

| Parameter           | Default      | Description                                                                 |
|---------------------|--------------|-----------------------------------------------------------------------------|
| `issuer_name`       | Required     | Name displayed in authenticator apps                                        |
| `excluded_paths`    | []           | Paths that bypass 2FA verification                                          |
| `qr_code_size`      | 200          | Size in pixels for generated QR codes                                       |
| `recovery_codes_count` | 10      | Number of recovery codes to generate per user                               |
| `totp_interval`     | 30           | Time interval (seconds) for TOTP codes                                      |
| `session_expiry`    | 3600         | Session duration after successful 2FA verification (seconds)               |

## Advanced Configuration

```python
from two_fast_auth import TwoFactorMiddleware, TwoFactorConfig

config = TwoFactorConfig(
    issuer_name="Secure App",
    excluded_paths=["/public", "/healthcheck"],
    qr_code_size=300,
    recovery_codes_count=12,
    totp_interval=60,
    session_expiry=7200,
    custom_template="custom_2fa.html",
    failed_attempts_limit=5
)
```

## Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

## License

MIT License - See [LICENSE](https://github.com/rennf93/two-fast-auth/blob/main/LICENSE) for details

## Author

**Renzo Franceschini**
- [GitHub Profile](https://github.com/rennf93)
- [Email](mailto:rennf93@gmail.com)

## Acknowledgements

- [FastAPI](https://fastapi.tiangolo.com/)
- [FastAPI Users](https://fastapi-users.github.io/fastapi-users/)
- [PyOTP](https://pyauth.github.io/pyotp/)
- [qrcode](https://github.com/lincolnloop/python-qrcode)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rennf93/two-fast-auth",
    "name": "two-fast-auth",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "fastapi, security, 2fa, authentication, middleware",
    "author": "Renzo Franceschini",
    "author_email": "rennf93@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/dd/a6/2f08dfcdaef8d0e42bfb3d3b31e8c9b09c217381b9ec69501b0b14993ea8/two-fast-auth-1.0.5.tar.gz",
    "platform": null,
    "description": "![Two-Fast-Auth Logo](docs/assets/big_logo.svg)\n\n---\n\n[![PyPI version](https://badge.fury.io/py/two-fast-auth.svg?cache=none)](https://badge.fury.io/py/two-fast-auth)\n[![Release](https://github.com/rennf93/two-fast-auth/actions/workflows/release.yml/badge.svg)](https://github.com/rennf93/two-fast-auth/actions/workflows/release.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![CI](https://github.com/rennf93/two-fast-auth/actions/workflows/ci.yml/badge.svg)](https://github.com/rennf93/two-fast-auth/actions/workflows/ci.yml)\n[![CodeQL](https://github.com/rennf93/two-fast-auth/actions/workflows/code-ql.yml/badge.svg)](https://github.com/rennf93/two-fast-auth/actions/workflows/code-ql.yml)\n[![Docs Update](https://github.com/rennf93/two-fast-auth/actions/workflows/docs.yml/badge.svg)](https://github.com/rennf93/two-fast-auth/actions/workflows/docs.yml)\n[![Downloads](https://pepy.tech/badge/two-fast-auth)](https://pepy.tech/project/two-fast-auth)\n\n`two-fast-auth` is a FastAPI middleware that provides seamless two-factor authentication implementation. It integrates with FastAPI to offer robust 2FA protection for your application routes.\n\n---\n\n## Documentation\n\n\ud83d\udcda [Full Documentation](https://rennf93.github.io/two-fast-auth/) - Comprehensive technical documentation and API reference\n\n## Features\n\n- **QR Code Generation**: Automatic QR code creation for authenticator apps\n- **TOTP Verification**: Time-based one-time password validation\n- **Recovery Codes**: Secure recovery code generation and management\n- **Middleware Integration**: Easy integration with FastAPI routes\n- **Customizable Templates**: Flexible UI templates for 2FA setup and verification\n- **Session Management**: Built-in session tracking for 2FA validation\n\n## Installation\n\nTo install `two-fast-auth`, use pip:\n```bash\npip install two-fast-auth\n```\n\n## Basic Usage\n\n```python\nfrom fastapi import FastAPI\nfrom two_fast_auth import TwoFactorMiddleware, TwoFactorConfig\n\napp = FastAPI()\n\nconfig = TwoFactorConfig(\n    issuer_name=\"Your App Name\",\n    excluded_paths=[\"/docs\", \"/redoc\"],\n    qr_code_size=200,\n    recovery_codes_count=8\n)\n\napp.add_middleware(TwoFactorMiddleware, config=config)\n\n@app.get(\"/protected-route\")\nasync def protected_route():\n    return {\"message\": \"2FA protected content\"}\n```\n\n## Configuration Options\n\n### TwoFactorConfig\n\n| Parameter           | Default      | Description                                                                 |\n|---------------------|--------------|-----------------------------------------------------------------------------|\n| `issuer_name`       | Required     | Name displayed in authenticator apps                                        |\n| `excluded_paths`    | []           | Paths that bypass 2FA verification                                          |\n| `qr_code_size`      | 200          | Size in pixels for generated QR codes                                       |\n| `recovery_codes_count` | 10      | Number of recovery codes to generate per user                               |\n| `totp_interval`     | 30           | Time interval (seconds) for TOTP codes                                      |\n| `session_expiry`    | 3600         | Session duration after successful 2FA verification (seconds)               |\n\n## Advanced Configuration\n\n```python\nfrom two_fast_auth import TwoFactorMiddleware, TwoFactorConfig\n\nconfig = TwoFactorConfig(\n    issuer_name=\"Secure App\",\n    excluded_paths=[\"/public\", \"/healthcheck\"],\n    qr_code_size=300,\n    recovery_codes_count=12,\n    totp_interval=60,\n    session_expiry=7200,\n    custom_template=\"custom_2fa.html\",\n    failed_attempts_limit=5\n)\n```\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request on GitHub.\n\n## License\n\nMIT License - See [LICENSE](https://github.com/rennf93/two-fast-auth/blob/main/LICENSE) for details\n\n## Author\n\n**Renzo Franceschini**\n- [GitHub Profile](https://github.com/rennf93)\n- [Email](mailto:rennf93@gmail.com)\n\n## Acknowledgements\n\n- [FastAPI](https://fastapi.tiangolo.com/)\n- [FastAPI Users](https://fastapi-users.github.io/fastapi-users/)\n- [PyOTP](https://pyauth.github.io/pyotp/)\n- [qrcode](https://github.com/lincolnloop/python-qrcode)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "FastAPI 2-Factor Authentication Middleware",
    "version": "1.0.5",
    "project_urls": {
        "Homepage": "https://github.com/rennf93/two-fast-auth"
    },
    "split_keywords": [
        "fastapi",
        " security",
        " 2fa",
        " authentication",
        " middleware"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ee18d446370031011c7440c616ebb89d6dd6b6380dc21ce61d4a1712213202f4",
                "md5": "c535d990d8bf2aad5f7a038185524fb6",
                "sha256": "58f1c5ac6e7c91dfdae3ec8827c935fe57f95d2fa3fe7e8d1141573d3712a771"
            },
            "downloads": -1,
            "filename": "two_fast_auth-1.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c535d990d8bf2aad5f7a038185524fb6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 5718,
            "upload_time": "2025-02-01T22:02:39",
            "upload_time_iso_8601": "2025-02-01T22:02:39.017282Z",
            "url": "https://files.pythonhosted.org/packages/ee/18/d446370031011c7440c616ebb89d6dd6b6380dc21ce61d4a1712213202f4/two_fast_auth-1.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dda62f08dfcdaef8d0e42bfb3d3b31e8c9b09c217381b9ec69501b0b14993ea8",
                "md5": "1c9f0abd7888234d805f4d0daf841328",
                "sha256": "88e59710ddbcac0629cb409c4f5006d43ecbcd5c3d77f021b8b5db7eafaa1a86"
            },
            "downloads": -1,
            "filename": "two-fast-auth-1.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "1c9f0abd7888234d805f4d0daf841328",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 5227,
            "upload_time": "2025-02-01T22:02:42",
            "upload_time_iso_8601": "2025-02-01T22:02:42.161609Z",
            "url": "https://files.pythonhosted.org/packages/dd/a6/2f08dfcdaef8d0e42bfb3d3b31e8c9b09c217381b9ec69501b0b14993ea8/two-fast-auth-1.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-01 22:02:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rennf93",
    "github_project": "two-fast-auth",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "two-fast-auth"
}
        
Elapsed time: 0.45769s