openrdap / rdap

RDAP command line client
https://www.openrdap.org
MIT License
230 stars 36 forks source link

ability to send api code to lacnic rdap server #12

Closed hc6pe closed 1 year ago

hc6pe commented 4 years ago

lacnic has the possibility to use an api keys in order to access their rdap service. For example: curl https://rdap.lacnic.net/rdap/ip/1.2.3.4?apikey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx will return the requested resource. Here for more info: https://www.lacnic.net/676/2/lacnic/request-rdap-access

Is it possible for your package to include an option to send the api-key when querying lacnic rdap?

skip2 commented 4 years ago

Sure, I'll work on adding this. Do you have an API key? (i.e. can you help test it?)

hc6pe commented 4 years ago

yes I do, I can help with the testing. regards epe

skip2 commented 4 years ago

I've added a branch for this here: https://github.com/openrdap/rdap/tree/lacnic-apikey

The branch adds an option -L, --lacnic-apikey=APIKEY Use APIKEY for requests to rdap.lacnic.net. to the rdap command, so you can use it like rdap -v 177.0.0.1 -L mykey.

It only sends the apikey to rdap.lacnic.net, e.g. it won't send it to RIPE or Verisign, or anyone else.

Can you try it with your key?

[tfh@localhost rdap]$ rdap -v 177.0.0.1 -L mykey 
# OpenRDAP v0.0.1
# 
# rdap: Configuring query...
# rdap: Using disk cache (/home/tfh/.openrdap)
# rdap: Bootstrap URL is default 'https://data.iana.org/rdap/'
# rdap: Bootstrap cache TTL set to 3600 seconds
# rdap: Timeout is 30 seconds
# 
# client: Running...
# client: Request type  : ip
# client: Request query : 177.0.0.1
# client: Request URL   : TBD, bootstrap required
#   bootstrap: Looking up...
#   bootstrap: Question type : ipv4
#   bootstrap: Question query: 177.0.0.1
#   bootstrap: Cache state: ipv4.json: good
#   bootstrap: Using cached Service Registry file
#   bootstrap: Looked up '177.0.0.1/32'
#   bootstrap: Matching entry '177.0.0.0/8'
#   bootstrap: Service URL #1: 'https://rdap.lacnic.net/rdap/'
# client: RDAP URL #0 is https://rdap.lacnic.net/rdap/ip/177.0.0.1
# client: GET https://rdap.lacnic.net/rdap/ip/177.0.0.1?apikey=mykey
# client: status-code=400, content-type=application/rdap+json, length=711 bytes, duration=1.088858033s
# 
# rdap: Finished in 1.090798914s
# Error: No RDAP servers responded successfully (tried 1 server(s))
[tfh@localhost rdap]$ 

I'm guessing a 400 error means "incorrect key".

thanks!