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

Fetch api keys, secrets etc from env and apply it to jobs #1002

Closed
SkandaBhat opened this issue Nov 1, 2022 · 2 comments
Closed

Fetch api keys, secrets etc from env and apply it to jobs #1002

SkandaBhat opened this issue Nov 1, 2022 · 2 comments
Assignees
Milestone

Comments

@SkandaBhat
Copy link
Contributor

Analysis: some URLs may require authentication or API keys.

Possible solution: Consider reading the keys from env and substituting it while fetching a job.

@SkandaBhat SkandaBhat self-assigned this Nov 1, 2022
@SkandaBhat SkandaBhat added this to the v1.0.6 milestone Dec 14, 2022
@SkandaBhat SkandaBhat removed their assignment Dec 14, 2022
@Yashk767
Copy link
Contributor

API keys can be passed in two ways:

1) Sending API key directly In URL

  • If we are passing API keys directly in url then we need to follow a certain regex while creating jobs for all the jobs which requires api key.

  • e.g. if this is the required format for this API
    /v1/exchangerate/BTC?apikey=73034021746739393292922SAMPLE-KEY

  • Than we can create a job following this,
    /v1/exchangerate/BTC?apikey={API_KEY_REGEX}

2) Sending API key via authorization headers

  • Here the problem is how would node know when to follow this and there would be different formats followed for different APIs as each API have different documentation.

@Yashk767
Copy link
Contributor

Yashk767 commented Aug 3, 2023

As suggested

// API key should be directly fetched from os environment 
// Use os.Getenv() as used here https://gobyexample.com/environment-variables instead of depending on godotenv library.
// Followed format {API_KEY_KEYWORD} as regex in urls to search for keyword and respective value from os env variables. 

Implemented the same in #1097

While defining the job which requires a API key, staker needs to follow regex defined in constants.go , which is set to e.g ${API_KEY_KEYWORD}.

e.g. if this is the required format for this API

https://api.gemini.com/v1/pubticker/v1/exchangerate/BTC?apikey=73034021746739393292922

Than a job with url can be created as shown below,

https://api.gemini.com/v1/pubticker/v1/exchangerate/BTC?apikey=${COINAPI_API_KEY}

Now staker needs to use the same keyword defined inside ${...} as a environment variable using export command and assigning it a value as users API key as shown below.

export COINAPI_API_KEY="73034021746739393292922"

Oracle node will directly look for the same in os environment variables and pick the respective value.
@ashish10677 @SkandaBhat

@Yashk767 Yashk767 reopened this Aug 3, 2023
@Yashk767 Yashk767 modified the milestones: v1.0.6, v1.0.7 Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants