feat: api key authentication and management#20
Merged
ontehfritz merged 2 commits intomainfrom Feb 14, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request implements API key authentication and management functionality for the BulwarkAuth service. It enables users to create, list, delete, and authenticate using API keys as an alternative to password-based authentication. The API keys follow a structured format (bwa_<random>_<secret>) where the prefix is stored for identification and the secret portion is hashed using bcrypt for secure storage.
Changes:
- Added API key data model with MongoDB repository implementation supporting CRUD operations
- Implemented API key service with token-based authorization for management operations and API key-based authentication
- Added HTTP handlers and routes for API key creation, listing, and deletion with rate limiting support
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/encryption/encryption.go | Added GenerateRandomString function for generating API key prefixes |
| internal/authentication/apikey.go | Core API key domain model, repository, and service implementation with authentication logic |
| internal/authentication/apikey_errors.go | Custom error types for API key operations |
| internal/authentication/apikey_test.go | Comprehensive repository-level tests covering CRUD operations and edge cases |
| internal/authentication/apikey_service_test.go | Service-level tests including authentication flows and isolation testing |
| internal/accounts/accounts.go | Added ID field to Account struct for API key association |
| api/authentication/apikey_handlers.go | HTTP handlers for API key management endpoints |
| api/authentication/apikey_routes.go | Route definitions for API key endpoints with rate limiting middleware |
| cmd/bulwarkauth/main.go | Integration of API key service and handlers into the application |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.