# Web based authentication form for KanoOS

Authentication from based on [`kwc-auth`](https://github.com/kanocomputing/kwc-auth) running on kano-webengine and sending authentication token through QWebChannel

## Installing dependencies

login in npm first

```
yarn
```

## Development

Run `yarn serve`

## Building

Bundle and compress the code. Env is pulled from the `NODE_ENV` env var. Then just run:

`yarn build`

## Deploying

The build uses `terraform` to deploy the infrastructure and `kart` to deploy
the site.

### Terraform

Ensure that you've configured your `~/.aws/credentials` file with the
instructions found [here](https://github.com/KanoComputing/kes-documentation/blob/master/Access.md)
and with the old production account (which should be named `production`). This
is only necessary until we migrate this to be owned by the new production
account.

#### Sandbox deploy

```
aws-mfa --profile kano-ops login <token> --shell
aws-mfa assume-role kano-staging --duration 3600  --shell
terraform init --backend-config=terraform/staging-backend.tfvars terraform/
terraform plan -out=plan -var-file=terraform/staging.tfvars terraform/
terraform apply plan
```

#### Production Deploy

Note that currently this is deployed to the old production account.

```
terraform init --backend-config=terraform/prod-backend.tfvars terraform/
terraform plan -out=plan -var-file=terraform/prod.tfvars terraform/
terraform apply plan
```

### Deploy

We have separate deployments for the OS and web. Each has a `staging` and `production` channel. To deploy either of them, use the following commands:

```bash
# Build the project first
yarn build

# OS
yarn publish:os:staging
yarn publish:os:prod

# Web
yarn publish:web:staging
yarn publish:web:prod
```

For the publish commands to work, you'll need kart configured on your machine (have the `.kartrc` file and aws credentials in your home directory). See the [kart README](https://github.com/KanoComputing/kart/blob/master/README.md) for more detailed information.

### CI

**Update 27/02/2020**: Currently the CI builds don't seem to work.

Currently all branches will get deployed - `master` will deploy automatically to production and all other branches will deploy to staging.
