Metadata-Version: 2.4
Name: hotosm-auth
Version: 0.2.3
Summary: HOTOSM SSO authentication library for Hanko + OSM OAuth
Project-URL: Homepage, https://github.com/hotosm/login
Project-URL: Documentation, https://hotosm.github.io/auth-docs
Project-URL: Repository, https://github.com/hotosm/login/tree/main/auth-libs/python
Project-URL: Issues, https://github.com/hotosm/login/issues
Author-email: HOTOSM <tech@hotosm.org>
License: AGPL-3.0
Keywords: auth,django,fastapi,hanko,hotosm,oauth,osm,sso
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Django
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: cryptography>=41.0.0
Requires-Dist: httpx>=0.25.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pyjwt[crypto]>=2.8.0
Requires-Dist: python-dateutil>=2.8.0
Provides-Extra: dev
Requires-Dist: black>=23.0.0; extra == 'dev'
Requires-Dist: mypy>=1.5.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
Requires-Dist: pytest>=7.4.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: django
Requires-Dist: django>=4.2.0; extra == 'django'
Requires-Dist: djangorestframework>=3.14.0; extra == 'django'
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.104.0; extra == 'fastapi'
Requires-Dist: sqlalchemy>=2.0.0; extra == 'fastapi'
Description-Content-Type: text/markdown

# HOTOSM Auth Library - Python

FastAPI/Django integration for Hanko authentication with OSM OAuth support.

## Installation

```bash
pip install hotosm-auth
```

## Usage

### FastAPI

```python
from fastapi import FastAPI, Depends
from hotosm_auth.integrations.fastapi import CurrentUser

app = FastAPI()

@app.get("/me")
async def get_me(user: CurrentUser):
    return {"id": user.id, "email": user.email}
```

### Django

```python
from django.http import JsonResponse
from hotosm_auth.integrations.django import require_auth

@require_auth
def my_view(request):
    return JsonResponse({"user_id": request.user.id})
```

## Features

- JWT validation for Hanko tokens
- OSM OAuth 2.0 integration
- User mapping between Hanko and application users
- FastAPI and Django integrations

## Configuration

Set these environment variables:

```bash
HANKO_API_URL=https://login.hotosm.org
OSM_CLIENT_ID=your_osm_client_id
OSM_CLIENT_SECRET=your_osm_secret
COOKIE_SECRET=your_secret_key
```

## License

AGPL-3.0
