feat: Support customizing the success and cancel url of Stripe. - #2745
Conversation
WalkthroughAdds trusted-domain-backed validation for optional Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Server
participant Stripe
Client->>Server: POST /request-pay (amount, email, SuccessURL?, CancelURL?)
Server->>Server: RequestPay validates payload
Server->>Server: common.ValidateRedirectURL(SuccessURL / CancelURL)
alt URLs valid
Server->>Server: genStripeLink(refId, custId, email, amount, successURL, cancelURL)
else invalid
Server-->>Client: 400 Bad Request (localized message)
end
Server->>Stripe: Create Checkout Session (uses provided or default success/cancel URLs)
Stripe-->>Server: Checkout session URL
Server-->>Client: Respond with Stripe link
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@controller/topup_stripe.go`:
- Around line 222-228: Validate user-provided successURL and cancelURL before
using them to prevent open redirects: add a helper (e.g., validateRedirectURL)
that parses the raw URL, ensures the scheme is "https" and the host matches or
belongs to an allowlist (or matches system_setting.ServerAddress's host), call
this helper immediately after reading successURL/cancelURL and return an error
(or fall back to the default) if validation fails, and update the logic that
sets successURL/cancelURL so defaults are only used when validation fails or the
parameter is empty.
|
不知道Stripe有没有针对success和cancel地址的白名单限制。 |
|
谢谢你的回复,我的应用场景是这样的: 麻烦你基于这个需求再考虑一下,如果有需要我修改的地方我可以随时修改,谢谢。
我在本地已经测试过了,Stripe 没有任何限制。 |
|
如果有安全方面的担心,我也可以在环境变量里面配置一个白名单,接口只能传递白名单里面的 url |
嗯这倒是一个法子 |
feat: Support customizing the success and cancel url of Stripe.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.