-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Problem / Motivation
First off, thank you for this fantastic project! Archon is a powerful and clean wrapper for the Bungie.net API.
Currently, the API endpoints provided by Archon appear to be open without any built-in authentication mechanism. While this is great for local development, it poses a significant security risk when deploying Archon to a server or using it in a production environment. Anyone who discovers the endpoint URL could potentially make requests, consume rate limits, and abuse the service.
To make Archon more robust and production-ready, it would be beneficial to add a layer of security.
Proposed Solution
I propose a two-part solution to address this, which covers both securing the API endpoints and providing a management interface.
Part 1: API Key Authentication for Endpoints
This is the core security feature. It would involve securing the Archon API endpoints so that they can only be accessed with a valid secret key.
- Configuration: A new configuration key could be added to
appsettings.json
(or an environment variable), for example:"Archon": { "ApiKey": "your-super-secret-api-key-here" }
- Implementation: A new middleware would check incoming requests for this key. Clients would be required to include the key in an HTTP header, for example:
X-Archon-API-Key: your-super-secret-api-key-here
. - Behavior: If a request arrives without a valid key, the API should immediately respond with a
401 Unauthorized
or403 Forbidden
status. - Benefit: This simple mechanism would effectively secure the wrapper from unauthorized use and allow the owner to control who has access.
Part 2: Optional: Web-based Administrative Dashboard
This part addresses the "add login page" request in a way that fits the project's architecture. A simple, built-in web UI for managing Archon would be incredibly useful.
- Login Page: The dashboard would be protected by a basic login page. The credentials could also be configured in
appsettings.json
."ArchonAdmin": { "Username": "admin", "Password": "a-strong-password" }
- Dashboard Features: This dashboard could provide:
- A simple API endpoint tester.
- A view of recent logs or errors.
- A way to view current Bungie.net API rate limit status.
- In the future, a UI to manage multiple API keys (if that feature is ever added).
- Benefit: This would provide a secure, user-friendly way to monitor and interact with the Archon instance without needing to use third-party tools like Postman or curl for basic checks.
Alternatives Considered
- Relying on a Reverse Proxy: One could use Nginx, Traefik, or Caddy to handle authentication in front of Archon. While this is a valid approach, it adds external complexity. Building authentication directly into Archon makes it more self-contained and easier to set up for users who aren't familiar with reverse proxies.
Additional Context
- For the API Key authentication, ASP.NET Core has excellent built-in support for API key authentication middleware that could be leveraged.
- For the admin dashboard, a minimalistic framework like Blazor or even simple Razor Pages would be a great fit within the .NET ecosystem and wouldn't add too much overhead to the project.
Thank you for considering this feature! I believe it would significantly increase Archon's value and make it suitable for a much wider range of use cases.