Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

google-pubsub-webhooks

БесплатноЗапускает вложенные скриптыНе проверен

Receive and verify Google Cloud Pub/Sub push subscription webhooks. Use when setting up a Pub/Sub push endpoint, verifying the OIDC `Authorization: Bearer`…

hookdeckот hookdeck★ 104 звезды на GitHub

Об этом скилле

Google Cloud Pub/Sub Webhooks (Push Subscriptions)

When to Use This Skill

  • How do I receive Google Cloud Pub/Sub messages at an HTTP endpoint?
  • How do I verify a Pub/Sub push request is really from Google?
  • How do I validate the OIDC JWT in the Authorization: Bearer header?
  • Why does Pub/Sub keep redelivering the same message to my webhook?
  • How do I decode message.data from a Pub/Sub push envelope?
  • Why is my Pub/Sub push endpoint returning 401?

How Pub/Sub Push Differs From HMAC Webhooks

Pub/Sub is not a signed-webhook provider. Read this before looking for a signature header — there isn't one.

  • No signing secret, no HMAC header. There is no X-Goog-Signature, no Standard Webhooks (webhook-id / webhook-timestamp / webhook-signature). Do not invent one.
  • The body is never signed. On an authenticated push subscription the Authorization: Bearer <JWT> header proves who is calling (your push service account), not what they sent. So unlike Stripe or Shopify, you do not need the raw body — parsing JSON first is fine here.
  • No event catalog. Pub/Sub carries whatever your publisher published. Event semantics live entirely in message.data and message.attributes. There are no payment.succeeded-style Pub/Sub event names.
  • Two auth postures, depending on how the subscription was created:
Posture What Pub/Sub sends What you can check
Default (no subscription auth) Nothing proving origin An unguessable ?token= in the push URL, plus network-level ingress restriction
OIDC (--push-auth-service-account, recommended) Authorization: Bearer <Google-signed OIDC JWT> RS256 signature, iss, aud, email, email_verified

Configure OIDC. See references/setup.md.

The Push Envelope

POST with Content-Type: application/json:

Google's documented minimum example:

{
  "message": {
    "data": "SGVsbG8gQ2xvdWQgUHViL1N1YiEgSGVyZSBpcyBteSBtZXNzYWdlIQ==",
    "messageId": "2070443601311540",
    "message_id": "2070443601311540",
    "publishTime": "2021-02-26T19:13:55.749Z",
    "publish_time": "2021-02-26T19:13:55.749Z"
  },
  "subscription": "projects/myproject/subscriptions/mysubscription"
}

data is base64 and may be absent (a message needs data or at least one attribute). attributes is an optional string map set by the publisher. orderingKey appears when the publisher set one, and a top-level deliveryAttempt when the subscription has a dead-letter topic.

Verification (core)

Verify the OIDC token with Google's official auth library — it fetches and caches Google's public keys and checks the RS256 signature, aud, and exp. You must still check the service account yourself.

const { OAuth2Client } = require('google-auth-library');
const client = new OAuth2Client();

// Both are valid Google issuers — accept either, as the official libraries do.
const GOOGLE_ISSUERS = ['https://accounts.google.com', 'accounts.google.com'];

async function verifyPushJwt(authorizationHeader) {
  // RFC 9110: the auth scheme is case-insensitive.
  const [scheme, token] = String(authorizationHeader || '').split(' ');
  if (!token || scheme.toLowerCase() !== 'bearer') return null;

  let claims;
  try {
    // Verifies the RS256 signature against Google's public keys, plus aud + exp.
    const ticket = await client.verifyIdToken({
      idToken: token.trim(),
      audience: process.env.PUBSUB_AUDIENCE, // defaults to the push endpoint URL
    });
    claims = ticket.getPayload();
  } catch {
    return null;
  }

  // Checks the library does not do for you.
  if (!claims.iss || !GOOGLE_ISSUERS.includes(claims.iss)) return null;
  if (claims.email_verified !== true) return null;

  // Service account emails are case-insensitive — normalize before comparing.
  const email = String(claims.email || '').toLowerCase();
  if (!email || email !== process.env.PUBSUB_SERVICE_ACCOUNT_EMAIL.trim().toLowerCase()) {
    return null;
  }
  return claims;
}

Python is the same shape with google-auth: id_token.verify_oauth2_token(token, google.auth.transport.requests.Request(), audience), then check iss / email / email_verified yourself. Details and the unauthenticated fallback are in references/verification.md.

For complete handlers with envelope parsing, subscription allowlisting, and tests, see:

Acknowledgement and Redelivery

  • Ack by returning 200, 201, 202, 204, or 102. Any other status code — and any timeout — is a nack, and Pub/Sub redelivers.
  • Respond within the subscription's ack deadline (default 10 seconds, configurable up to 600 seconds). Do slow work asynchronously and ack fast.
  • Delivery is **at-l
Полный SKILL.md на GitHub

Установить google-pubsub-webhooks в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

examples/express/.env.exampleexamples/express/README.mdexamples/express/package.jsonexamples/express/src/index.jsexamples/fastapi/.env.exampleexamples/fastapi/README.mdexamples/fastapi/main.pyexamples/fastapi/requirements.txtexamples/fastapi/test_webhook.pyexamples/nextjs/.env.exampleexamples/nextjs/README.mdexamples/nextjs/app/webhooks/google-pubsub/route.tsexamples/nextjs/lib/pubsub.tsexamples/nextjs/package.jsonexamples/nextjs/tsconfig.jsonexamples/nextjs/vitest.config.tsreferences/overview.mdreferences/setup.mdreferences/verification.md

FAQ

Что делает скилл google-pubsub-webhooks?

Receive and verify Google Cloud Pub/Sub push subscription webhooks. Use when setting up a Pub/Sub push endpoint, verifying the OIDC `Authorization: Bearer` JWT that Pub/Sub attaches to authenticated push subscriptions (iss, aud, email, email_verified), parsing the push envelope (`message.data` base64, `message.attributes`, `messageId`, `publishTime`, `subscription`), securing an unauthenticated push endpoint, or debugging redelivery and ack deadline issues.

Как установить скилл google-pubsub-webhooks?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл google-pubsub-webhooks запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить google-pubsub-webhooks с