Skip to content

fix(gen): generate security handling for webhook server and client - #1771

Merged
ernado merged 1 commit into
ogen-go:mainfrom
SahilRajputdotexe:fix/webhook-security
Nov 13, 2026
Merged

ernado merged 1 commit into
ogen-go:mainfrom
SahilRajputdotexe:fix/webhook-security

Conversation

@SahilRajputdotexe

Copy link
Copy Markdown
Contributor

Fixes #1560

If a webhook declares security, the generated webhook handlers and webhook client methods call s.security<Name>, but those methods only exist on Server and Client. WebhookServer and WebhookClient have no SecurityHandler/SecuritySource, so the generated code does not compile.

With this change, when some webhook requires security:

  • NewWebhookServer takes a SecurityHandler and WebhookServer gets the security<Name> methods
  • NewWebhookClient takes a SecuritySource and WebhookClient gets the client-side security<Name> methods

Specs where no webhook has security generate the same code as before (make generate examples only adds the new test package). Webhook client + security-reentrant isn't wired up, so that combination now fails generation with an explicit error instead of producing broken code.

Added _testdata/positive/webhook_security.yml and an integration test that covers an API key and a custom security on webhooks: valid credentials, wrong credentials (401), and missing credentials (client error, and 401 from the server for a raw request).

Webhook handlers and webhook client methods called s.security<Name>,
but those methods were only generated for Server and Client, and
WebhookServer/WebhookClient had no SecurityHandler/SecuritySource.
Code generated for a webhook with security did not compile.

When a webhook declares security, WebhookServer now takes a
SecurityHandler and WebhookClient a SecuritySource, and both get the
security methods.

Fixes ogen-go#1560
@ernado ernado closed this Nov 13, 2026
@ernado ernado reopened this Nov 13, 2026
@ernado
ernado merged commit 1cbcdb1 into ogen-go:main Nov 13, 2026
17 checks passed
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.

WebhookServer: invalid code when security is enabled

2 participants