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

RPC Authorization #1029

Open
5 tasks
ebuchman opened this issue Jun 1, 2021 · 8 comments
Open
5 tasks

RPC Authorization #1029

ebuchman opened this issue Jun 1, 2021 · 8 comments
Labels
I: rpc Internal: related to (g)RPC O: new-feature Objective: cause to add a new feature or support O: usability Objective: cause to improve the user experience (UX) and ease using the product
Milestone

Comments

@ebuchman
Copy link
Member

ebuchman commented Jun 1, 2021

Crate

relayer-cli

Summary of Bug

RPC endpoints do not support some means of authentication.

The first is http based user/password in the url, for instance https://<user>:<password>@url:port. This is a pretty convenient way to secure access to nodes (we have some nodes set up like this) so it would be good if the *_addr fields in the hermes config were able to support this. Currently if I set the rpc_addr to this it fails with:

Jun 01 13:43:31.113  INFO ibc_relayer::event::monitor: starting event monitor chain.id=informal-testnet-1
Error: chain runtime error: RPC error to endpoint https://<user>:<password>@rpc.interchain.io/: Parse error. Invalid JSON: expected value at line 1 column 1 (code: -32700)

A related point (since this kind of auth requires https), already noted in #877, is that the grpc_addr does not support https.

Another kind of authentication is that used by eg. https://datahub.figment.io/ where you are given an API key. In that case, the API key can be easily added to the rpc_addr and the websocket_addr URLs, but there is no way to add it to the grpc_addr. For instance this works fine in the hermes config:

rpc_addr = 'https://cosmoshub-4--rpc--full.datahub.figment.io/apikey/<api key>'
websocket_addr = 'ws://cosmoshub-4--rpc--full.datahub.figment.io/apikey/<api key>'

but there is no way to make it work with the grpc_addr. According to the figment datahub docs the way to make this work is by setting an HTTP header field, eg. grpcurl -H "Authorization:<api key>" cosmoshub-4--grpc--archive.grpc.datahub.figment.io:443 list. So perhaps there could be some way to either set this specific Authorization header or to more generally set header fields for these urls ?

Note that the rpc/websocket addrs can also work with the -H "Authorization:<api key>" instead of including it in the url so persumably the API key could be included in the hermes config once for each chain and used for all the URLs for that chain.

That said it occurs to me I couldn't even test if the API key works in the grpc_addr because https doesn't even work there so we should fix that first since it's needed for everything.

Version

Latest

Steps to Reproduce

For the first, add a user/password to the any of the addr fields. For the second, try to connect to a figment data hub node

Acceptance Criteria

Hermes can talk to nodes protected by https along with a user/password or an Authorization API key


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate milestone (priority) applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@ancazamfir ancazamfir added this to the 07.2021 milestone Jun 9, 2021
@adizere adizere modified the milestones: 07.2021, 09.2021 Jun 28, 2021
@adizere adizere modified the milestones: 09.2021, 10.2021 Sep 6, 2021
@adizere adizere modified the milestones: 10.2021, 12.2021 Sep 27, 2021
@adizere adizere added O: new-feature Objective: cause to add a new feature or support I: rpc Internal: related to (g)RPC O: usability Objective: cause to improve the user experience (UX) and ease using the product labels Feb 25, 2022
@adizere adizere modified the milestones: v1.0.0, Backlog Feb 25, 2022
@faddat
Copy link
Contributor

faddat commented Aug 9, 2023

Hi, I think that we are very happy to contribute this one :).

@romac
Copy link
Member

romac commented Aug 9, 2023

Cool! We'd gladly accept a PR for this :)

On order to prioritize this properly, may I ask if you currently have a use case for this at Notional or have heard others mention a need for this recently?

@faddat
Copy link
Contributor

faddat commented Aug 25, 2023

@romac we want to integrate it with out API product, https://notionalapi.com

@romac
Copy link
Member

romac commented Aug 25, 2023

Good to know, thanks! Let me put this back in a milestone then

@romac romac modified the milestones: Backlog, v1.8 Aug 25, 2023
@github-project-automation github-project-automation bot moved this to 🩹 Triage in Hermes Aug 25, 2023
@faddat
Copy link
Contributor

faddat commented Aug 28, 2023

@romac if I were going to break this down into tasks, you figure it might look like:

  • add a place in config.toml for the api auth
  • look at the query and http code and shimmy that auth key in there?

I am not super familiar with the hermes codebase, I have only made a few contributions, possibly just bumping the supported sdk version a few times.

@ebuchman -- afaik, we've got https on our grpc. I think that @baabeetaa can explain how we did that, but here is a rough map:

both notionalapi and cosmosia use cosmosia and its configs

(bunch of nodes that can both be scaled, and auto scale) -> caddy LP + https <-> hermes and other consumers

We want to "dogfood" this because relaying is our most latency sensitive operation. If our shared infra can equal the perf of the dedicated machines we can use for relaying now then:

  • we save money
  • we can cover every single chain in cosmos
  • we provide better services where needed
  • we've proven that our rpcs are highly performant and that's useful market data

Also in the present state we do have keys that can be appended to the ends of URLS for grpc, too. I think that in the end our approach just changes the path though.


Acceptance criteria

I was hoping that we could change the acceptence criteria a little to get this out the door faster. I think we just need the authorization api key.

@antony-everstake
Copy link

Authorization is a very important for grpc. I wanted to inquire whether the process is moving for add Authorization for GRPC? Are there plans to add GRPC authorization to the config file in new releases?

@romac romac modified the milestones: v1.8, v1.9 Jan 16, 2024
@adizere adizere modified the milestones: v1.9, v1.10 Apr 2, 2024
@gilbahat
Copy link

Hi,

hermes documentation asserts that http basic auth is supported. is this bug stale or is documentation incorrect?
https://hermes.informal.systems/documentation/configuration/configure-hermes.html#connecting-to-a-full-node-protected-by-http-basic-authentication
also, are we sure this applies to grpc as well? are there any unit tests for it?

@gilbahat
Copy link

as per diagnostic session in interchain discord, tonic does not support basic authentication out of the box. either documentation should be updated or support added for gRPC basic auth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I: rpc Internal: related to (g)RPC O: new-feature Objective: cause to add a new feature or support O: usability Objective: cause to improve the user experience (UX) and ease using the product
Projects
Status: 🩹 Triage
Development

No branches or pull requests

7 participants