# cypress-iap

> Cypress command to authenticate to Google Identity Aware Proxy(IAP)

Latest version **2.0.1** (published 2022-02-22) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install cypress-iap
pnpm add cypress-iap
yarn add cypress-iap
bun add cypress-iap
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2022-02-22 |
| First published | 2020-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Colt Dorsey |
| Maintainers | coltdorsey, onx-qa |
| Keywords | cypress, identity aware proxy, iap, iap-verification, google-authentication |

## Links

- npm: https://www.npmjs.com/package/cypress-iap
- Repository: https://github.com/onxmaps/cypress-iap
- Homepage: https://github.com/onxmaps/cypress-iap#readme
- Issues: https://github.com/onxmaps/cypress-iap/issues
- npm.io page: https://npm.io/package/cypress-iap

## Dependencies (2)

- [underscore.string](https://npm.io/package/underscore.string.md) >=3.3.5
- [google-auth-library](https://npm.io/package/google-auth-library.md) ^6.1.0

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 2.0.1 (latest) — 2022-02-22
- 2.0.0 — 2022-01-26
- 0.0.0-development — 2020-09-23
- 1.0.0 — 2020-09-18

## README

# Cypress-IAP [![npm version](https://badge.fury.io/js/cypress-iap.svg)](https://badge.fury.io/js/cypress-iap) ![cypress-iap status](https://github.com/onxmaps/cypress-iap/workflows/ci/badge.svg?branch=master)

# Cypress Identity Aware Proxy(IAP)

This Cypress plugin overwrites the `cy.visit` command and builds authentication capability [google-auth-library](https://github.com/googleapis/google-auth-library-nodejs) to access applications behind [Identity Aware Proxy(IAP)](https://cloud.google.com/iap/). If the the cypress baseUrl is localhost, the original `cy.visit` function is returned.

## Installation

Install the package using npm:

```
npm i -D cypress-iap
```

And add the following at the beginning of your setup file at `cypress/support/index.js`:

```
import 'cypress-iap/visit';
```

## Register the plugin

Register the plugin in your `cypress/plugins/index.js` file like this:

```
module.exports = (on, config) => {
    require('cypress-iap/utils')(on, config);

    return config;
};
```

## Google Service Account

A google service account should be created within your google cloud project. Upon creation, store the keyfile that is auto generated.

[Create a google service account](https://cloud.google.com/iam/docs/creating-managing-service-account-keys#creating_service_account_keys)

Do `NOT` check this file in to your remote repository. Store it outside of your project or .gitignore / .dockerignore your keyfile.

### Example google cloud service account

`keyfile.json`

```
{
  "type": "service_account",
  "project_id": "<project_id>",
  "private_key_id": "<private_key_id",
  "private_key": "-----BEGIN PRIVATE KEY-----\n <private_key> \n-----END PRIVATE KEY-----\n",
  "client_email": "<service_account_name>@<google_cloud_project>.iam.gserviceaccount.com",
  "client_id": "<client_id>",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/<google_clould_project>.iam.gserviceaccount.com"
}
```

### Set GOOGLE_APPLICATION_CREDENTIALS env variable

Ensure the `GOOGLE_APPLICATION_CREDENTIALS` environment variable is set to the credentials path of the credentials file.

```
export GOOGLE_APPLICATION_CREDENTIALS=path/to/keyfile.json
```

Alternatively you can use third party plugin called [as-a](https://github.com/bahmutov/as-a) and in your `as-a.ini` you can set the following configuration:

`as-a.ini`

```
[auth-me]
GOOGLE_APPLICATION_CREDENTIALS=keyfile.json
```

This command will execute the [as-a](https://github.com/bahmutov/as-a) package set the variables defined under `[auth-me]`.

```
as-a auth-me cypress run
```

---
_Source: https://npm.io/package/cypress-iap · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
