Skip to content

Instantly share code, notes, and snippets.

@asciimike
Created September 11, 2018 18:56
Show Gist options
  • Save asciimike/366e05d86ec9c48108719a5a9b37eeda to your computer and use it in GitHub Desktop.
Save asciimike/366e05d86ec9c48108719a5a9b37eeda to your computer and use it in GitHub Desktop.
Testing Google Cloud IAP (https://cloud.google.com/iap) with GAE 2nd Generation Runtimes
runtime: nodejs8
const express = require('express');
const app = express();
app.get('/', (req, res) => {
const jwt = req.headers['x-goog-iap-jwt-assertion'] || 'No JWT';
const uid = req.headers['x-goog-authenticated-user-id'] || 'No UID';
const email = req.headers['x-goog-authenticated-user-email'] || 'No email';
console.log(jwt);
console.log(uid);
console.log(email);
res.status(200).send('Hello: ' + email);
});
if (module === require.main) {
const server = app.listen(process.env.PORT || 8080, () => {
const port = server.address().port;
console.log(`App listening on port ${port}`);
});
}
module.exports = app;
{
"name": "IAP Gen 2 Test",
"version": "1.0.0",
"description": "Testing Google Cloud IAP on GAE Gen 2 runtimes",
"scripts": {
"start": "node index.js",
},
"author": "Mike McDonald",
"license": "Apache-2.0",
"dependencies": {
"express": "^4.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment