---
title: "Token Handler Installation"
description: "Install the Curity token handler that will act as a Backend for Frontend (BFF) for a single page application."
url: "https://curity.io/resources/learn/token-handler-getting-started/"
date: "2024-12-01"
area: "tutorials"
topic: "getting-started"
pagegroup: "tokenhandler-getting-started"
---

# Token Handler Installation

The [token handler pattern](https://curity.io/resources/learn/token-handler-overview/) enables single page applications to follow web security best practices. An SPA calls OAuth secured APIs via the token handler, which acts as a Backend for Frontend (BFF) for the SPA. The token handler consists of stateless API components and does not require any backend storage. API requests use HTTP-only cookies and there are no tokens in the browser.

![Token handler components issue first-party cookies on behalf of the Single Page Application](https://curity.io/images/resources/neo_security/token-handler/token-handler.svg) 

## Design Token Handler URLs

The first task is usually to design token handler base URLs, to provide endpoints for SPAs. You should consider both web development URLs and deployed systems.

Same Site Requirement

When designing URLs, make sure the SPA and BFF share the same parent site and use the same scheme (HTTP or HTTPS), so that cookies are same-site and the browser sends them reliably.

### Web Development URLs

Start with development base URLs, which might use the following existing values, where a local SPA calls deployed APIs and an authorization server:

| Component | Base URL | Runs Locally? |
| --- | --- | --- |
| SPA | `http://localhost:3000` | Yes |
| API | `https://api.example.com` | No |
| Authorization Server | `https://login.example.com` | No |

To use the token handler pattern there are no changes to the hosting of the APIs or the authorization server. Instead, add a new base URL that runs token handler components. Some example base URLs are summarized below.

| Component | Base URL | Runs Locally? |
| --- | --- | --- |
| SPA | `http://www.demoapp.example:3000` | Yes |
| Token Handler | `http://api.demoapp.example` | No |
| API | `https://api.example.com` | No |
| Authorization Server | `https://login.example.com` | No |

It is possible to run a development setup that uses `localhost` URLs, but a more productive option for web developers is to switch to a domain based URL during development, such as `http://www.demoapp.example:3000`. Doing so enables web developers to externalize cookie security to a remote token handler.

### Deployed URLs

It is usual to deploy the SPA and token handler to multiple stages of a deployment pipeline. The following table shows some example URLs:

| Stage | SPA Base URL | Token Handler Base URL |
| --- | --- | --- |
| Development | `http://www.demoapp-dev.example:3000` | `http://api.demoapp-dev.example` |
| Testing | `https://www.demoapp-test.example` | `https://api.demoapp-test.example` |
| Staging | `https://www.demoapp-staging.example` | `https://api.demoapp-staging.example` |
| Production | `https://www.demoapp.example` | `https://api.demoapp.example` |

## Install the Curity Token Handler

Once there is a known token handler base URL, the next deployment step is to deploy the Curity product and use a license file to activate the token handler feature. The installation provides an administration user interface to configure the system and runtime endpoints that implement the security work.

Install the Curity product on any Linux based platform. Choose one of the options from the following sections to get up and running, and follow the links to tutorials to learn more about the installation mechanics for each platform.

**Docker**

The [Install using Docker](https://curity.io/resources/learn/run-curity-docker/) tutorial explains how to deploy the Curity product using Docker. Run the following example commands to set an admin password and quickly install the token handler on Docker on any Windows, macOS or Linux computer.

```bash
export PASSWORD='zIf66A9Wz'
docker run -it -e PASSWORD=$PASSWORD -p 6749:6749 -p 8443:8443 curity.azurecr.io/curity/idsvr
```

**Helm**

To install to a Kubernetes cluster in a cloud platform or on-premise, use the Helm chart, which spins up separate containers for the admin and runtime roles. The following example commands demonstrate a basic installation:

```bash
helm repo add curity https://curityio.github.io/idsvr-helm/
helm repo update
helm install idsvr-tutorial curity/idsvr \
    --set image.tag=latest \
    --set curity.config.password=Password1 \
    --set curity.config.uiEnabled=true
```

The [Install using Helm](https://curity.io/resources/learn/install-helm-chart/) tutorial says more on how to get started with the Helm chart. Follow our [Kubernetes tutorials](https://curity.io/resources/kubernetes/) to learn more about deploying to clusters.

**AWS**

The Curity Amazon Machine Image (AMI) enables the Curity product to run on EC2 instances in AWS. Learn more about the details in the [Install on AWS (AMI)](https://curity.io/resources/learn/run-curity-aws/) getting started guide.

**Azure**

The Curity Azure Resource Manager (ARM) template enables the Curity product to run on an Azure Container Instances (ACI). Learn more about the details in the [Install on Azure](https://curity.io/resources/learn/install-on-azure/) getting started guide.

**GCP**

The Curity product can run on any Linux based operating system in the Google cloud platform, such as a containers or virtual machines. The [Install using Google Cloud Platform](https://curity.io/resources/learn/install-on-gcp/) tutorial explains an example deployment.

## Run the First Configuration

After deployment, log in to the Admin UI using the username **admin** and the configured password. The Admin UI URL is `https://localhost:6749/admin` for a local Docker deployment. It may have a different host name for other deployments. Next, configure and deploy the token handler so that the SPA can make OAuth and API requests. The [First Configuration](https://curity.io/resources/learn/token-handler-first-configuration/) tutorial explains the configuration steps.
