Skip to content

feat(auth): add HTTP Basic Auth middleware for API protection#1229

Open
YvanJiang wants to merge 1 commit intoagentscope-ai:mainfrom
YvanJiang:feature/http-basic-auth
Open

feat(auth): add HTTP Basic Auth middleware for API protection#1229
YvanJiang wants to merge 1 commit intoagentscope-ai:mainfrom
YvanJiang:feature/http-basic-auth

Conversation

@YvanJiang
Copy link

Summary

Add HTTP Basic Auth middleware to protect API endpoints.

Features

  • Configurable username/password
  • Path exclusion support (e.g., `/webhook/feishu` for webhook endpoints)
  • Secure credential comparison using `secrets.compare_digest`

Configuration

```python

Via environment variables

BASIC_AUTH_USERNAME=admin
BASIC_AUTH_PASSWORD=secret
BASIC_AUTH_EXCLUDED=/webhook/feishu,/health
```

Security

  • Uses constant-time comparison to prevent timing attacks
  • Returns 401 with WWW-Authenticate header on failure

Related

Split from PR #1063

🤖 Generated with Claude Code

Add FastAPI middleware to enforce HTTP Basic Authentication on API endpoints.
Supports configurable username/password and path exclusions.

Features:
- Configurable credentials via environment variables
- Path exclusion support for webhooks
- Constant-time credential comparison using secrets.compare_digest
@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time-contributor PR created by a first time contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant