Skip to content

fix: route forward client to dedicated base URL#172

Open
armando-rodriguez-cko wants to merge 5 commits into
masterfrom
fix/forward-identity-base-urls
Open

fix: route forward client to dedicated base URL#172
armando-rodriguez-cko wants to merge 5 commits into
masterfrom
fix/forward-identity-base-urls

Conversation

@armando-rodriguez-cko
Copy link
Copy Markdown
Contributor

@armando-rodriguez-cko armando-rodriguez-cko commented May 11, 2026

Summary

The forward service lives on its own host (forward.{sandbox.,}checkout.com) in the swagger spec, not under api.checkout.com. This PR adds a dedicated forward_uri to Environment and routes the ForwardClient through it. It also tightens the subdomain validation regex to match the AWS PrivateLink prefix format documented at https://www.checkout.com/docs/developer-resources/api/private-connections/aws-privatelink^(?:pl-)?[a-z0-9]+$ (alphanumeric, optionally prefixed by the literal pl-). As a follow-up to a fresh RuboCop warning surfaced by the lint job, also wraps the file upload in File.open's block form to guarantee descriptor closure. Finally, exposes the missing forward:secrets and identity-verification OAuth scope constants.

The identity-verification services (applicants, identity-verifications, AML, face-authentications, ID document verifications) are also hosted on their own dedicated subdomain in swagger, but those endpoints are not yet implemented in this SDK — scope deferred to a follow-up.

Changes

  • lib/checkout_sdk/environment.rb — adds forward_uri accessor/parameter, sandbox/production values
  • lib/checkout_sdk/checkout_api.rb — adds forward_client helper; routes @forward to forward URI
  • lib/checkout_sdk/environment_subdomain.rb — tightens regex to /^(?:pl-)?[a-z0-9]+$/
  • lib/checkout_sdk/oauth_scopes.rb — adds FORWARD_SECRETS = 'forward:secrets' and IDENTITY_VERIFICATION = 'identity-verification'
  • lib/checkout_sdk/api_client.rbApiClient#upload switches from file = File.open(...) + ensure file.close to the block form File.open(...) do |file| ... end, fixing RuboCop Style/FileOpen and guaranteeing the descriptor is closed even if build_multipart_request raises before the inner begin/ensure block
  • spec/checkout_sdk/configuration/configuration_spec.rb — adds sandbox forward URL assertion; adds production forward URL test; updates subdomain corpus: removes test-123 from accepted, adds pl-vkuhvk4v (docs example), adds test-123/foo-bar/pl- to rejected

API Reference

  • https://forward.checkout.com / https://forward.sandbox.checkout.com — forward service (POST /forward (beta), GET /forward/{id} (beta), POST /forward/secrets, GET|POST|DELETE /forward/secrets/{name}). Scopes: forward (plus forward:secrets for secrets endpoints).
  • https://pl-{prefix}.api.{sandbox.,}checkout.com — AWS PrivateLink subdomain format

Breaking changes

  • Environment#initialize now requires forward_uri as a positional parameter. Anyone constructing Environment directly (rather than via Environment.sandbox / Environment.production) must update.
  • The subdomain regex is now stricter: arbitrary hyphenated subdomains like test-123 or foo-bar-baz are rejected. Only plain alphanumeric or the literal PrivateLink form (pl-{prefix}) are accepted.

README

Not affected.

@armando-rodriguez-cko armando-rodriguez-cko requested a review from a team May 11, 2026 13:28
RuboCop Style/FileOpen flagged ApiClient#upload because File.open
without a block could leak the file descriptor if
build_multipart_request raises before the ensure block is entered.
Wrap the file lifecycle in a block so closure is guaranteed even
if the multipart builder fails.
Per the AWS PrivateLink docs (https://www.checkout.com/docs/developer-resources/api/private-connections/aws-privatelink),
the valid subdomain is the first eight characters of the client_id
(alphanumeric only), optionally with the literal pl- prefix when
calling through PrivateLink. Tighten the regex from RFC-1123-style
hyphenated to /^(?:pl-)?[a-z0-9]+$/ and update the test corpus:
test-123 moves to the rejected list, pl-vkuhvk4v (the docs example)
joins the accepted list, and pl-, foo-bar are added as rejected.
Comment thread lib/checkout_sdk/api_client.rb
…tants

Per the swagger spec, /forward/secrets endpoints require the
forward:secrets scope in addition to forward, and all identity
endpoints (applicants, identity-verifications, aml-verifications,
face-authentications, id-document-verifications) require the
identity-verification scope. Expose both as typed constants so
OAuth clients can request them without hardcoding the strings.
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants