Skip to content

Support callable signing_secrets for dynamic configuration#177

Open
kristinemcbride wants to merge 1 commit into
integrallis:masterfrom
kristinemcbride:callable-signing-secrets
Open

Support callable signing_secrets for dynamic configuration#177
kristinemcbride wants to merge 1 commit into
integrallis:masterfrom
kristinemcbride:callable-signing-secrets

Conversation

@kristinemcbride

Copy link
Copy Markdown

Why?
Multi-tenant Rails applications often need to use different Stripe webhook signing secrets for different tenants/regions. Currently, signing_secrets must be set to a static array at boot time, which doesn't work well for applications where the correct signing secrets are only known at request time.
This change allows signing_secrets to accept a callable (lambda/proc) that is evaluated on each webhook request, enabling dynamic resolution of signing secrets based on the current request context.

What?

  • Added a custom getter for signing_secrets that resolves callable values (lambdas/procs) before returning
  • Added documentation explaining the callable support
  • Added tests for callable signing_secrets configuration
    After this change, applications can configure StripeEvent like this:
StripeEvent.signing_secrets = -> { CurrentTenant.stripe_signing_secrets }

See Also

activerecord-tenanted - This is the gem I am using that enables multi-tenant Rails applications, which is an example use case for this feature.

Allow signing_secrets to accept lambdas/procs that are resolved at
request time. This enables multi-region deployments or dynamic
configuration scenarios where signing secrets may vary per request.
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