Skip to content

feat(hermes-server): add optional token to all apis and track usage#3404

Merged
keyvankhademi merged 9 commits intomainfrom
hermes-token
Feb 4, 2026
Merged

feat(hermes-server): add optional token to all apis and track usage#3404
keyvankhademi merged 9 commits intomainfrom
hermes-token

Conversation

@keyvankhademi
Copy link
Contributor

Summary

add optional token to all apis and track usage

Rationale

We need to accept the token to allow users to add it on their side before enforcing it. Also tracking users.

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

Manually tested by setting api key and looking at the /metrics

@vercel
Copy link

vercel bot commented Jan 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-reference Error Error Feb 4, 2026 2:30am
component-library Ready Ready Preview, Comment Feb 4, 2026 2:30am
developer-hub Ready Ready Preview, Comment Feb 4, 2026 2:30am
pyth-app Ready Ready Preview, Comment Feb 4, 2026 2:30am
4 Skipped Deployments
Project Deployment Actions Updated (UTC)
entropy-explorer Skipped Skipped Feb 4, 2026 2:30am
insights Skipped Skipped Feb 4, 2026 2:30am
proposals Skipped Skipped Feb 4, 2026 2:30am
staking Skipped Skipped Feb 4, 2026 2:30am

Request Review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d8c9a25c7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +20 to +22
if let Ok(auth_str) = auth_header.to_str() {
if let Some(token) = auth_str.strip_prefix("Bearer ") {
let token = token.trim();

Choose a reason for hiding this comment

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

P2 Badge Handle lowercase bearer in Authorization header

In extract_token_from_headers_and_uri, the token is only recognized when the header starts with the exact string Bearer , but the auth scheme is case-insensitive per RFC 7235; clients that send bearer <token> (some HTTP libraries do) will be treated as unauthenticated and recorded as none, which defeats the new usage tracking for those clients. Consider normalizing the scheme or performing a case-insensitive match before extracting the token.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Collaborator

@ali-behjati ali-behjati left a comment

Choose a reason for hiding this comment

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

Overall LGTM, please fix my comments before merging. Also bump the Hermes Server Cargo.toml file.

We also have a price service client js, and many websocket users over TS use it. Can you update that too?

In the future we might need to track the usage of tokens per asset or per asset class.

this.appendUrlSearchParams(url, transformedOptions);
}

// Add access token as query param for SSE connections
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does SSE also require query param here? I thought that was only WS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Collaborator

Choose a reason for hiding this comment

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

Latency itself has a lot of params, we don't need it per API key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, fixed.

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

Successfully merging this pull request may close these issues.

3 participants