Spaces:
Running
Running
File size: 1,211 Bytes
7d369c8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
"""
Example script to demonstrate how to use the AdaptiveAuth framework
"""
from fastapi import FastAPI
from adaptiveauth import AdaptiveAuth
import uvicorn
# Create a sample FastAPI application
app = FastAPI(title="Example App with AdaptiveAuth")
# Initialize the AdaptiveAuth framework
auth = AdaptiveAuth(
database_url="sqlite:///./example_app.db", # Local database for this example
secret_key="super-secret-key-change-in-production",
enable_2fa=True,
enable_risk_assessment=True,
enable_session_monitoring=True
)
# Integrate AdaptiveAuth with your application
auth.init_app(app, prefix="/auth")
@app.get("/")
async def root():
return {
"message": "Example app with AdaptiveAuth integration",
"endpoints": {
"docs": "/docs",
"auth": "/auth/docs"
}
}
if __name__ == "__main__":
print("Starting AdaptiveAuth example server...")
print("Visit http://localhost:8000/docs for API documentation")
print("Visit http://localhost:8000/auth/docs for authentication endpoints")
uvicorn.run(
"run_example:app",
host="0.0.0.0",
port=8000,
reload=True # Set to False in production
) |