Created
September 11, 2018 18:56
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime: nodejs8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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