# Connect TARA

> Setting up TARA, the Estonian state authentication service, as the login provider of Oktul eID SSO, and the token relay its live service needs.
>
> Documentation for Oktul eID SSO for Jira, for Jira Cloud, by Oktul: https://oktul.com/docs/plugins/eid-sso/tara/

[TARA](https://e-gov.github.io/TARA-Doku/) is the authentication service of the Estonian
Information System Authority (RIA), for Estonian government-sector institutions. Through TARA the
app accepts **the Estonian ID card, Mobile-ID and Smart-ID**.

TARA has a demo service and a live one. The demo works like any other provider. The live service
also needs a [token relay](#the-token-relay) on your own infrastructure, because it accepts token
requests only from registered IP addresses.

<Aside type="note" title="The live service is not tested yet">
We have tested the app with TARA's demo service. We have not yet run a login through the live
service and a relay against RIA, because that needs a live client. Test it with your own live
client and one user before you move anyone to it.
</Aside>

## What you need

- A TARA client from RIA. You apply with RIA's
  [application forms](https://www.ria.ee/riigi-infosusteem/elektrooniline-identiteet-ja-usaldusteenused/kesksed-autentimisteenused#tara),
  for the demo service first and then for the live one. RIA's
  [technical specification](https://e-gov.github.io/TARA-Doku/TechnicalSpecification) lists what
  an application holds.
- In the application: the redirect URL from the app's admin page, and the methods ID-card,
  Mobile-ID and Smart-ID
- For the live service: a host with a static IP address for the relay, and that address
  registered with RIA

## Add TARA with the demo service

1. **On the Login providers tab, select Add a provider and choose TARA (RIA)** The row shows the redirect URL for your application to RIA.
2. **Leave Environment on Demo**
3. **Enter the Client ID and the Client secret RIA issued for the demo**
4. **Select Save and connect, and approve Atlassian's dialog** It names https://tara-test.ria.ee.

RIA registers a separate client for each environment. Changing the environment or the client ID
needs that client's secret. With Live, or a demo sent through the relay, the secret goes in the
relay's credential file and the app has no field for it.

## What the app asks of TARA, and what it accepts

| Part of the login | What the app asks for or accepts |
|---|---|
| Scopes | `openid idcard mid smartid`, so TARA offers only the Estonian ID card, Mobile-ID and Smart-ID |
| Level requested | `acr_values=high` |
| Client authentication | The client secret, as HTTP Basic |
| Method (`amr`) | `idcard`, `mID` or `smartid` |
| Level of assurance (`acr`) | `high`. Not a setting. A token without a level is refused |
| Person | An Estonian personal code: `sub` is `EE` and the code |

- **No cross-border eIDAS logins.** The app does not ask for TARA's eIDAS scopes, and refuses a
  person from any country but Estonia.
- **Every login is a new authentication.** RIA's specification says TARA keeps no single sign-on
  session.

## The token relay

RIA's specification, section 4.3, says of the live service that token requests "are allowed only
from IP addresses that are configured per client application". The relay is a small container
you run. It gives the app one fixed address and forwards TARA's token request, and nothing else.

The relay is open source under the EUPL-1.2 licence, at
[github.com/Oktul/eID-TARA-remote](https://github.com/Oktul/eID-TARA-remote). The repository holds
the container, deployment files for Docker Compose and Kubernetes, and the setup guide.
[Run the token relay](../token-relay/) is the short version.

It runs on a host with a static outbound IP address, behind a reverse proxy that serves HTTPS
and admits only Atlassian's egress addresses.

What the relay does:

- **Only your site can use it.** Atlassian signs every call the app makes to it, and the
  relay checks the signature and the app, environment and site in it.
- **It holds TARA's client secret**, and adds it to the request. With TARA live, the app stores
  no TARA secret: the secret field is hidden, and saving **Live** deletes a stored demo secret.
- **It stores nothing.**
- **It cannot fake a login.** Only the token request passes through it. The app fetches TARA's
  discovery document and signing keys directly, and checks the ID token as it does for the demo.

<Aside type="caution" title="What passes through the relay">
The relay, and anything that ends TLS in front of it, such as a reverse proxy, a load balancer
or a tunnel, sees the token request and TARA's answer. The answer holds the person's personal
code and name. Run the relay on infrastructure that is yours or that your processing agreements
cover.
</Aside>

### Set up the relay

Choosing **Live** and saving adds a **Token relay** part to the TARA row.

1. **Prepare the relay on a host with a static IP address** Do steps 1 and 2 of Run the token relay: the deployment files and image tag, the reverse proxy, and for Kubernetes secret.yaml and networkpolicy.yaml. The last step here starts it.
2. **Register that IP address with RIA for your live client** The demo needs no registration. If you try the relay with the demo first, give the address when you apply for the live service.
3. **Enter the Relay URL and select Save relay URL** An HTTPS address with no path. Atlassian asks you to confirm it.
4. **Copy the Relay configuration into the relay's configuration** Four values, each between the quotes that stand in the deployment file: RELAY_APP_ID, RELAY_ENVIRONMENT_ID, RELAY_CLOUD_IDS and RELAY_UPSTREAM_URL. They tie the relay to this app, this environment and your site.
5. **Add TARA's credential and CA file to the relay** RELAY_UPSTREAM_AUTH_FILE and RELAY_UPSTREAM_CA_FILE, as section 3 of the relay's setup guide describes.
6. **Start the relay, then select Check relay** With the commands in the last step of Run the token relay.

Until a relay URL is saved, live logins end with *The eID service is not available*.
**Remove relay URL** takes it out again.

### The relay check

**Check relay** runs when the row opens and on demand, and the [health check](../health-check/)
runs it too.

| Result | Meaning |
|---|---|
| **The relay works** | It answers as a relay, forwards to the TARA environment in use and holds a credential |
| **The relay works, with a warning** | It is older than the oldest release the app supports, or is not a release build. Update it to the current release |
| **The relay does not work** | The message names the cause, for example no relay URL, a refused call, another upstream, no credential, an unsupported protocol version, or no answer within 15 seconds |

A relay that refuses the app names the three settings to compare: `RELAY_APP_ID`,
`RELAY_ENVIRONMENT_ID` and `RELAY_CLOUD_IDS`.

### Try the relay with the demo first

TARA's demo accepts any IP address. With **Demo** chosen, tick **Send token requests through my
token relay** to send the demo's token requests through the relay as well. The relay then holds
the demo secret, its configuration names `https://tara-test.ria.ee`, and a demo login tests the
whole relay path before you go live. The live client stays untested: its credential, its
upstream and RIA's list of allowed addresses.

## Go live

These steps assume a relay that already runs and passes **Check relay**, set up as in
[Set up the relay](#set-up-the-relay) and [tried with the demo](#try-the-relay-with-the-demo-first).

1. **Apply to RIA for the live service** With the same redirect URL and the relay's IP address.
2. **Give the relay the live client, and set its upstream to https://tara.ria.ee** Build a new credential file from the live client ID and secret together (section 3.1 of the relay's setup guide), and set RELAY_UPSTREAM_URL. Demo logins through the relay stop until the next step is saved. With Compose, start the relay again with docker compose up -d, because docker compose restart keeps the old settings. With Kubernetes, recreate the Secret eid-tara-remote-upstream-auth from the new credential file and the same CA file, apply deployment.yaml, then run kubectl rollout restart (section 5). With the demo client ID still in the file, TARA refuses every live login.
3. **In the TARA row, set Environment to Live and enter the live Client ID** Save, and approve Atlassian's dialog for https://tara.ria.ee.
4. **Select Check relay, then log in as a test user**

## Keeping a record of logins

RIA's specification asks a client to log its use of TARA and advises keeping the records for 1
to 7 years. The app's [audit log](../audit-log/) records successful logins once you turn that
on, keeps them for one year and exports them as CSV for your own archive.

## Common questions

**Why does TARA's live service need a relay?**

Because TARA's production environment accepts token requests only from the IP addresses registered for your client, and an app on Atlassian Forge has no fixed IP address. The token request goes through a small relay you run on a host with a static IP address.

**Can the relay log someone in by itself?**

No. The relay forwards one request. The app fetches TARA's signing keys directly and checks the ID token exactly as it does without a relay.

**Can a private company use TARA?**

Not for Estonian eIDs. According to the Estonian Information System Authority, TARA is for government-sector institutions. A private organisation uses [eeID](../eeid/), [Signicat](../signicat/) or [Dokobit](../dokobit/).

## Related

- [Login providers](../providers/)
- [Security](../security/)
- [Troubleshooting](../troubleshooting/)

---

A problem or a question? Write to [support@oktul.com](mailto:support@oktul.com) or open a request in the [Help Center](https://support.oktul.com).
