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

feat: added header-key and header-value to pass header if required for wasm clients #227

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bcsainju
Copy link
Collaborator

added headers key/value if provided in config, the key is header-key and value is header-value in config for wasm

@bcsainju bcsainju marked this pull request as ready for review July 31, 2024 09:15
Copy link

codecov bot commented Jul 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 13.07%. Comparing base (02b1aaf) to head (64b6862).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #227      +/-   ##
==========================================
- Coverage   13.15%   13.07%   -0.09%     
==========================================
  Files          70       70              
  Lines       17075    17421     +346     
==========================================
+ Hits         2247     2277      +30     
- Misses      14586    14900     +314     
- Partials      242      244       +2     

see 1 file with indirect coverage changes

@@ -53,6 +54,8 @@ type WasmProviderConfig struct {
ChainName string `json:"-" yaml:"-"`
ChainID string `json:"chain-id" yaml:"chain-id"`
RPCAddr string `json:"rpc-addr" yaml:"rpc-addr"`
HeaderKey string `json:"header-key" yaml:"header-key"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use standard Authorization header key rather using config.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Header key may be different for different API endpoints so letting it be set by the config.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Authorization header is standard.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not authorization header, but rather may be API key based where some expect in key api-key or some API in authorization etc. If we are only talking about some predefined API please do mention them so it will be tailored to work only for them.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's specific for now, almost all RPC support authorization from endpoint.

var customTransport *CustomRoundTripper
headers := http.Header{}
if headerKey != "" {
headers.Add(headerKey, headerValue)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use key from environment variable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

key or value ?? since other api which used API key in URL are also saved in plain mode in config, it can be done later if you are concerned about security analyzing the benefits and disadvantages of saving key in file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants