login512-fastapi 2.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- login512_fastapi-2.1.1/PKG-INFO +53 -0
- login512_fastapi-2.1.1/README.md +28 -0
- login512_fastapi-2.1.1/login512_fastapi.egg-info/PKG-INFO +53 -0
- login512_fastapi-2.1.1/login512_fastapi.egg-info/SOURCES.txt +8 -0
- login512_fastapi-2.1.1/login512_fastapi.egg-info/dependency_links.txt +1 -0
- login512_fastapi-2.1.1/login512_fastapi.egg-info/requires.txt +2 -0
- login512_fastapi-2.1.1/login512_fastapi.egg-info/top_level.txt +1 -0
- login512_fastapi-2.1.1/login512_fastapi.py +70 -0
- login512_fastapi-2.1.1/setup.cfg +4 -0
- login512_fastapi-2.1.1/setup.py +24 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: login512-fastapi
|
|
3
|
+
Version: 2.1.1
|
|
4
|
+
Summary: FastAPI Security Dependency for Login512 Post-Quantum Biometrics and Passkeys
|
|
5
|
+
Home-page: https://login512.com
|
|
6
|
+
Author: Login512 Team
|
|
7
|
+
Author-email: support@login512.com
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: fastapi>=0.100.0
|
|
14
|
+
Requires-Dist: httpx>=0.24.0
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: author-email
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: license
|
|
22
|
+
Dynamic: requires-dist
|
|
23
|
+
Dynamic: requires-python
|
|
24
|
+
Dynamic: summary
|
|
25
|
+
|
|
26
|
+
# login512-fastapi
|
|
27
|
+
|
|
28
|
+
FastAPI Security Dependency for **Login512** Post-Quantum Biometrics and Passkeys.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
```bash
|
|
32
|
+
pip install login512-fastapi
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
```python
|
|
37
|
+
import os
|
|
38
|
+
from fastapi import FastAPI, Depends
|
|
39
|
+
from login512_fastapi import Login512Bearer
|
|
40
|
+
|
|
41
|
+
app = FastAPI()
|
|
42
|
+
auth_guard = Login512Bearer(secret_key=os.environ["LOGIN512_SECRET_KEY"])
|
|
43
|
+
|
|
44
|
+
@app.get("/api/user/profile")
|
|
45
|
+
async def get_user_profile(user_claims: dict = Depends(auth_guard)):
|
|
46
|
+
return {
|
|
47
|
+
"status": "authenticated",
|
|
48
|
+
"user_id": user_claims.get("sub"),
|
|
49
|
+
"mode": user_claims.get("mod"),
|
|
50
|
+
"risk": user_claims.get("risk"),
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# login512-fastapi
|
|
2
|
+
|
|
3
|
+
FastAPI Security Dependency for **Login512** Post-Quantum Biometrics and Passkeys.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
```bash
|
|
7
|
+
pip install login512-fastapi
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
```python
|
|
12
|
+
import os
|
|
13
|
+
from fastapi import FastAPI, Depends
|
|
14
|
+
from login512_fastapi import Login512Bearer
|
|
15
|
+
|
|
16
|
+
app = FastAPI()
|
|
17
|
+
auth_guard = Login512Bearer(secret_key=os.environ["LOGIN512_SECRET_KEY"])
|
|
18
|
+
|
|
19
|
+
@app.get("/api/user/profile")
|
|
20
|
+
async def get_user_profile(user_claims: dict = Depends(auth_guard)):
|
|
21
|
+
return {
|
|
22
|
+
"status": "authenticated",
|
|
23
|
+
"user_id": user_claims.get("sub"),
|
|
24
|
+
"mode": user_claims.get("mod"),
|
|
25
|
+
"risk": user_claims.get("risk"),
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: login512-fastapi
|
|
3
|
+
Version: 2.1.1
|
|
4
|
+
Summary: FastAPI Security Dependency for Login512 Post-Quantum Biometrics and Passkeys
|
|
5
|
+
Home-page: https://login512.com
|
|
6
|
+
Author: Login512 Team
|
|
7
|
+
Author-email: support@login512.com
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: fastapi>=0.100.0
|
|
14
|
+
Requires-Dist: httpx>=0.24.0
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: author-email
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: license
|
|
22
|
+
Dynamic: requires-dist
|
|
23
|
+
Dynamic: requires-python
|
|
24
|
+
Dynamic: summary
|
|
25
|
+
|
|
26
|
+
# login512-fastapi
|
|
27
|
+
|
|
28
|
+
FastAPI Security Dependency for **Login512** Post-Quantum Biometrics and Passkeys.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
```bash
|
|
32
|
+
pip install login512-fastapi
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
```python
|
|
37
|
+
import os
|
|
38
|
+
from fastapi import FastAPI, Depends
|
|
39
|
+
from login512_fastapi import Login512Bearer
|
|
40
|
+
|
|
41
|
+
app = FastAPI()
|
|
42
|
+
auth_guard = Login512Bearer(secret_key=os.environ["LOGIN512_SECRET_KEY"])
|
|
43
|
+
|
|
44
|
+
@app.get("/api/user/profile")
|
|
45
|
+
async def get_user_profile(user_claims: dict = Depends(auth_guard)):
|
|
46
|
+
return {
|
|
47
|
+
"status": "authenticated",
|
|
48
|
+
"user_id": user_claims.get("sub"),
|
|
49
|
+
"mode": user_claims.get("mod"),
|
|
50
|
+
"risk": user_claims.get("risk"),
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
login512_fastapi
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""
|
|
2
|
+
login512_fastapi — FastAPI Security Dependency for Login512 Post-Quantum Biometrics
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
from typing import Any, Optional
|
|
7
|
+
|
|
8
|
+
from fastapi import Depends, HTTPException, Request, status
|
|
9
|
+
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
|
10
|
+
|
|
11
|
+
import httpx
|
|
12
|
+
|
|
13
|
+
_security = HTTPBearer(auto_error=False)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Login512Bearer:
|
|
17
|
+
"""FastAPI Security Dependency that validates Login512 ML-DSA tokens."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, secret_key: str, endpoint: str = "https://api.login512.com"):
|
|
20
|
+
if not secret_key.startswith("l512_sk_"):
|
|
21
|
+
raise ValueError("Invalid secret_key: must start with 'l512_sk_'")
|
|
22
|
+
self.secret_key = secret_key
|
|
23
|
+
self.endpoint = endpoint.rstrip("/")
|
|
24
|
+
|
|
25
|
+
async def __call__(
|
|
26
|
+
self,
|
|
27
|
+
credentials: Optional[HTTPAuthorizationCredentials] = Depends(_security),
|
|
28
|
+
) -> dict[str, Any]:
|
|
29
|
+
if not credentials or not credentials.credentials:
|
|
30
|
+
raise HTTPException(
|
|
31
|
+
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
32
|
+
detail="Missing Bearer authentication token",
|
|
33
|
+
headers={"WWW-Authenticate": "Bearer"},
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
token = credentials.credentials.strip()
|
|
37
|
+
try:
|
|
38
|
+
async with httpx.AsyncClient(timeout=5.0) as client:
|
|
39
|
+
res = await client.post(
|
|
40
|
+
f"{self.endpoint}/v1/token/verify",
|
|
41
|
+
headers={"Authorization": f"Bearer {self.secret_key}"},
|
|
42
|
+
json={"token": token},
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
if res.status_code != 200:
|
|
46
|
+
raise HTTPException(
|
|
47
|
+
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
48
|
+
detail="Invalid or expired Login512 biometric token",
|
|
49
|
+
headers={"WWW-Authenticate": "Bearer"},
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
data = res.json()
|
|
53
|
+
if data.get("valid") is not True:
|
|
54
|
+
raise HTTPException(
|
|
55
|
+
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
56
|
+
detail=data.get("error", "Biometric token verification failed"),
|
|
57
|
+
headers={"WWW-Authenticate": "Bearer"},
|
|
58
|
+
)
|
|
59
|
+
if data.get("step_up_required") is True:
|
|
60
|
+
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="STEP_UP_REQUIRED")
|
|
61
|
+
|
|
62
|
+
return data.get("claims", {})
|
|
63
|
+
except HTTPException:
|
|
64
|
+
raise
|
|
65
|
+
except Exception as e:
|
|
66
|
+
raise HTTPException(
|
|
67
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
68
|
+
detail=f"Verification gateway error: {str(e)}",
|
|
69
|
+
)
|
|
70
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="login512-fastapi",
|
|
5
|
+
version="2.1.1",
|
|
6
|
+
description="FastAPI Security Dependency for Login512 Post-Quantum Biometrics and Passkeys",
|
|
7
|
+
author="Login512 Team",
|
|
8
|
+
author_email="support@login512.com",
|
|
9
|
+
long_description=open("README.md", encoding="utf-8").read(),
|
|
10
|
+
long_description_content_type="text/markdown",
|
|
11
|
+
license="Apache-2.0",
|
|
12
|
+
url="https://login512.com",
|
|
13
|
+
python_requires=">=3.9",
|
|
14
|
+
py_modules=["login512_fastapi"],
|
|
15
|
+
install_requires=[
|
|
16
|
+
"fastapi>=0.100.0",
|
|
17
|
+
"httpx>=0.24.0",
|
|
18
|
+
],
|
|
19
|
+
classifiers=[
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"License :: OSI Approved :: Apache Software License",
|
|
22
|
+
],
|
|
23
|
+
)
|
|
24
|
+
|