Metadata-Version: 2.2
Name: fastsecure
Version: 0.1.0
Summary: Flexible authentication system for FastAPI applications
Author-email: Igor Benav <igor.magalhaes.r@gmail.com>
Keywords: fastapi,authentication,oauth,jwt,session
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Security
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: fastapi>=0.115.8
Requires-Dist: httpx>=0.28.1
Requires-Dist: pydantic>=2.10.6
Requires-Dist: python-jose[cryptography]>=3.3.0
Requires-Dist: python-multipart>=0.0.20
Requires-Dist: redis>=5.2.1
Requires-Dist: sqlalchemy>=2.0.37

# FastSecure

FastVerify is a flexible authentication system for FastAPI applications that supports multiple authentication methods and allows them to be used individually or in combination.

## Features

- 🔐 Multiple authentication methods:
  - JWT tokens (with refresh token support)
  - Session-based authentication
  - OAuth providers (Google, GitHub, etc.)
- 🔄 Combine multiple authentication methods
  - Require all methods (AND logic)
  - Allow alternative methods (OR logic)
  - Optional authentication methods
- 🛠️ Easy to extend with new providers
- 🔌 Pluggable architecture
- 🚀 FastAPI integration with middleware and dependencies
- ✨ Type hints and modern Python features

## Installation

```bash
pip install fastverify
```

## Quick Start

Here's a simple example using JWT authentication:

```python
from fastapi import FastAPI, Depends
from fastverify import (
    AuthenticationManager,
    JWTAuthenticationProvider,
    requires_auth
)

app = FastAPI()

# Setup authentication
auth_manager = AuthenticationManager()
jwt_auth = JWTAuthenticationProvider(
    secret_key="your-secret-key",
    access_token_expire_minutes=30
)
auth_manager.register_provider("jwt", jwt_auth)
auth_manager.add_requirement("/protected", ["jwt"])

# Protected route
@app.get("/protected")
async def protected_route(auth = Depends(requires_auth("/protected"))):
    return {"message": "Access granted", "user_id": auth.user_id}
```

## Multiple Authentication Methods

You can combine multiple authentication methods:

```python
from fastverify import (
    AuthenticationManager,
    AuthStrategy,
    JWTAuthenticationProvider,
    SessionAuthenticationProvider
)

# Setup providers
auth_manager = AuthenticationManager()
jwt_auth = JWTAuthenticationProvider(secret_key="your-secret-key")
session_auth = SessionAuthenticationProvider()

# Register providers
auth_manager.register_provider("jwt", jwt_auth)
auth_manager.register_provider("session", session_auth)

# Require both JWT and session authentication
auth_manager.add_requirement(
    "/very-secure",
    providers=["jwt", "session"],
    strategy=AuthStrategy.ALL
)

# Allow either JWT or session authentication
auth_manager.add_requirement(
    "/flexible-auth",
    providers=["jwt", "session"],
    strategy=AuthStrategy.ANY
)
```

## OAuth Integration

Adding OAuth providers is straightforward:

```python
from fastverify import GoogleAuthProvider

google_auth = GoogleAuthProvider(
    client_id="your-client-id",
    client_secret="your-client-secret",
    redirect_uri="http://localhost:8000/auth/google/callback"
)
auth_manager.register_provider("google", google_auth)
```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

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