|
| 1 | +# Google Cloud Identity Aware Proxy Samples |
| 2 | + |
| 3 | +These samples show how to use the [Google Cloud Identity Aware Proxy][iap]. Cloud Identity-Aware Proxy (Cloud IAP) controls access to your cloud applications running on Google Cloud Platform. Cloud IAP works by verifying a user’s identity and determining if that user should be allowed to access the application. |
| 4 | + |
| 5 | +If this is your first time using the Google Cloud Identity Aware Proxy, try out our [quickstart tutorial][iap-quickstart]. |
| 6 | + |
| 7 | +Visit the [Programmatic authentication][iap-programmatic-authentication] and [Securing your app with signed headers][iap-signed-headers] tutorials to learn more about how these code samples work. |
| 8 | + |
| 9 | +You can also learn more by reading the [Cloud IAP conceptual overview][iap-conceptual-overview]. |
| 10 | + |
| 11 | +## Setup |
| 12 | + |
| 13 | +1. Deploy this [basic web application to App Engine][iap-app-engine]. |
| 14 | +1. Once the application is deployed, enable Cloud IAP for it using the Enabling Cloud IAP section of [this tutorial][iap-enable]. |
| 15 | +1. [Create a service account][create-service-account] that you will later use to access your Cloud IAP protected site. Give it the role of 'Project > Owner' and check the box for 'Furnish a new private key'. |
| 16 | +1. Save the service account key you created in the previous step to your local computer. |
| 17 | +1. [Grant your service account access][iap-manage-access] to your Cloud IAP application. |
| 18 | +1. Visit the [Cloud IAP admin page][iap-console] and click the ellipses button on the same row as 'App Engine app'. Click 'Edit OAuth Client' and note the Client ID. |
| 19 | +1. **Install dependencies** via [Composer][composer]. Run `php composer.phar install` (if composer is installed locally) or `composer install` (if composer is installed globally). |
| 20 | + |
| 21 | +## Samples |
| 22 | + |
| 23 | +To run the Cloud Identity Aware Proxy Samples: |
| 24 | + |
| 25 | + $ php iap.php |
| 26 | + Cloud Identity Aware Proxy |
| 27 | + |
| 28 | + Usage: |
| 29 | + command [options] [arguments] |
| 30 | + |
| 31 | + Options: |
| 32 | + -h, --help Display this help message |
| 33 | + -q, --quiet Do not output any message |
| 34 | + -V, --version Display this application version |
| 35 | + --ansi Force ANSI output |
| 36 | + --no-ansi Disable ANSI output |
| 37 | + -n, --no-interaction Do not ask any interactive question |
| 38 | + -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug |
| 39 | + |
| 40 | + Available commands: |
| 41 | + request Make a request to an IAP-protected resource using a service account. |
| 42 | + validate Make a request to an IAP-protected resource using a service account and then validate the JWT. |
| 43 | + |
| 44 | +### Run Request |
| 45 | + |
| 46 | +To run the Request sample: |
| 47 | + |
| 48 | + $ php iap.php request [YOUR_CLOUD_IAP_URL] [YOUR_CLIENT_ID] [PATH_TO_YOUR_SERVICE_ACCOUNT] |
| 49 | + |
| 50 | +### Run Validate |
| 51 | + |
| 52 | +To run the Analyze Sentiment sample: |
| 53 | + |
| 54 | + $ php iap.php validate [YOUR_CLOUD_IAP_URL] [YOUR_CLIENT_ID] [PATH_TO_YOUR_SERVICE_ACCOUNT] [YOUR_PROJECT_NUMBER] [YOUR_PROJECT_ID] |
| 55 | + |
| 56 | +[iap]: http://cloud.google.com/iap |
| 57 | +[iap-quickstart]: https://cloud.google.com/iap/docs/app-engine-quickstart |
| 58 | +[iap-app-engine]: https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/iap/app_engine_app |
| 59 | +[iap-enable]: https://cloud.google.com/iap/docs/app-engine-quickstart#enabling_iap |
| 60 | +[create-service-account]: https://console.cloud.google.com/iam-admin/serviceaccounts?_ga=2.249998854.-1228762175.1480648951 |
| 61 | +[iap-manage-access]: https://cloud.google.com/iap/docs/managing-access |
| 62 | +[iap-console]: https://console.cloud.google.com/iam-admin/iap |
| 63 | +[composer]: http://getcomposer.org/doc/00-intro.md |
| 64 | +[iap-programmatic-authentication]: https://cloud.google.com/iap/docs/authentication-howto#authenticating_from_a_service_account |
| 65 | +[iap-signed-headers]: https://cloud.google.com/iap/docs/signed-headers-howto |
| 66 | +[iap-conceptual-overview]: https://cloud.google.com/iap/docs/concepts-overview |
0 commit comments