Skip to content
This repository was archived by the owner on Feb 8, 2026. It is now read-only.

Fee auth#140

Merged
garry-sharp merged 1 commit into
mainfrom
fee-auth
Jul 25, 2025
Merged

Fee auth#140
garry-sharp merged 1 commit into
mainfrom
fee-auth

Conversation

@garry-sharp

@garry-sharp garry-sharp commented Jul 24, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Fee history retrieval by public key now requires authentication for enhanced security.
  • Bug Fixes

    • Enforced validation to ensure a verifier token is provided in the configuration.
  • Chores

    • Updated configuration to use a new verifier token key.
    • Removed unauthenticated fee retrieval endpoints for improved security.

Copilot AI review requested due to automatic review settings July 24, 2025 14:26
@coderabbitai

coderabbitai Bot commented Jul 24, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes remove unauthenticated fee history retrieval methods from the verifier API, enforce authentication for public key fee queries, and update configuration to require a verifier token. The VerifierApi struct now stores an API token and client, with authenticated HTTP requests implemented. Related configuration and plugin initialization are updated accordingly.

Changes

File(s) Change Summary
etc/vultisig/fee.yml Changed verifier_token value from localhost-fee-key to localhost-fee-apikey.
internal/verifierapi/fees.go Removed unauthenticated fee retrieval methods; made public key fee retrieval require authentication.
internal/verifierapi/verifierapi.go Added token/client to VerifierApi; updated constructor; added authenticated GET method.
plugin/fees/config.go Enforced non-empty VerifierToken in fee config validation.
plugin/fees/fees.go Passed VerifierToken to NewVerifierApi in plugin initialization.

Sequence Diagram(s)

sequenceDiagram
    participant Plugin
    participant VerifierApi
    participant VerifierService

    Plugin->>VerifierApi: NewVerifierApi(url, token, logger)
    Note right of VerifierApi: Stores token and http.Client

    Plugin->>VerifierApi: GetPublicKeysFees(pubKey)
    VerifierApi->>VerifierApi: getAuth(endpoint)
    VerifierApi->>VerifierService: HTTP GET /fees/{pubKey} with Authorization header
    VerifierService-->>VerifierApi: FeeHistoryDto (if authorized)
    VerifierApi-->>Plugin: FeeHistoryDto or error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A token in paw, the rabbit hops fast,
Old open doors to the fees are now past.
Auth is required for every new call,
Secure little tunnels, no breaches at all!
With configs checked twice and headers in line,
The code is now safer—oh, how divine!
🐇🔐

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23fe082 and 44047a3.

📒 Files selected for processing (5)
  • etc/vultisig/fee.yml (1 hunks)
  • internal/verifierapi/fees.go (1 hunks)
  • internal/verifierapi/verifierapi.go (1 hunks)
  • plugin/fees/config.go (1 hunks)
  • plugin/fees/fees.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • etc/vultisig/fee.yml
  • plugin/fees/fees.go
  • plugin/fees/config.go
  • internal/verifierapi/verifierapi.go
🧰 Additional context used
🧠 Learnings (1)
internal/verifierapi/fees.go (5)

Learnt from: garry-sharp
PR: #117
File: plugin/fees/policy.go:46-47
Timestamp: 2025-07-04T10:47:47.927Z
Learning: For the fee plugin in plugin/fees/policy.go, the resource validation and recipe specification are intentionally configured to accept only USDC transfers ("ethereum.usdc.transfer"), not general ERC20 transfers ("ethereum.erc20.transfer"), as fees are only collected in USDC.

Learnt from: webpiratt
PR: #126
File: plugin/fees/policy.go:26-26
Timestamp: 2025-07-10T20:41:44.025Z
Learning: The constant vtypes.PluginVultisigFees_feee in the vultisig/plugin project is correctly spelled with "feee" (including the extra 'e'). This is the actual constant name defined in the external dependency github.com/vultisig/verifier/types and should not be changed to "fee" singular, as this is how it's defined in the external package.

Learnt from: RaghavSood
PR: #36
File: api/server.go:21-33
Timestamp: 2025-05-07T08:23:45.882Z
Learning: The import path github.com/vultisig/verifier/plugin refers to an external dependency that provides the plugin interface, and should not be changed to github.com/vultisig/plugin/plugin as these are distinct packages with different purposes.

Learnt from: garry-sharp
PR: #117
File: plugin/fees/constraints.go:3-3
Timestamp: 2025-07-04T10:50:42.832Z
Learning: For the vultisig/plugin project, use "fee" (singular) throughout the codebase wherever possible, not "fees" (plural). This applies to all naming conventions including plugin types, variable names, function names, comments, and documentation.

Learnt from: webpiratt
PR: #125
File: plugin/payroll/policy.go:160-160
Timestamp: 2025-07-09T22:23:17.348Z
Learning: In plugin/payroll/policy.go, the "token" case in the checkRule method intentionally does not call validateToken() as this is a temporary implementation that will be replaced with generic schema validation. The missing validation call is expected behavior during this transition period.

🔇 Additional comments (2)
internal/verifierapi/fees.go (2)

29-57: Removed unauthenticated endpoints are not referenced elsewhere

I ran a code-wide search for both GetPluginPolicyFees and GetAllPublicKeysFees and found no remaining usages. The two methods can safely be removed without breaking any internal callers.

No further action required.


29-57: Authentication in getAuth Verified

  • The method at internal/verifierapi/verifierapi.go:44–51 correctly:
    • Constructs a GET request to v.url+endpoint
    • Sets the Authorization: Bearer {token} header
    • Executes the request via v.client.Do
  • In GetPublicKeysFees, any non-200 status (including 401 Unauthorized) is already surfaced through the existing error paths.

No further changes are needed.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fee-auth

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements authentication requirements for fee retrieval endpoints by adding mandatory verifier token authentication. The changes strengthen security by removing unauthenticated access to fee-related APIs and ensuring proper token validation throughout the system.

  • Added mandatory verifier token configuration validation and authentication
  • Updated verifier API to use authenticated requests with Bearer tokens
  • Removed unauthenticated fee retrieval methods and unused API endpoints

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
plugin/fees/fees.go Passes verifier token to API constructor
plugin/fees/config.go Adds mandatory validation for verifier token field
internal/verifierapi/verifierapi.go Updates constructor to accept token and adds authenticated request method
internal/verifierapi/fees.go Removes unauthenticated methods and updates public key fees to use auth
etc/vultisig/fee.yml Updates token value in configuration


func (v *VerifierApi) get(endpoint string) (*http.Response, error) {
r, err := http.Get(v.url + endpoint)
return http.Get(v.url + endpoint)

Copilot AI Jul 24, 2025

Copy link

Choose a reason for hiding this comment

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

The simplified get() method removes error logging that was present in the original implementation. This could make debugging network issues more difficult. Consider either removing this method entirely if it's no longer used, or maintaining the error logging functionality.

Suggested change
return http.Get(v.url + endpoint)
req, err := http.NewRequest(http.MethodGet, v.url+endpoint, nil)
if err != nil {
v.logger.Errorf("Failed to create GET request for endpoint %s: %v", endpoint, err)
return nil, err
}
resp, err := v.client.Do(req)
if err != nil {
v.logger.Errorf("GET request to endpoint %s failed: %v", endpoint, err)
return nil, err
}
return resp, nil

Copilot uses AI. Check for mistakes.
func (v *VerifierApi) GetPublicKeysFees(ecdsaPublicKey string) (*FeeHistoryDto, error) {
url := fmt.Sprintf("/fees/publickey/%s", ecdsaPublicKey)
response, err := v.get(url)
response, err := v.getAuth(fmt.Sprintf("/fees/publickey/%s", ecdsaPublicKey))

Copilot AI Jul 24, 2025

Copy link

Choose a reason for hiding this comment

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

The ecdsaPublicKey parameter is directly interpolated into the URL without validation or encoding. This could potentially lead to path traversal or injection attacks if the public key contains unexpected characters. Consider validating the input format or using URL encoding.

Copilot uses AI. Check for mistakes.

@RaghavSood RaghavSood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@garry-sharp
garry-sharp merged commit b0115d6 into main Jul 25, 2025
3 checks passed
@garry-sharp
garry-sharp deleted the fee-auth branch July 25, 2025 10:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants