Documentation

Install the Keycloak plugin

Documentation
On this page

From installation to the first push approval. You need the credentials from the portal in step 4; how to get them is described in Getting started.

All other settings (approval mode, logo, location, code fallback …) are described in Settings in Keycloak.

1. Install the plugin

The plugin is a single file, push-mfa.jar. You download it in the portal under Plugin and updates (okivo.app/en/app/downloads). For each version the portal lists the Keycloak versions it supports (currently Keycloak 26.x), what it changes and its SHA-256 checksum.

Put the file into the providers folder of your Keycloak installation and rebuild Keycloak once:

Shell
# copy the JAR into the providers folder
cp push-mfa.jar /opt/keycloak/providers/

# rebuild and start Keycloak
/opt/keycloak/bin/kc.sh build
/opt/keycloak/bin/kc.sh start --optimized

On startup the plugin writes its version to the Keycloak log, for example Okivo plugin 1.0.0.

With Docker or Podman it's best to build your own image:

Dockerfile
FROM quay.io/keycloak/keycloak:26.7 AS builder
COPY push-mfa.jar /opt/keycloak/providers/
RUN /opt/keycloak/bin/kc.sh build

FROM quay.io/keycloak/keycloak:26.7
COPY --from=builder /opt/keycloak/ /opt/keycloak/

The plugin brings the sign-in and setup pages as well as the email theme okivo for invitations. You don't need a login theme of your own; if you have one, see Custom themes.

2. Ready-made image okivo/keycloak-dist

Instead of building yourself, you can use our ready-made image: unmodified Keycloak by the Keycloak authors, plus the plugin and the free GeoIP database DB-IP City Lite (for Location and risk). Nothing else is changed, no branding either.

The image is public on Docker Hub (hub.docker.com/r/okivo/keycloak-dist); you don't need to sign in:

Shell
# Keycloak 26.7 with the latest stable Okivo version
docker pull okivo/keycloak-dist:26.7-stable

The Keycloak and plugin version of a fixed tag never change. Once a month we rebuild the images with the new GeoIP database. With Renovate, Dependabot or Watchtower you get updates through the 26.7-stable tag like with any other image.

The image starts with start and builds itself on the way. For a faster start with --optimized, build your own image on top of it with your build options:

Dockerfile
FROM okivo/keycloak-dist:26.7-stable
RUN /opt/keycloak/bin/kc.sh build --db=postgres --health-enabled=true

3. Add the authenticator to the login flow

In the admin console of the realm your users sign in to:

  1. Authentication → Flows: duplicate the browser flow, for example as browser-okivo.
  2. In the new flow, add the step Push MFA inside the sub-flow “forms”, directly below “Username Password Form”, and set it to Required.
  3. Make the new flow the browser flow with Bind flow.

The plugin creates the required action push-mfa (“Register Okivo device”), through which users set up their device, by itself on the first sign-in (Authentication → Required actions). If you disabled it there, enable it again.

Not on the top level and not in the realm “master”. If “Push MFA” sits on the top level of the flow, the step runs before Keycloak knows the user, and nobody can sign in any more. In the realm master this locks you out of the admin console. Test the new flow in a second browser before you sign out.

If you want to offer recovery codes as a fallback, put the step into the sub-flow for the second factor instead, see Recovery codes.

4. Enter the credentials

On the Push MFA step, open the settings via the gear icon, give it an alias and enter the three values from the portal: Relay Base URL, Tenant ID and Tenant API Key.

It's best to store the API key in the Keycloak vault and only reference it:

Shell
# file name: <realm>_<key>, here for the realm “acme”
echo -n 'pmfa_…' > /opt/keycloak/vault/acme_push-mfa-apikey
chmod 600 /opt/keycloak/vault/acme_push-mfa-apikey

# start Keycloak with the file vault
kc.sh start --vault=file --vault-dir=/opt/keycloak/vault

The Tenant API Key field then only contains ${vault.push-mfa-apikey}. In Kubernetes this works the same with a secret as vault. Without a vault you can also enter the key directly in the field; it is then stored (masked in the UI) in the Keycloak database.

The plugin copies the values into the realm settings so that device setup and the endpoints for the app know them too. The same form holds all other settings, see Settings in Keycloak.

5. Set up the first user

Sign in to the realm with a test account. Keycloak shows the setup page with a QR code; scan it with the Okivo app. The first push arrives with the next sign-in. Afterwards the user appears in the usage in the portal.

Setup page in Keycloak with a QR code and the link “Open in the Okivo app”
The setup page: QR code for the app, below it the way for users who read it on their phone.
  • The QR code is valid for five minutes. After that the user reloads the page.
  • Someone reading the page on their phone taps Open in the Okivo app, or copies the code and pastes it in the app under “Enter code”.
  • Applications can trigger the setup themselves with the OIDC parameter kc_action=push-mfa.

What happens next for your users is described in The Okivo app. You can pass that link on as it is.

Invite users

Instead of waiting for the next sign-in, invite users by email: in the admin console, open the user, choose the action “Set up Okivo” under Credentials → Credential reset and send the email. The link leads to the setup page from step 5.

Invitation email with three steps and the button “Set up Okivo”
The invitation. It contains no access code, only the link.
  • The link works once and for as long as you set when sending (default 12 hours).
  • If an account already has a device, the link requires a normal sign-in approved on the existing device. An intercepted email is therefore never enough to register another device.
  • For this Okivo email, set the email theme okivo under Realm settings → Themes; otherwise Keycloak sends its default text. Your realm needs working email delivery. With an email theme of your own, see Custom themes.
  • The email follows the user's language (German or English).

Update the plugin

You install new versions whenever you want. An installed plugin is never changed or switched off remotely. Keycloak only loads plugins at startup, so every update takes effect with the next restart. Older versions keep working with the push service; what a version changes is listed in the portal next to the version.

Versions and channels. Version numbers follow SemVer: a patch version fixes bugs, a minor version brings new features without you having to change anything, a major version requires something from you (for example an adjusted flow). There are two channels: stable and preview. Pre-releases such as 1.3.0-rc.1 only exist in preview; in the portal you see them under “Including pre-releases”.

Okivo updater

The updater needs no credentials. Download the script okivo-update.sh in the portal under “Plugin and updates” → “Automatic updates”. It only needs curl, openssl, unzip and awk.

Shell
# only check whether there is an update (exit code 10 = update available, 0 = up to date)
./okivo-update.sh --check

# install (then restart Keycloak)
./okivo-update.sh

# restore the previous version
./okivo-update.sh --rollback

systemd: before every Keycloak start

Configuration
# /etc/systemd/system/keycloak.service.d/okivo-update.conf
[Service]
# optional settings (OKIVO_CHANNEL, OKIVO_PIN, …)
EnvironmentFile=-/etc/okivo/update.env
Environment=KC_HOME=/opt/keycloak
ExecStartPre=/opt/okivo/okivo-update.sh
# kc.sh build may take a while depending on the machine.
TimeoutStartSec=300
Shell
sudo install -m 0755 okivo-update.sh /opt/okivo/okivo-update.sh
sudo mkdir -p /etc/systemd/system/keycloak.service.d
sudo cp okivo-update.conf /etc/systemd/system/keycloak.service.d/
sudo systemctl daemon-reload && sudo systemctl restart keycloak

Docker Compose

With Docker or Kubernetes the updater runs as a separate container before Keycloak (image okivo/keycloak-updater, public on Docker Hub) and puts the plugin into a shared providers volume. Keycloak then starts with start instead of start --optimized and builds itself on the way.

YAML
services:
  okivo-update:
    image: okivo/keycloak-updater:stable
    environment:
      OKIVO_KEYCLOAK_VERSION: "26.7.1"   # same as the Keycloak image below
      # OKIVO_PIN: "1"                   # optional: only 1.x
    volumes:
      - providers:/providers

  keycloak:
    image: quay.io/keycloak/keycloak:26.7.1
    command: ["start"]
    depends_on:
      okivo-update:
        condition: service_completed_successfully
    volumes:
      - providers:/opt/keycloak/providers
    # … your existing settings (KC_DB, KC_HOSTNAME, vault, ports)

volumes:
  providers:

Kubernetes

You don't need secrets or imagePullSecrets.

YAML
# Excerpt from the Keycloak deployment
spec:
  template:
    spec:
      initContainers:
        - name: okivo-update
          image: okivo/keycloak-updater:stable
          env:
            - { name: OKIVO_KEYCLOAK_VERSION, value: "26.7.1" }
          volumeMounts:
            - { name: providers, mountPath: /providers }
      containers:
        - name: keycloak
          image: quay.io/keycloak/keycloak:26.7.1
          args: ["start"]
          volumeMounts:
            - { name: providers, mountPath: /opt/keycloak/providers }
      volumes:
        # emptyDir: latest matching version on every pod start. Use a PVC for "only when needed".
        - name: providers
          emptyDir: {}

Updater settings

  • Safe on errors: If the service is unreachable or a checksum or signature doesn't match, the installed version stays and Keycloak starts as usual. With OKIVO_STRICT=1 the start is aborted instead.
  • Only matching versions: The updater asks for the latest version for your channel, your pin and your Keycloak version.
  • Atomic and reversible: The old JAR stays as push-mfa.jar.prev. If kc.sh build fails with the new version, the updater restores the old one. --rollback switches back.
  • Network: The updater only needs outbound HTTPS to okivo.app (version selection and files under okivo.app/releases). The images come from Docker Hub.
  • Older setups: The updater used to need a download token (OKIVO_DOWNLOAD_TOKEN). It is now ignored; you can remove it from your configuration.

Verify the signature

Every version is signed with our release key (Ed25519). The updater checks checksum and signature itself before installing anything; it has the public key built in.

If you download the plugin manually, verify it like this:

  1. In the portal, download push-mfa.jar and the Signature (push-mfa.jar.sig) of the version and compare the SHA-256 checksum with the one shown in the portal:

    Shell
    sha256sum push-mfa.jar
    
  2. Download the public release key and compare its fingerprint. That way you notice if someone replaced key and file together:

    Shell
    curl -O https://okivo.app/okivo-release-key.pub
    openssl pkey -pubin -in okivo-release-key.pub -outform DER | openssl dgst -sha256
    # Expected: dccb4a4436ab38e8ff43eecc92de88bc4d0d4a2613da843c4b3b3639915defd6
    
  3. Verify the signature (OpenSSL 3.x):

    Shell
    openssl pkeyutl -verify -pubin -inkey okivo-release-key.pub -rawin \
      -in push-mfa.jar -sigfile push-mfa.jar.sig
    # Output: Signature Verified Successfully
    

Verify the updater script the same way (okivo-update.sh with okivo-update.sh.sig).

If you get anything else, don't install the file and write to us at support@okivo.app.

Fingerprint of the Okivo release key (SHA-256): dccb4a4436ab38e8ff43eecc92de88bc4d0d4a2613da843c4b3b3639915defd6

Troubleshooting