koa-gcp-iap

1.0.7 • Public • Published

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}`;
});

Package Sidebar

Install

npm i koa-gcp-iap

Weekly Downloads

0

Version

1.0.7

License

MIT

Unpacked Size

8.73 kB

Total Files

15

Last publish

Collaborators

  • saka1