Skip to content

Commit f2dc1c7

Browse files
committed
feat(api_key): implement comprehensive API key management system
- Add complete API key CRUD operations with validation - Implement unified AuthChain middleware for consistent authentication - Add API key management endpoints with proper error handling - Enhance database schema for API key storage and relationships - Add comprehensive validation for API key creation and updates - Implement multi-language localization support for API key management - Remove unused authentication methods and streamline middleware - Add proper field validation and required field enforcement This implementation provides a robust foundation for API key-based authentication across the Peekaping monitoring platform.
1 parent f79f146 commit f2dc1c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+6408
-271
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Rollback API Keys table
2+
DROP TABLE IF EXISTS api_keys;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- Add API Keys table for third-party integrations
2+
-- This migration creates the api_keys table for secure API key management
3+
4+
CREATE TABLE IF NOT EXISTS api_keys (
5+
id UUID PRIMARY KEY,
6+
user_id UUID NOT NULL,
7+
name VARCHAR(255) NOT NULL,
8+
key_hash VARCHAR(255) NOT NULL,
9+
display_key VARCHAR(20) NOT NULL DEFAULT 'pk_****',
10+
last_used TIMESTAMP,
11+
expires_at TIMESTAMP,
12+
usage_count INTEGER NOT NULL DEFAULT 0,
13+
max_usage_count INTEGER,
14+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
15+
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
16+
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
17+
);
18+
19+
-- Create index for faster lookups
20+
CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
21+
CREATE INDEX IF NOT EXISTS idx_api_keys_key_hash ON api_keys(key_hash);
22+
CREATE INDEX IF NOT EXISTS idx_api_keys_display_key ON api_keys(display_key);
23+
CREATE INDEX IF NOT EXISTS idx_api_keys_expires_at ON api_keys(expires_at);

0 commit comments

Comments
 (0)