This document outlines the security standards and practices for the MapleCMS project, ensuring safe development, deployment, and operation across all environments.
MapleCMS follows a security-by-design philosophy, emphasizing data protection, access control, and compliance at every level — from API endpoints to cloud infrastructure.
- Least privilege: Each service and user gets only necessary access.
- Defense in depth: Multiple security layers across API, database, and network.
- Encryption everywhere: HTTPS, TLS, and encrypted storage.
- Continuous monitoring: Real-time alerting and auditing through AWS services.
- Implemented using JWT (JSON Web Tokens).
- Tokens include user ID, role, and expiration.
- Tokens are signed with
HS256orRS256(recommended for production). - Refresh tokens (optional) allow seamless re-authentication.
Example Payload:
{
"sub": "user_12345",
"role": "editor",
"exp": 1735678900
}- Role-based access control (RBAC) enforced at route level.
- Routes are grouped by role (Admin, Editor, Author, Viewer).
- Unauthorized access returns HTTP 403.
Example:
@router.post("/articles/", dependencies=[Depends(require_role("author"))])
async def create_article(...):
...- Passwords are hashed using Argon2 (preferred) or bcrypt.
- Never store raw passwords.
- Password reset links are time-limited and one-time-use.
- API keys and service credentials are stored only in:
- AWS Secrets Manager (prod)
.envfile (local dev, ignored in Git)
password_hash = argon2.hash(user_password)
if not argon2.verify(entered_password, password_hash):
raise HTTPException(status_code=401)
| Layer | Protection |
|---|---|
| Database | Encrypted at rest (AWS RDS encryption) |
| Media Files | Encrypted in S3 using AES-256 SSE |
| API Traffic | HTTPS enforced with AWS ACM certificates |
| Secrets | Stored in AWS Secrets Manager |
| Backups | Encrypted and versioned automatically |
password_hashaccess_tokensrefresh_tokensapi_keys
All sensitive fields are never logged, never sent to frontend, and masked in debug tools.
- All endpoints require HTTPS.
- CORS restricted to frontend domain(s) (
https://maplecms.com). - Rate limiting enabled (via Starlette middleware or AWS API Gateway if extended).
- Input validation enforced via Pydantic schemas.
- Output filtering: only return safe, public fields.
Example:
class UserOut(BaseModel):
id: int
username: str
email: EmailStr
role: str- Validate MIME type and file extension before upload.
- Reject executable files or scripts.
- Sanitize filenames (remove spaces/special characters).
- Upload directly to AWS S3 via presigned URLs.
- Use signed URLs for temporary access to private files.
Example:
s3_client.generate_presigned_url(
'get_object',
Params={'Bucket': 'maplecms-assets', 'Key': 'uploads/article1.png'},
ExpiresIn=3600
)- ECS Services: run in private subnets with public access only via ALB.
- Security Groups: allow minimal inbound/outbound traffic.
- IAM Roles: use fine-grained policies for ECS tasks and Lambda functions.
- CloudWatch Alerts: for login failures, traffic spikes, or CPU anomalies.
- CloudTrail Logs: for full API auditing and compliance.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["ecr:GetAuthorizationToken", "ecr:BatchGetImage"],
"Resource": "*"
}
]
}- Static Analysis: ruff, flake8, bandit
- Dependency Scanning:
pip-audit,npm audit - Penetration Testing: optional quarterly manual review
- CI/CD Checks: automatic scans via GitHub Actions security workflows
- Detect issue (via CloudWatch alert or user report)
- Contain: isolate affected ECS service
- Investigate logs (CloudTrail + ECS task output)
- Rotate affected secrets/keys
- Patch vulnerability
- Document incident in
SECURITY.md
- GDPR & PIPEDA-friendly: only essential user data collected.
- All user data deletable upon request.
- Data access logs retained for 90 days.
- Backups stored in encrypted S3 with versioning enabled.
✅ HTTPS enforced for all endpoints
✅ JWT secrets stored in AWS Secrets Manager
✅ Argon2 password hashing verified
✅ Database encryption enabled
✅ IAM roles reviewed for least privilege
✅ CORS origins whitelisted
✅ CloudWatch + CloudTrail logging active
MapleCMS is designed for trust and transparency — every request, credential, and file is protected by multiple layers of security from edge to database.