Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API SECURITY, HF REFACTOR OF SCORING. #365

Merged
merged 12 commits into from
Jan 25, 2025
Merged

API SECURITY, HF REFACTOR OF SCORING. #365

merged 12 commits into from
Jan 25, 2025

Conversation

Arrmlet
Copy link
Collaborator

@Arrmlet Arrmlet commented Jan 23, 2025

API Security Update

Added API Key Authentication and Rate Limiting System

New Features:

  1. Two-Tier API Key System
    • Master key for validator owners (administrative access)
    • Regular API keys for users
    • SQLite-based key storage and management
  2. Key Management Endpoints
    • POST /api/v1/keys - Create new API keys (master key required)
    • GET /api/v1/keys - List all API keys (master key required)
    • GET /api/v1/keys/{key}/deactivate - Deactivate API keys (master key required)
  3. Rate Limiting
    • Regular API keys: 100 requests/hour
    • Master key: 1000 requests/hour
    • Rolling window implementation
    • Rate limit headers in responses
  4. Protected Endpoints
    • Regular data endpoints require valid API key
    • Administrative endpoints require master key
    • Set desirabilities endpoint restricted to master key only

Technical Implementation:

  • SQLite database for key storage and rate limiting
  • Thread-safe implementation for concurrent access
  • Automatic cleanup of old rate limit records
  • Response headers for rate limit tracking

Configuration:

  • Master key configurable via environment variable: MASTER_KEY
  • Database file auto-generated: api_keys.db

Security Improvements:

  • Protected documentation endpoints
  • Rate limit protection against DDoS
  • Secure key generation and storage
  • Thread-safe operations

Change date from 27th. Reduce limit from 400 to 200 to make upload more brief( to be changed on 27th)

@Arrmlet Arrmlet requested a review from chai-amy January 23, 2025 15:17
@Arrmlet Arrmlet merged commit a1835e8 into main Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants