Skip to content

feat(api): add external api endpoints for interact with rustmail via external system#265

Merged
Akinator31 merged 13 commits intomainfrom
241-external-api-endpoints
Nov 28, 2025
Merged

feat(api): add external api endpoints for interact with rustmail via external system#265
Akinator31 merged 13 commits intomainfrom
241-external-api-endpoints

Conversation

@Akinator31
Copy link
Copy Markdown
Member

This pull request introduces a comprehensive API key management system and adds support for external ticket creation endpoints. The main changes include a new database schema for API keys, handlers for creating, listing, revoking, and deleting API keys, middleware for API key authentication and permission checks, and new routes for both API key and external ticket operations.

API Key Management

  • Added a migration script to create the api_keys table, including fields for key hash, permissions, expiration, usage tracking, and relevant indexes for performance.
  • Implemented handlers for creating (create.rs), listing (list.rs), revoking (revoke.rs), and deleting (delete.rs) API keys, supporting permission assignment and key lifecycle management.

Authentication and Permissions

  • Updated the authentication middleware to support API key authentication via the x-api-key header, including key validation, usage tracking, and error handling.
  • Added permission middleware and utility functions to check API key permissions for protected endpoints, returning standardized error responses when permissions are missing.

Routing and Integration

  • Introduced new API routes for API key management (/api/apikeys) and external endpoints (/api/externals), with appropriate middleware protection.

Dependency Updates

  • Added new dependencies (prefixed-api-key, sha2, hex) to support secure API key generation and hashing.

@Akinator31 Akinator31 self-assigned this Nov 28, 2025
@Akinator31 Akinator31 linked an issue Nov 28, 2025 that may be closed by this pull request
@Akinator31 Akinator31 merged commit ba0a75b into main Nov 28, 2025
7 checks passed
@Akinator31 Akinator31 deleted the 241-external-api-endpoints branch November 28, 2025 13:07
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.

External Api Endpoints

1 participant