[Bug]: Creating an API key returns 401 unauthorized
Preliminary Checks
- [x] I have searched existing issues for similar problems
- [x] I have read the troubleshooting documentation
- [x] I am using a supported version of HeadlessX
HeadlessX Version
v2.0
Installation Method
npm install
Environment
Ubuntu
Bug Description
Hi again!
When trying to add a new API key using the UI I get a 401 code and the key is not created.
I see no X-Api-Key is being sent on that request (although there's no authentication in the panel at all).
At this moment the UI is using the X-Api-Key => test-key-dashboard, which as it's being hardcoded every instance is not protected by API keys at all.
From my point of view the panel should require authentication so we protect the instance from being used by anyone. And that's the whole point of the API keys, so I guess it's something you have in mind.
So, I'd solve this in two steps: 1- Adding authentication to the panel so we avoid strangers to use UI. We can auto-generate an API key for the admin user the first time that user logs in and then use it when we scrape from the browser. 2- Use that API key with admin permissions to create new API keys.
For the moment the workaround is to use the API with test-key-dashboard and protect it with basic authentication behind a proxy.
I can help with this change if you agree and we make a plan so we are on the same page! :)
Expected Behavior
Creating API keys works and secure dashboard using a unique string instead of a hardcoded API key.
Actual Behavior
Creating API keys doesn't work and the dashboard is not secure as anyone can use it + using the test-key-dashboard the API can be used too
Steps to Reproduce
- Navigate to the frontend
- Try to create an API key
- 401 error appears in Devtools
Error Logs
Configuration
Severity
Critical (application crashes, security vulnerability)
Browser Context
None
Additional Context
No response
Contribution
- [x] I am willing to help fix this bug
- [x] I can provide additional testing
- [x] I can help with documentation updates
Fixed: https://github.com/saifyxpro/HeadlessX/pull/26