Skip to content

fix: route forward and identity clients to dedicated base URLs#209

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

fix: route forward and identity clients to dedicated base URLs#209
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 and the identity-verification services (applicants, identity-verifications, aml-verifications, face-authentications, id-document-verifications) live on their own hosts in the swagger spec, not under api.checkout.com. This PR adds dedicated URIs for both and routes the corresponding clients through them. 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-). Finally, it exposes the identity-verification OAuth scope as a typed constant.

Changes

  • configuration/environment.go — adds ForwardUri() and IdentityUri() to the Environment interface; adds forwardUri/identityUri fields and getters on CheckoutEnv; extends NewEnvironment signature with both URIs; adds sandbox/production values; tightens subdomain regex to ^(?:pl-)?[a-z0-9]+$
  • configuration/oauth_scopes.go — adds IdentityVerification = "identity-verification"
  • nas/checkout_api.go — adds buildForwardClient and buildIdentityClient helpers; routes api.Forward to the forward URL; caches the identity ApiClient once and reuses it across AmlScreening, Applicants, FaceAuthentication, IdDocumentVerification, IdentityVerification
  • mocks/environment_mock.go — adds ForwardUri() and IdentityUri() stubs
  • test/configuration_api_test.go — adds pl-vkuhvk4v (docs example) and pl-abc123 to the accepted subdomains; moves test-123 to the rejected list and adds foo-bar, pl- (bare); asserts ForwardUri()/IdentityUri() on production env; adds TestShouldHaveCorrectSandboxUrls / TestShouldHaveCorrectProductionUrls covering every URI
  • test/telemetry_test.go — passes the new URIs to the mock environment factory
  • README.md — updates the NewEnvironment example to reflect the new signature

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://identity-verification.checkout.com / https://identity-verification.sandbox.checkout.com — identity services (/applicants, /identity-verifications (beta), /aml-verifications (beta), /face-authentications (beta), /id-document-verifications (beta)). Scope: identity-verification.
  • https://pl-{prefix}.api.{sandbox.,}checkout.com — AWS PrivateLink subdomain format

Breaking changes

  • configuration.NewEnvironment signature now requires forwardUri and identityUri parameters
  • configuration.Environment interface adds ForwardUri() and IdentityUri() methods — custom implementations must add them
  • The subdomain regex is now stricter: arbitrary hyphenated subdomains like test-123 or foo-bar-baz are rejected. Only plain alphanumeric (vkuhvk4v) or the literal PrivateLink form (pl-vkuhvk4v) are accepted.

README

Updated.

Extends the forward/identity URI split to the AML screening, applicants,
face authentication, ID document verification and identity verification
clients that were added on master after the original fix. Adds
IdentityUri to the Environment interface and CheckoutEnv, with
https://identity-verification.{sandbox.,}checkout.com as defined in the
swagger spec. Adds buildIdentityClient and wires the five clients
through it. Mock, telemetry test, README example and configuration
tests updated accordingly.
@armando-rodriguez-cko armando-rodriguez-cko requested a review from a team May 11, 2026 13:27
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.
david-ruiz-cko
david-ruiz-cko previously approved these changes May 12, 2026
Per the swagger spec, all identity endpoints (applicants,
identity-verifications, aml-verifications, face-authentications,
id-document-verifications) require the OAuth scope
identity-verification. Expose it as a typed constant so OAuth
clients can request it without hardcoding the string.
@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