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

Display an error when trying to add an user with a non-localhost IP #889

Merged
3 commits merged into from Oct 13, 2021
Merged

Display an error when trying to add an user with a non-localhost IP #889

3 commits merged into from Oct 13, 2021

Conversation

ghost
Copy link

@ghost ghost commented Oct 12, 2021

Purpose

When trying to call add_api_user from a non-localhost IP, no error message is sent to the client, nor logged. This emits an error message using the custom error handling from #847.

Context

Emit an error when calling add_api_user from a remote IP.

Changes

Update the add_api_user method and update the API documentation with an output example.

How to test this PR

Calling the add_api_user from a remote IP should send back an error message. For instance curl -s "Content-Type: application/json" --data '{"method":"add_api_user","params:{"username":"toto","api_key":"toto"},"id":1,"jsonrpc":"2.0"}' http://10.0.0.1:5000/ | jq should return something like

{
  "id": 1,
  "error": {
    "message": "Unauthorized to call this method from a remote IP",
    "data": {
      "remote_ip": "10.0.0.2"
    },
    "code": -32603
  },
  "jsonrpc": "2.0"
}

Alexandre Pion added 2 commits October 12, 2021 15:33
The "add_api_user" method should be called from a local IP.
@ghost ghost added this to the v2021.2 milestone Oct 12, 2021
@ghost ghost requested review from mattias-p, matsduf and hannaeko October 12, 2021 13:49
Copy link
Contributor

@matsduf matsduf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine and works fine, but one comment on wording.

Copy link
Contributor

@matsduf matsduf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine. Approved.

@ghost ghost merged commit 0ea105d into zonemaster:develop Oct 13, 2021
@ghost ghost deleted the error-msg-add-api-user-remote branch October 13, 2021 09:19
@matsduf
Copy link
Contributor

matsduf commented Dec 3, 2021

Testing v2021.2

LGTM.

@matsduf matsduf added the S-ReleaseTested Status: The PR has been successfully tested in release testing label Dec 3, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-ReleaseTested Status: The PR has been successfully tested in release testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant