Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Unexposed jwt_secret on GET /api/kytos/core/config/ endpoint #378

Merged
merged 4 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Changed
- HTTP API exceptions responses no longer include the ``"name"`` key name in the response, only ``"code"`` and ``"description"`` still remain
- Development ``get_test_client`` now uses a ``htppx.AsyncClient`` instance

Fixed
=====
- Unexposed ``jwt_secret`` on ``GET /api/kytos/core/config/`` endpoint


[2022.3.1] 2023-02-17
**********************
Expand Down
8 changes: 8 additions & 0 deletions kytos/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ def _parse_json(value):

return options

@staticmethod
def options_exposed(daemon_options: dict) -> dict:
"""Options exposed on API."""
options = dict(daemon_options)
for key in {"jwt_secret"}:
options.pop(key, None)
return options


def _render_config_templates(templates,
destination=Path(__file__).parent,
Expand Down
2 changes: 1 addition & 1 deletion kytos/core/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def configuration_endpoint(self, _request: Request) -> JSONResponse:
string: Json with current configurations used by kytos.

"""
return JSONResponse(self.options.__dict__)
return JSONResponse(KytosConfig.options_exposed(self.options.__dict__))

def restart(self, graceful=True):
"""Restart Kytos SDN Controller.
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_core/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ async def test_app_event_handler(self, controller):
async def test_configuration_endpoint(self, controller, api_client):
"""Should return the attribute options as json."""
expected = vars(controller.options)
expected.pop("jwt_secret", None)
resp = await api_client.get("kytos/core/config")
assert resp.status_code == 200
assert expected == resp.json()