Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 8 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1208,9 +1208,15 @@ Omitting params:
Trying to add a user over non-localhost:
```json
{
"result": 0,
"id": 1,
"jsonrpc": "2.0"
"jsonrpc": "2.0",
"error": {
"code": -32603,
"data": {
"remote_ip": "10.0.0.1"
},
"message": "Unauthorized to call this method from a remote IP"
}
}
```

Expand Down
6 changes: 6 additions & 0 deletions lib/Zonemaster/Backend/RPCAPI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,12 @@ sub add_api_user {
if ( $allow ) {
$result = 1 if ( $self->{db}->add_api_user( $params->{username}, $params->{api_key} ) eq '1' );
}
else {
die Zonemaster::Backend::Error::PermissionDenied->new(
message => 'Unauthorized to call this method from a remote IP',
data => { remote_ip => $remote_ip }
);
}
};
if ($@) {
handle_exception( $@ );
Expand Down