Skip to content

saka1/koa-gcp-iap

Repository files navigation

koa-gcp-iap

Node.js CI

A koa middleware to verify requests with the GCP Identity-Aware Proxy.

Install

npm i koa-gcp-iap

Usage

Insert iap middleware before your application. It needs projectNumber/backendServiceId or projectNumber/projectId, which depends on your runtime environment.

Following application can read sub and email field from ctx.iapPayload. See https://cloud.google.com/iap/docs/signed-headers-howto#retrieving_the_user_identity for more details.

This is a minimal example.

const iap = require("koa-gcp-iap");
const Koa = require("koa");
const app = new Koa();

app.use(
  iap({
    projectNumber: "123456789",
    // projectId: "dummyProjectId",
    backendServiceId: "dummyBackendServiceId",
  })
);

app.use(async (ctx) => {
  ctx.body = `Hello World: ${ctx.iapPayload}`;
});

About

A koa middleware to verify requests with the GCP Identity-Aware Proxy

Resources

License

Stars

Watchers

Forks

Packages

No packages published