Add optional API-key authentication on registration/device routes#62
Open
ff225 wants to merge 1 commit into
Open
Add optional API-key authentication on registration/device routes#62ff225 wants to merge 1 commit into
ff225 wants to merge 1 commit into
Conversation
The registration/device_input/device_inference_result HTTP routes had no authentication, so any device on the network could register and send data. Adds a middleware gate behind communication.http.auth.enabled, requiring an X-API-Key header that matches auth.api_key (or the SCIOT_API_KEY env var, which takes precedence). Off by default to avoid breaking existing deployments. Closes #53
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.
Summary
HttpServerbehindcommunication.http.auth.enabled(defaultfalse, so existing deployments are unaffected). When enabled, requests to those three routes must send a matchingX-API-Keyheader; the key is set viacommunication.http.auth.api_keyor theSCIOT_API_KEYenv var (env var takes precedence). Enabling auth without a configured key fails fast at server startup instead of silently locking everyone out or silently doing nothing.docs/config/server.full.yaml,src/server/settings.yaml, anddocs/CONFIGURATION.md; validated insciot.config.validate_server_config.Test plan
tests/integration/test_http_api_key_auth.py: disabled-by-default passthrough, missing/wrong key rejected with 401, correct key accepted, env var precedence over settings key, unprotected routes (e.g.offloading_layer) unaffected, fail-fast when enabled without a key.communication.http.authvalidation cases totests/unit/test_config_validation.py.uv run pytest tests/unit tests/integration -m "not external_server and not model_artifact"passes (191 passed, 1 skipped).Closes #53