Stream D: Security hardening — 10 fixes from QA review
- SEC-05: Fail fast if SECRET_KEY is default 'change-me-in-production' - SEC-06: CORS allow_credentials=False (Bearer tokens don't need it) - SEC-08: Input validation on auth schemas (min/max length, username pattern) - SEC-10: .dockerignore files (root, backend, mcp-connector) - SEC-11: Hardcode ALGORITHM='HS256' as constant, remove from settings - CQ-01: Gate crawl scheduler on CRAWL_ENABLED env var (default false) - OS-02: CONTRIBUTING.md - OS-03: CHANGELOG.md with v1.0.0 entry - setup.ps1: Add API_TOKEN generation (Windows parity with setup.sh)
This commit is contained in:
parent
c075eb9257
commit
6e082ce58f
10 changed files with 113 additions and 20 deletions
|
|
@ -13,6 +13,7 @@ from app.config import get_settings
|
|||
from app.database import get_db
|
||||
|
||||
settings = get_settings()
|
||||
ALGORITHM = "HS256" # Hardcoded — not configurable for security
|
||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/api/auth/login", auto_error=False)
|
||||
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ def verify_password(plain: str, hashed: str) -> bool:
|
|||
def create_access_token(user_id: str, expires_delta: timedelta | None = None) -> str:
|
||||
expire = datetime.now(timezone.utc) + (expires_delta or timedelta(minutes=settings.access_token_expire_minutes))
|
||||
payload = {"sub": user_id, "exp": expire}
|
||||
return jwt.encode(payload, settings.secret_key, algorithm=settings.algorithm)
|
||||
return jwt.encode(payload, settings.secret_key, algorithm=ALGORITHM)
|
||||
|
||||
|
||||
async def get_current_user(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue