Quick Start Guide¶
Get USSO up and running in under 10 minutes. This guide will walk you through installation, configuration, and your first API call.
Prerequisites¶
Before you begin, make sure you have:
- Docker and Docker Compose installed (Get Docker)
- Basic understanding of REST APIs
- A code editor
Step 1: Install USSO¶
Clone the USSO repository:
Step 2: Configure Environment¶
Copy the sample environment file and edit it:
Edit .env with your favorite editor. At minimum, set these variables:
# Project basics
PROJECT_NAME=my-sso
DOMAIN=localhost
# Database
MONGO_URI=mongodb://localhost:27017/
REDIS_URI=redis://localhost:6379/
# Security (generate a strong password)
SYSTEM_PASSWORD=your-super-secret-password
# Optional: Email for magic links and OTP
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=[email protected]
SMTP_PASSWORD=your-app-password
SMTP_SENDER=[email protected]
SMTP_USE_TLS=true
Generate Secure Passwords
Use a password manager or run: openssl rand -base64 32
Step 3: Start USSO¶
Launch all services with Docker Compose:
This will start:
- USSO API on port 8000
- MongoDB for data storage
- Redis for sessions and caching
Check if services are running:
Step 4: Verify Installation¶
Open your browser and visit:
- API Docs: http://localhost:8000/api/sso/v1/docs
- Alternative Docs: http://localhost:8000/api/sso/v1/redoc
You should see the FastAPI Swagger interface.
Step 5: Create Your First User¶
Now let's create a user via the REST API:
curl -X POST http://localhost:8000/api/sso/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"identifier": "[email protected]",
"secret": "SecurePassword123!",
"register": true
}'
import requests
response = requests.post(
"http://localhost:8000/api/sso/v1/auth/login",
json={
"identifier": "[email protected]",
"secret": "SecurePassword123!",
"register": true
}
)
data = response.json()
access_token = data["access_token"]
print(f"Access token: {access_token}")
const response = await fetch('http://localhost:8000/api/sso/v1/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
identifier: '[email protected]',
secret: 'SecurePassword123!',
register: true
})
});
const data = await response.json();
console.log('Access token:', data.access_token);
The response will include:
{
"access_token": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...",
"refresh_token": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600,
"user": {
"id": "user:abc123",
"tenant_id": "org_default",
"identifiers": [
{
"type": "email",
"identifier": "[email protected]",
"verified": false
}
]
}
}
Congratulations!
You've created your first user! The access_token can be used to authenticate API requests.
Step 6: Access Protected Resources¶
Use the access token to call protected endpoints:
Step 7: Integrate with Your App¶
Now that USSO is running, integrate it with your application using our SDKs:
Option A: Python SDK¶
Install the USSO Python SDK:
Use it in your FastAPI app:
from fastapi import FastAPI, Depends
from usso.integrations.fastapi import get_authenticator
from usso.config import JWTConfig
from usso.schemas import UserData
# Configure USSO
config = JWTConfig(
jwks_url="http://localhost:8000/.well-known/jwks.json",
issuer="http://localhost:8000",
audience="your-app"
)
authenticator = get_authenticator(config)
app = FastAPI()
@app.get("/protected")
def protected_route(user: UserData = Depends(authenticator)):
return {
"message": "Access granted",
"user_id": user.sub,
"roles": user.roles,
"scopes": user.scopes
}
Option B: JavaScript SDK¶
For Node.js or frontend apps, use direct API calls:
// Verify token manually
async function verifyToken(token) {
const response = await fetch('http://localhost:8000/api/sso/v1/auth/verify-token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ token })
});
return await response.json();
}
Common Operations¶
Login (Existing User)¶
curl -X POST http://localhost:8000/api/sso/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"identifier": "[email protected]",
"secret": "SecurePassword123!"
}'
Refresh Token¶
curl -X POST http://localhost:8000/api/sso/v1/auth/refresh \
-H "Content-Type: application/json" \
-d '{
"refresh_token": "YOUR_REFRESH_TOKEN"
}'
Logout¶
curl -X POST http://localhost:8000/api/sso/v1/auth/logout \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Next Steps¶
Now that USSO is running, explore these topics:
- Core Concepts - Understand how USSO works
- Authentication Methods - Setup OAuth, magic links, and more
- Authorization - Configure roles and permissions
- Service Accounts - Create API keys for services
- Production Deployment - Deploy to production
Troubleshooting¶
Port Already in Use¶
If port 8000 is already in use, edit docker-compose.yml to change the port:
Cannot Connect to MongoDB¶
Make sure MongoDB is running:
If needed, restart services:
Token Verification Fails¶
Ensure your JWKS URL is accessible:
Getting Help¶
- Documentation: Browse this site for detailed guides
- GitHub Issues: Report bugs or ask questions
- Email: [email protected]