Skip to content

Comments

[feature] SC-166737/improve app proxy security by restricting where token replacements can go#54

Open
HappyPaul55 wants to merge 1 commit intomainfrom
SC-166737/improve-app-proxy-security-by-restricting-where-token-replacements-can-go
Open

[feature] SC-166737/improve app proxy security by restricting where token replacements can go#54
HappyPaul55 wants to merge 1 commit intomainfrom
SC-166737/improve-app-proxy-security-by-restricting-where-token-replacements-can-go

Conversation

@HappyPaul55
Copy link
Contributor

@HappyPaul55 HappyPaul55 commented Nov 18, 2025

This pull request introduces improvements to the way sensitive credentials are injected into API requests and refines type safety in the constants file. The most significant updates are in the API manifest configuration, enabling dynamic injection of credentials into request headers for specific endpoints, and a minor enhancement to the constants definition for better type inference.

API Credential Injection Enhancements:

  • Added a settingsInjection configuration to relevant endpoints in manifest.json, allowing client_id, client_secret, integration_key, and secret_key to be dynamically injected into the Authorization header for authentication requests.
  • Applied the same settingsInjection logic to the token revocation endpoint, supporting dynamic header injection for client_id and client_secret.

Type Safety and Constants Improvements:

  • Updated the placeholders object in src/constants.ts to use as const, improving type safety and ensuring the object’s values are treated as immutable literals.

Summary by Sourcery

Limit where token-related settings can be injected by adding a settingsInjection configuration to OAuth token endpoints and strengthen constant definitions for safer type inference

New Features:

  • Restrict token placeholder injections to specific OAuth manifest endpoints using settingsInjection
  • Enable dynamic injection of client credentials into the Authorization header for access token and token revocation URLs

Enhancements:

  • Improve type safety of placeholders by marking the placeholders object as immutable with as const

@HappyPaul55 HappyPaul55 requested a review from Copilot November 18, 2025 15:16
@HappyPaul55 HappyPaul55 requested a review from a team as a code owner November 18, 2025 15:16
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 18, 2025

Reviewer's Guide

Implements a controlled settingsInjection mechanism in manifest.json for dynamic credential header injection on OAuth2 endpoints, and strengthens type safety for the placeholders constant by marking it immutable.

Entity relationship diagram for updated manifest.json endpoint configuration

erDiagram
    ENDPOINT {
        string url
        string[] methods
        int timeout
        SettingsInjection settingsInjection
    }
    SettingsInjection {
        string[] header
    }
    ENDPOINT ||--|{ SettingsInjection : contains
    SettingsInjection }|--|{ Credential : injects
    Credential {
        string client_id
        string client_secret
        string integration_key
        string secret_key
    }
Loading

Class diagram for updated placeholders constant

classDiagram
    class placeholders {
        +string OAUTH2_ACCESS_TOKEN_PATH
        +string OAUTH2_REFRESH_TOKEN_PATH
        +string IS_USING_SANDBOX
    }
    placeholders : <<immutable>>
Loading

File-Level Changes

Change Details Files
Enhanced API Credential Injection Configuration
  • Added settingsInjection block to OAuth2 authentication endpoint
  • Enabled header injection for client_id, client_secret, integration_key, and secret_key
  • Applied same injection logic for client_id and client_secret on token revocation endpoint
manifest.json
Refined type safety for constants
  • Appended 'as const' to placeholders object for stronger type inference
src/constants.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@github-actions
Copy link

Copy link

Copilot AI left a comment

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 enhances security by restricting credential injection locations through the settingsInjection configuration in the proxy whitelist, and improves type safety in constants. The changes ensure that sensitive credentials are only injected into specific headers for OAuth endpoints.

Key Changes:

  • Added settingsInjection configuration to OAuth and token revocation endpoints to explicitly define where credentials can be injected
  • Updated placeholders object with as const for improved type inference and immutability

Reviewed Changes

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

File Description
src/constants.ts Added as const assertion to the placeholders object for better type safety
manifest.json Added settingsInjection configuration to OAuth endpoints to restrict credential injection to Authorization headers only

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +88 to +101
"settingsInjection": {
"client_id": {
"header": ["Authorization"]
},
"client_secret": {
"header": ["Authorization"]
},
"integration_key": {
"header": ["Authorization"]
},
"secret_key": {
"header": ["Authorization"]
}
}
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

All four credentials (client_id, client_secret, integration_key, secret_key) are configured to inject into the same Authorization header. This appears inconsistent with the actual usage patterns in the codebase: refreshAccessToken.ts uses __integration_key+':'+secret_key.base64__ in the Authorization header, while getQuickBooksAccessToken.ts sends client_id and client_secret in the request body. Consider reviewing whether all these credentials should actually be injected into the Authorization header, or if some should be restricted to body parameters instead.

Copilot uses AI. Check for mistakes.
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.

1 participant