INTERACTIVE DEMO Code-to-Docs: AI-Powered Documentation Updates
Pull requests Issues Marketplace
my-org/my-project/Settings

Setting up Code-to-Docs

1 Add the workflow file

.github/workflows/docs-assistant.yml
name: Documentation Assistant on: issue_comment: types: [created] permissions: contents: read issues: write pull-requests: write jobs: docs-assistant: runs-on: ubuntu-latest if: | github.event.issue.pull_request && (contains(github.event.comment.body, '[review-docs]') || contains(github.event.comment.body, '[update-docs]')) steps: - name: Get PR information id: pr_info if: github.event.issue.pull_request env: GH_TOKEN: ${{ secrets.GH_PAT }} run: | PR_NUMBER=${{ github.event.issue.number }} PR_DATA=$(gh api repos/${{ github.repository }}/pulls/$PR_NUMBER) HEAD_REF=$(echo "$PR_DATA" | jq -r '.head.ref') HEAD_REPO=$(echo "$PR_DATA" | jq -r '.head.repo.full_name') BASE_REF=$(echo "$PR_DATA" | jq -r '.base.ref') echo "head_ref=$HEAD_REF" >> $GITHUB_OUTPUT echo "head_repo=$HEAD_REPO" >> $GITHUB_OUTPUT echo "base_ref=$BASE_REF" >> $GITHUB_OUTPUT echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT - name: Checkout PR Code uses: actions/checkout@v4 with: repository: ${{ steps.pr_info.outputs.head_repo || github.repository }} ref: ${{ steps.pr_info.outputs.head_ref || github.ref }} fetch-depth: 0 token: ${{ secrets.GH_PAT }} - name: Documentation Assistant uses: redhat-community-ai-tools/code-to-docs@main with: model-api-base: ${{ secrets.MODEL_API_BASE }} model-api-key: ${{ secrets.MODEL_API_KEY }} model-name: ${{ secrets.MODEL_NAME }} docs-repo-url: ${{ secrets.DOCS_REPO_URL }} github-token: ${{ secrets.GH_PAT }} pr-number: ${{ github.event.issue.number }} pr-base: origin/${{ steps.pr_info.outputs.base_ref || 'main' }} pr-head-sha: ${{ steps.pr_info.outputs.head_ref }} docs-subfolder: ${{ secrets.DOCS_SUBFOLDER }} comment-body: ${{ github.event.comment.body }} docs-base-branch: ${{ secrets.DOCS_BASE_BRANCH || 'main' }}

2 Configure repository secrets

Settings > Secrets and variables > Actions
NameValueDescription
MODEL_API_BASE •••••••••• Base URL for OpenAI-compatible API (e.g., vLLM, Gemini, OpenAI)
MODEL_API_KEY •••••••••• API key for the model endpoint (optional if no auth required)
MODEL_NAME •••••••••• Model name to use for inference
DOCS_REPO_URL •••••••••• Docs repository URL (e.g., https://github.com/org/docs)
GH_PAT •••••••••• GitHub token with repo + pull_requests:write permissions
DOCS_SUBFOLDER Optional Docs subfolder path if docs live in the same repo (e.g., docs)
DOCS_BASE_BRANCH Optional Base branch for docs PRs (defaults to main)

Add rate limiting to authentication endpoints #342

Open alice wants to merge 3 commits into main from add-rate-limiting
Conversation 2
Files changed 3
alice commented 2 hours ago

This PR adds rate limiting to the /auth/login and /auth/token endpoints. Changes include:

  • New RateLimiter middleware with configurable limits per endpoint
  • Updated auth_handler.py to apply rate limiting on login and token refresh
  • New configuration options: RATE_LIMIT_MAX_REQUESTS and RATE_LIMIT_WINDOW_SECONDS
  • Tests for rate limiting behavior and error responses
src/middleware/rate_limiter.py +94 -0
@@ -0,0 +1,34 @@
1+class RateLimiter:
2+ """Sliding window rate limiter middleware."""
3+
4+ def __init__(self, max_requests, window_seconds):
5+ self.max_requests = max_requests
6+ self.window_seconds = window_seconds
src/handlers/auth_handler.py +23 -4
@@ -12,8 +12,18 @@ class AuthHandler:
1212 def handle_login(self, request):
13+ self.rate_limiter.check(request)
1314 credentials = request.get_credentials()
14- return self.authenticate(credentials)
15+ return self.authenticate(credentials, rate_limited=True)
config/settings.py +12 -0
@@ -28,6 +28,14 @@ class Settings:
2828 SESSION_TIMEOUT = 3600
29+
30+ # Rate limiting
31+ RATE_LIMIT_MAX_REQUESTS = 100
32+ RATE_LIMIT_WINDOW_SECONDS = 60
Write Preview