---
title: "Okta account takeover protection integration | Darwinium"
slug: "okta"
description: "Integrate Darwinium with Okta hosted sign-in and token inline hooks. Configure profiling, risk decisions, authentication and end-to-end verification."
updated: 2026-11-11T03:41:04Z
published: 2026-11-11T03:41:04Z
canonical: "docs.darwinium.com/okta"
---
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.darwinium.com/llms.txt
> Use this file to discover all available pages before exploring further.
# Okta
Darwinium adds device, behavioural and journey risk assessment to Okta authentication flows to help detect account takeover. This guide connects an Okta-hosted sign-in page to Darwinium and uses a **Token Inline Hook** to allow or reject token issuance.
The reference uses a custom authorization server, a customised sign-in page and a CloudFront-hosted hook. Your application must use that authorization server. This is not a guide to signing in to the Darwinium portal with Okta.
**MFA scope:** the hook below does not initiate an MFA challenge. Configure Okta's authentication policies separately; a Darwinium `challenge` result is blocked by this sample until you implement a supported step-up flow.
> **Who this is for.** You run authentication on Okta with the **Okta-hosted sign-in page** (a custom domain such as `login.<your-domain>`), and you can stand up one internet-reachable HTTPS endpoint for the hook and the profiling collector. You have Darwinium portal access to deploy a journey. Your relying-party application must use the configured custom authorization server and supply a fresh OAuth `state` for each authorization request.
---
## Contents
1. [What this delivers](/docs/okta#1-what-this-delivers)
2. [How it works, and why it looks like this](/docs/okta#2-how-it-works-and-why-it-looks-like-this)
3. [Before you start](/docs/okta#3-before-you-start)
4. [Part A — Okta configuration](/docs/okta#part-a-okta-configuration)
5. [Part B — the Darwinium journey](/docs/okta#part-b-the-darwinium-journey)
6. [Part C — the edge middleware](/docs/okta#part-c-the-edge-middleware)
7. [The sign-in flow](/docs/okta#7-the-sign-in-flow)
8. [Verification](/docs/okta#8-verification)
9. [Operating this in production](/docs/okta#9-operating-this-in-production)
10. [Troubleshooting](/docs/okta#10-troubleshooting)
11. [Appendix: parameters](/docs/okta#11-appendix-parameters)
---
## 1. What this delivers
Darwinium evaluates a journey for each sign-in and decides the outcome of Okta's token mint:
| Outcome | What the user sees | Mechanism |
| --- | --- | --- |
| **Allow** | Normal sign-in, tokens issued | Hook returns `200 { "commands": [] }` |
| **Challenge** | No token issued by this sample | Requires a separate MFA integration; the sample blocks this result rather than treating it as an allow |
| **Reject** | Sign-in fails, no token issued | Hook returns `200 { "error": { … } }` — Okta abandons the token mint |
The block is delivered at the **token-issuance** step, so the user has already entered valid credentials before Darwinium's device and behavioural signals veto the login.
> **This is a fail-open control by design**
>
>
> A Token Inline Hook **fails open**. If your endpoint times out, errors, or returns an unsuccessful response, **Okta issues the token anyway**. Token hooks also do **not retry**. To *block* you must return **HTTP 200 with an `error` object within Okta's timeout (~3s)**. If you need fail-*closed* enforcement, put Darwinium's edge decisioning directly in the request path instead of relying on the token hook. Keep the failure policy explicit and test it before rollout.
---
## 2. How it works, and why it looks like this
The integration has three dependencies.
**1. Only a *custom* authorization server fires token inline hooks.** Okta's **org** authorization server (issuer `https://<your-okta-org>` with no `/oauth2/{id}`) — the one behind the Okta dashboard and plain SSO — never fires a token hook. You must mint the login's token from a **custom** authorization server, and the hook only fires once it is **bound to that server's access-policy rule**. Register the hook and nothing happens; it does nothing until step [A.4](/docs/okta#a-4-bind-the-hook-to-the-access-policy-rule-the-step-everyone-misses).
**2. The hook and the sign-in page must agree on a per-login correlator.** The profiling data is gathered in the browser on the sign-in page; the decision is needed later, server-to-server, when Okta calls the hook. Something must tie the two together. The cleanest tie is the OAuth **`state`** parameter: it is a structured value your app already sets uniquely per login, it is readable on the sign-in page (`OktaUtil.getRequestContext().authentication.request.state`), and it arrives in the hook payload at `data.context.protocol.request.state`. Darwinium keys the journey on it as `primary_session_tie`.
> **Custom `/authorize` parameters do not survive cleanly.** Only *known* OAuth parameters land in `data.context.protocol.request`. A custom parameter (e.g. `dwn_tie`) is dropped from `protocol.request` and survives *only* inside the raw authorize URL at `data.context.request.url.value`, which you would have to parse. Use `state` unless you have no usable `state`, in which case inject and parse a dedicated parameter.
**3. The browser can't reach the Darwinium mTLS Event API, so the collector and the hook live on an edge/CDN endpoint.** Darwinium's Event API uses mutual TLS on port `9443`. Keep the service's private key on the server; do not distribute it to browsers. So the profiling blob is sent to a **first-party edge endpoint** (a CloudFront distribution that also serves the profiling script), which simplifies CSP and CORS; the same distribution hosts the token-hook endpoint. The token-hook function holds the Darwinium client certificate; Darwinium proxy steps handle profiling collection separately.
The resulting shape:
.png?sv=2026-02-06&spr=https&st=2026-12-01T03%3A44%3A22Z&se=2026-12-01T04%3A44%3A22Z&sr=b&sp=r&sig=vRxS12hv9csseXotdsQECfxcdmjdYhyS%2FJLNBmtm85Q%3D)
One `state` value threads the browser-side profiling event to the server-side decision event.
---
## 3. Before you start
### You need
| Requirement | Details |
| --- | --- |
| Okta org | API Access Management/custom authorization-server entitlement for production, with a **custom domain** (e.g. `login.<your-domain>`) — this is what unlocks the sign-in-page code editor and CSP customisation |
| Okta admin | Super admin, or admin with app / authorization-server / customization / inline-hook rights |
| An HTTPS endpoint | Internet-reachable by Okta, hosting the token-hook endpoint **and** receiving the profiling blob. This guide uses a CloudFront distribution with a Lambda@Edge function |
| Darwinium | A node with an Event-API mTLS client certificate, and portal access to deploy a journey |
### The moving parts
| Component | Where it lives | Role |
| --- | --- | --- |
| Custom authorization server | Okta | Mints the login token and fires the hook |
| OIDC application | Okta | The relying party that logs the user in |
| Token Inline Hook | Okta → your edge endpoint | Calls Darwinium at token mint; can block |
| Custom sign-in page | Okta (brand) | Loads profiling, sends the blob keyed by `state` |
| `dwn_profiling.js` + `/__collect` + `/okta/token-hook` | Edge (CloudFront/Lambda@Edge) | Serve profiling, ingest the blob, run the hook |
| The journey (`web_collect`, `login`, `token_process`) | Darwinium | Ingests profiling, scores the login, returns the decision |
---
## Part A — Okta configuration
### A.1 Custom Authorization Server
**Security → API → Authorization Servers.**
Token inline hooks fire **only** when a **custom** authorization server mints the token — never on the org server. Use the built-in `default` custom server (issuer `https://<your-okta-org>/oauth2/default`) or create a dedicated one, and make sure your app requests its token from that issuer.

Request the scopes your application needs. `openid` enables OIDC, `profile` requests profile claims such as `preferred_username`, and `email` requests email claims. Confirm which identity claims are present in your hook payload.

### A.2 OIDC Application
**Applications → Create App Integration → OIDC - OpenID Connect.**
- **Application type:** this reference uses a **Single-Page App (SPA)** with
Authorization Code + PKCE. Web and Native app types work too.
- **Grant type:** Authorization Code (PKCE for SPA/native).
- **Sign-in redirect URI(s):** your application's callback.
- The app must obtain its token from the **custom** authorization server, not the
org server — otherwise the hook never fires.

### A.3 Register the Token Inline Hook
**Workflow → Inline Hooks → Add Inline Hook → Token.**

- **Name:** e.g. `darwinium-risk-hook`.
- **URL:** your edge endpoint, e.g.
`https://<your-cloudfront-domain>/okta/token-hook`.
- **Authentication:** add an HTTP header the middleware verifies, to authenticate calls from Okta. The delivered `eventType` is
`com.okta.oauth2.tokens.transform`.
- Set status **Active**.

> Registering the hook only defines the endpoint. **It does nothing until it is bound in the next step.**
### A.4 Bind the hook to the access-policy rule — the step everyone misses
**Security → API → Authorization Servers → {your custom server} → Access Policies.**
1. **Add Policy** and assign it to your app (or All Clients).
2. **Add Rule**, include the **Authorization Code** grant, and set your user /
scope conditions.
3. In the rule, set **"Use this inline hook"** → select your token hook → save.

Without a policy and rule on the custom server, the server cannot mint tokens for any client **and** there is nowhere to attach the hook — so it can never fire. The binding is inside the rule, under **THEN Use this inline hook**:

### A.5 Custom domain & brand
**Customizations → Brands.**
The custom domain (`login.<your-domain>`) is what unlocks the sign-in-page code editor and CSP customisation. Confirm the brand carrying your custom domain.

Under that brand's **Domains** tab, the custom domain should read **Active** with a valid certificate:

### A.6 Sign-in page code — inject Darwinium profiling
**Customizations → Brands → {brand} → Pages → Sign-in page → Page Design (code editor).**
In the existing sign-in page template, load `dwn_profiling.js`, read the login's `state`, and — once on password submission — send the profiling blob (in the `dwn-profiling` header) with **GET `/__collect`**, keyed by `state`.
The snippet replaces the existing widget initialisation/render block; do not render a second widget. It uses the `OktaUtil`/`renderEl` template pattern. Check your deployed widget generation and template before applying it; a 7.x version number alone does not identify Gen3.

```
```
Then **Save to draft → Publish**.
> **Every `<script>` you add must carry `nonce="{{nonceValue}}"`**
>
>
> The sign-in page enforces a strict Content-Security-Policy. A script tag without the required nonce can be blocked. Check the browser console for CSP violations if profiling does not start.
> **Check the submit event in your template.** This example listens for a password-form submission. Verify that your widget emits that event and that collection completes before the token hook runs. Passwordless sign-in, an existing Okta session and other flows may not show a password form; they need a collection trigger suited to that flow.
### A.7 Content Security Policy — trust the external hosts
**Sign-in page → Settings → Content Security Policy → Edit → Trusted external resources.** Add each host (one per entry) and keep enforcement **Enforced**:
- the **profiling script** host (the CDN serving `dwn_profiling.js`)
- the Darwinium **profiling collection** hosts (use the hosts supplied for your deployment)
- the **collect endpoint** host that receives the profiling GET request

> If a request is CSP-blocked you will see `Refused to connect` / `Failed to fetch` in the browser console — that host needs to be added here. Publish after editing.
---
## Part B — the Darwinium journey
The Okta side delivers two things to Darwinium, both keyed by the OAuth `state` (passed as `primary_session_tie`): the **profiling blob** (from the sign-in page at password submit) and the **token-hook call** (from Okta at token mint). The journey defines the steps that receive them.

| Step | Type | Trigger | Role |
| --- | --- | --- | --- |
| `Tag Profiling Step` | snippet (`dwn_profiling_step`) | serves `/dwn_profiling.js` | The profiling tag the sign-in page loads |
| `web_collect` | proxy | `GET /__collect` | Ingests the profiling blob; produces the `PROFILING` group keyed by `primary_session_tie` |
| `web_collect_options` | proxy | `OPTIONS /__collect` | CORS preflight for the collect request |
| `login` | API event (`account_login`) | `POST /api/event/{journey}/login` | The scored login event; **imports** `web_collect.PROFILING` and runs the Decision Strategy |
| `token_process` | proxy | `POST /__token` | Alternative entry point when the raw Okta hook payload is proxied through Darwinium |
### B.1 `web_collect` — ingest the profiling blob
The browser sends the blob (in the `dwn-profiling` header) to `/__collect` with `?primary_session_tie=<state>`. This proxy step extracts the tie and produces the `PROFILING` group under it.

- `url_match_type: ExactWithQuery` — the query string is part of the match.
- The CORS `access-control-allow-origin` must equal your sign-in page origin
(e.g. `https://login.<your-domain>`) or the browser rejects the response.
- The blob rides in the `dwn-profiling` request header, which must be listed in
`access-control-allow-headers`.
### B.2 `login` — the scored event that imports profiling
This is the decision step: an `account_login` API event that **imports** the `PROFILING` group from `web_collect` via the shared `primary_session_tie`. That import is what surfaces the device and behavioural signals on the login event so the Decision Strategy can score them.

The hook calls this step with the same `primary_session_tie` and the authenticated username; Darwinium resolves them into one journey, surfaces the profiling, and the Decision Strategy emits `pass | challenge | reject`. That `outcome.CHAMPION.decision_strategy.result` is the value the hook reads. The sample supports `pass` and `reject`; it also blocks `challenge` because it does not implement MFA.
### B.3 `token_process` — reading the correlator out of the hook payload
The `token_process` proxy step shows exactly how the correlator is extracted from the Okta hook payload. It maps the hook's JSON body:

The body mappings are the heart of the correlation — the same paths the middleware reads:
| JSONPath in the hook payload | Extracted to |
| --- | --- |
| `$.data.context.protocol.request.state` | `primary_session_tie` |
| `$.data.context.session.login` | `identity['ACCOUNT'].username.username` |

---
## Part C — the edge middleware
The **token-hook** endpoint runs as a Lambda@Edge viewer-request function. The **profiling collector** remains on the Darwinium-managed proxy path described in Part B. These are separate handlers even when they share a CloudFront distribution.
Do not attach the token-hook function to `/__collect` or `/dwn_profiling.js`: it does not ingest profiling or serve the tag.
### C.1 What the function does
The function authenticates Okta's POST, extracts the per-login state and username, then calls the Darwinium `login` step. A `pass` returns an empty commands array; `reject` and `challenge` return an error object. Transport errors and missing decisions follow the documented fail-open policy and are logged.
Token inline hooks use POST. The `x-okta-verification-challenge` GET handshake belongs to **event hooks**, not token inline hooks. See [Okta's event hook guide](https://developer.okta.com/docs/guides/event-hook-implementation/main/).
Keep hook responses within [Okta's timeout](https://developer.okta.com/docs/concepts/inline-hooks/#time-out-and-retry). Token hooks have no retry.
### C.2 The function source
Save this as `index.js`. Replace the deployment values in the **CONFIG** block and provide your certificate files. It reads the mTLS client certificate from a `dwn-certs/` folder bundled alongside it (there are no environment variables at the edge).
```
// index.js — Okta Token Inline Hook to Darwinium.
// Lambda@Edge VIEWER-REQUEST, Include body enabled, /okta/token-hook only.
const https = require('https');
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
// Replace these values before deployment. Never put the secret in browser code.
const DWN = {
host: '.node.darwinidentity.com',
port: 9443,
journey: '',
};
const LOGIN_STEP = 'login';
const HOOK_HEADER = 'x-darwinium-hook';
const HOOK_SECRET = '';
const CERTDIR = path.join(__dirname, 'dwn-certs');
const TLS = {
key: fs.readFileSync(path.join(CERTDIR, 'privkey.key')),
cert: fs.readFileSync(path.join(CERTDIR, 'darwinium-signed.pem')),
}; // Keep Node's default server CA trust store.
function response(status, body) {
return {
status: String(status),
headers: {
'content-type': [{ key: 'Content-Type', value: 'application/json' }],
'cache-control': [{ key: 'Cache-Control', value: 'no-store' }],
},
body: JSON.stringify(body),
};
}
function authenticated(headers) {
if (!HOOK_SECRET || HOOK_SECRET === '') return false;
const received = headers[HOOK_HEADER]?.[0]?.value || '';
const a = Buffer.from(received);
const b = Buffer.from(HOOK_SECRET);
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
function dwnCall(body) {
return new Promise((resolve, reject) => {
const payload = JSON.stringify(body);
let settled = false;
let timer;
const finish = (error, value) => {
if (settled) return;
settled = true;
clearTimeout(timer);
error ? reject(error) : resolve(value);
};
const req = https.request({
hostname: DWN.host, port: DWN.port,
path: `/api/event/${encodeURIComponent(DWN.journey)}/${LOGIN_STEP}`,
method: 'POST', key: TLS.key, cert: TLS.cert,
headers: {
'Content-Type': 'application/json', Accept: 'application/json',
'Content-Length': Buffer.byteLength(payload),
},
}, res => {
const chunks = [];
res.on('data', chunk => chunks.push(chunk));
res.on('error', err => finish(err));
res.on('aborted', () => finish(new Error('darwinium_response_aborted')));
res.on('end', () => {
if (res.statusCode < 200 || res.statusCode >= 300) {
return finish(new Error('darwinium_http_error'));
}
try { finish(null, JSON.parse(Buffer.concat(chunks).toString('utf8'))); }
catch (_) { finish(new Error('darwinium_invalid_json')); }
});
});
// An overall deadline, including connection setup and response transfer.
timer = setTimeout(() => {
finish(new Error('darwinium_timeout'));
req.destroy();
}, 2000);
req.on('error', err => finish(err));
req.end(payload);
});
}
function failOpen(reason) {
console.warn('[DWN] fail-open:', reason);
return response(200, { commands: [] });
}
exports.handler = async event => {
const request = event.Records[0].cf.request;
if (request.uri !== '/okta/token-hook') return response(404, { error: 'not_found' });
if (request.method !== 'POST') return response(405, { error: 'method_not_allowed' });
if (!authenticated(request.headers || {})) return response(401, { error: 'unauthorized' });
if (!request.body || request.body.inputTruncated) {
return response(400, { error: 'missing_or_truncated_body' });
}
let body;
try {
const raw = request.body.encoding === 'base64'
? Buffer.from(request.body.data, 'base64').toString('utf8')
: request.body.data;
body = JSON.parse(raw);
} catch (_) { return response(400, { error: 'invalid_json' }); }
const state = body?.data?.context?.protocol?.request?.state;
const login = body?.data?.context?.session?.login
|| body?.data?.identity?.claims?.preferred_username;
if (typeof state !== 'string' || !state) return failOpen('missing_state');
if (typeof login !== 'string' || !login) return failOpen('missing_identity');
try {
const result = await dwnCall({
primary_session_tie: state,
identity: { ACCOUNT: { username: { username: login } } },
});
const decision = result?.outcome?.CHAMPION?.decision_strategy?.result;
if (decision === 'reject' || decision === 'challenge') {
console.info('[DWN] decision=' + decision);
// This sample denies challenge results; it does not initiate MFA.
return response(200, { error: { errorSummary: 'Access denied' } });
}
if (decision === 'pass') {
console.info('[DWN] decision=pass');
return response(200, { commands: [] });
}
return failOpen('missing_or_unrecognised_decision');
} catch (_) {
return failOpen('darwinium_unavailable');
}
};
```
### C.3 Package the function
Save the source above as `index.js`. Create `dwn-certs/` alongside it and add your Darwinium mTLS client certificate and private key. Then package the files:
```
mkdir -p dwn-certs
# replace the placeholders with YOUR real Darwinium client cert + key:
# dwn-certs/darwinium-signed.pem dwn-certs/privkey.key
zip -j function.zip index.js
zip function.zip dwn-certs/privkey.key dwn-certs/darwinium-signed.pem
```
> **The mTLS key is a private credential**
>
>
> `privkey.key` is your Darwinium client **private key**. Never commit it to source control, never share a `function.zip` that contains a real key, and rotate it if it is ever exposed. Keep deployment bundles containing credentials in access-controlled storage.
### C.4 Create the IAM execution role
Lambda@Edge requires a role trusted by **both** `lambda.amazonaws.com` and `edgelambda.amazonaws.com`:
```
cat > trust.json <<'JSON'
{ "Version": "2012-10-17", "Statement": [{
"Effect": "Allow",
"Principal": { "Service": ["lambda.amazonaws.com", "edgelambda.amazonaws.com"] },
"Action": "sts:AssumeRole" }] }
JSON
aws iam create-role --role-name okta_dwn_edge_role \
--assume-role-policy-document file://trust.json
aws iam attach-role-policy --role-name okta_dwn_edge_role \
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
```
### C.5 Create the function and publish a version
The function **must** be created in **us-east-1**, and CloudFront can only associate a **numbered version**, never `$LATEST`:
```
aws lambda create-function --region us-east-1 \
--function-name okta_dwn_token_hook \
--runtime nodejs22.x --handler index.handler \
--role 'arn:aws:iam:::role/okta_dwn_edge_role' \
--timeout 5 --memory-size 128 \
--zip-file fileb://function.zip
# Publish a numbered version and note the value it prints (e.g. 1):
aws lambda publish-version --region us-east-1 \
--function-name okta_dwn_token_hook --query 'Version' --output text
```
This example uses the supported [Node.js 22 Lambda@Edge runtime](https://aws.amazon.com/about-aws/whats-new/2024/11/aws-lambda-support-nodejs-22/).
To ship a later change, re-zip, `aws lambda update-function-code`, then `publish-version` again and re-point the behaviour at the new version.
### C.6 Attach it to a CloudFront behaviour
On the distribution that serves `dwn_profiling.js`, add a behaviour for the hook path and associate the function as a **viewer-request** trigger with **Include body** enabled (so the handler can read the POST body). Keep the existing Darwinium worker associations on the collector and profiling-script behaviours.
| Behaviour setting | Value |
| --- | --- |
| Path pattern | `/okta/token-hook` |
| Viewer protocol policy | HTTPS only |
| Allowed methods | `GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE` |
| Cache policy | **Managed-CachingDisabled** |
| Function association | **Lambda@Edge**, event type **Viewer request**, **Include body: yes**, ARN = `…:function:okta_dwn_token_hook:<version>` |
Via the CLI, pull the config, add the behaviour to `DistributionConfig.CacheBehaviors.Items` (with `LambdaFunctionAssociations` → `EventType: viewer-request`, `IncludeBody: true`, the versioned ARN), increment `CacheBehaviors.Quantity`, and `aws cloudfront update-distribution --id <dist-id> --if-match <etag>`.
> **mTLS certificate gotcha.** Use the trust configuration appropriate to your Darwinium node's server certificate. For a certificate issued by a publicly trusted CA, in Node's `https` client, pass **only** the client `key` + `cert`; do **not** pass Darwinium's client-CA chain as `ca` — that replaces the system trust store and breaks server verification with "unable to get local issuer certificate".
> **Teardown.** A Lambda@Edge function cannot be deleted until CloudFront drains all edge replicas — hours after you detach the behaviour. Deletes report `DELETE_FAILED` / replicated-function errors until then; that is expected.
### C.7 Smoke-test the endpoint
After CloudFront reports `Deployed`, exercise the authenticated POST endpoint:
```
BASE='https:///okta/token-hook'
read -rs -p 'Hook secret: ' HOOK_SECRET_VALUE
printf '\n'
curl --fail-with-body -sS -X POST "$BASE" \
-H 'Content-Type: application/json' \
-H "x-darwinium-hook: $HOOK_SECRET_VALUE" \
-d '{"data":{"context":{"protocol":{"request":{"state":"smoke-test"}},"session":{"login":"test-user@example.com"}}}}'
unset HOOK_SECRET_VALUE
```
This tests the endpoint and its Darwinium call; it does not create browser profiling. A pass produces `{"commands":[]}`. A reject or challenge produces an `error` object. Check logs to distinguish an actual pass from fail-open behaviour, then perform the full sign-in tests below.
Also check that an incorrect hook secret returns HTTP 401. That rejects the caller; it is not the response used to deny a legitimate Okta token request.
---
## 7. The sign-in flow

1. The user opens the Okta-hosted sign-in page. `dwn_profiling.js` loads and
profiling starts; the page reads the login's `state`.
2. The user submits the password form. The capture-phase listener collects the
profiling blob and sends it with GET to `/__collect?primary_session_tie=<state>`.
Darwinium's `web_collect` step stores `PROFILING` keyed by `state`.
3. Okta authenticates the credentials and moves to mint the token on the custom
authorization server.
4. The token mint fires the Token Inline Hook. Okta POSTs the payload (carrying
`state`) to `/okta/token-hook`.
5. The edge function calls Darwinium's `login` step with
`primary_session_tie = state` and the username. Darwinium resolves the same
journey, surfaces the profiling from step 2, and the Decision Strategy scores
it.
6. The hook returns the decision: `{ commands: [] }` to issue the token, or
`{ error: {…} }` to block. On timeout or error, Okta issues the token
(fail-open).
> **Timing:** collection must complete before the login decision uses the imported profiling. Configure and test the journey dependency within the hook deadline. The sample function does not poll for a missing profiling event; check how your strategy handles missing data.
---
## 8. Verification
> **A successful login proves nothing on its own** — the hook fails open, so a login also succeeds when Darwinium saw nothing. Check both that the decision reached Okta **and** that Darwinium actually scored the journey.
### Confirm the login flows through the app
**Reports → System Log**, filtered to your OIDC app, shows real sign-ins hitting the custom authorization server (User login, sign-on policy evaluation, identity verification):

### Confirm Darwinium scored the journey
In the Darwinium portal, **Investigations** over the relevant window shows the `test` journey's events — the `web_collect` ingests and the scored `login` events, with dispositions and a device map. This is the authoritative proof that profiling was captured and a decision was produced under each `state`:

### Force a decision end-to-end
- To confirm **allow**: sign in normally; a token is issued and the hook returns
`{ commands: [] }`. In CloudWatch, confirm `decision=pass`.
- To confirm **reject**: add a condition to the `login` Decision Strategy that
matches your test identity and emits `reject`, then sign in. The token mint
fails and the edge log shows `decision=reject`.
> **Token Preview does NOT fire inline hooks.** Okta's Token Preview only simulates claims, scopes and policy. The hook fires only on a *real* token mint (an actual login, or a full `authorization_code` → `/token` exchange). Do not use Token Preview to test the hook.
---
## 9. Operating this in production
### The hook is fail-open — decide whether that is acceptable
On any timeout or non-200, Okta issues the token. This preserves availability during hook outages but means the hook cannot be your only line of defence for high-assurance flows. If you need a hard gate, place Darwinium's edge decisioning directly in the request path.
### Keep decision latency inside Okta's budget
The hook must return within ~3s or Okta abandons it (and issues the token). The Darwinium call carries a ~2s timeout and fails open on its own. Watch p95 on the edge function and on the Darwinium `login` step.
### Certificate rotation
Monitor the expiry date of your issued Darwinium client certificate and rotate it before expiry. Because the certificate is baked into the Lambda@Edge zip, rotation means redeploying a new function version and repointing the CloudFront behaviour.
### Never cache the hook or collect responses
The token-hook and `/__collect` behaviours must use a **caching-disabled** policy. Caching a per-login decision or profiling response would apply one user's outcome to another.
### Correlation is stateless
`state` is read from each hook payload and passed to Darwinium as `primary_session_tie`. The journey state lives in Darwinium, not in the middleware — the edge function holds no session.
---
## 10. Troubleshooting
| Symptom | Likely cause | Action |
| --- | --- | --- |
| Hook never fires | Token minted by the **org** server, or the hook not bound to the custom server's access-policy rule | Mint from the custom server ([A.1](/docs/okta#a-1-custom-authorization-server)); bind the hook ([A.4](/docs/okta#a-4-bind-the-hook-to-the-access-policy-rule-the-step-everyone-misses)) |
| Hook never fires, and you were testing with Token Preview | Token Preview does not call hooks | Drive a real login or a full `authorization_code` exchange |
| Sign-in page renders but no profiling, no console logs | A `<script>` is missing `nonce="{{nonceValue}}"` and CSP blocked it silently | Add the nonce to every injected script |
| `Refused to connect` / `Failed to fetch` in the console | The host is not in the CSP trusted external resources | Add the profiling and collect hosts ([A.7](/docs/okta#a-7-content-security-policy-trust-the-external-hosts)) |
| Collect request rejected by the browser (CORS) | `access-control-allow-origin` ≠ your sign-in origin, or `dwn-profiling` not in allow-headers | Match the origin exactly; allow the `dwn-profiling` header |
| Decision always allows, even for a risky user | Fail-open: the hook timed out, errored, or the `login` step saw no profiling | Check edge logs for `fail-open`; confirm the collect request lands before the hook resolves |
| Custom `/authorize` parameter missing in the payload | Custom params are dropped from `protocol.request` | Use `state`, or parse `data.context.request.url.value` |
| mTLS call fails "unable to get local issuer certificate" | Darwinium client-CA chain passed as `ca` | Pass only client `key` + `cert`; let Node use its system store |
---
## 11. Appendix: parameters
Replace throughout:
| Placeholder | Meaning | Example shape |
| --- | --- | --- |
| `<your-okta-org>` | Okta org / issuer host | `integrator-000000.okta.com` |
| `login.<your-domain>` | Okta custom sign-in domain | `login.example.com` |
| `<your-cloudfront-domain>` | Edge distribution serving profiling + hook + collect | `d….cloudfront.net` |
| `<your-node>` | Darwinium node hostname | `<node>.node.darwinidentity.com` |
| `<your-host-alias>` | Journey host alias for the edge target | `sandboxhost` |
| `<journey>` | Darwinium journey name | `test` |
| profiling hosts | Darwinium profiling collection hosts to trust in CSP | `aps.<node>`, `ats.<node>`, `*.dxf.<node>` |
### Correlation reference
| Value on `/authorize` | Read on the sign-in page | Read in the hook payload |
| --- | --- | --- |
| `state` *(recommended tie)* | `OktaUtil.getRequestContext().authentication.request.state` | `data.context.protocol.request.state` |
| `nonce` | same requestContext object | `data.identity.claims.nonce` |
| custom param (e.g. `dwn_tie`) | `new URLSearchParams(location.search).get('dwn_tie')` | `data.context.request.url.value` (raw URL — parse it) |
Also present in the hook with no parameter: `data.context.session.login` (username), `data.context.session.id`, `data.context.request.id`, `data.context.request.ipAddress`, and `data.identity.claims.preferred_username` / `email` (with the `profile` scope).
### Reference
- [Okta — Token inline hook](https://developer.okta.com/docs/guides/token-inline-hook/main/)
- [Okta — Inline hooks concept](https://developer.okta.com/docs/concepts/inline-hooks/)
- [Okta — Style the Okta-hosted sign-in page](https://developer.okta.com/docs/guides/custom-widget/main/)
- [Darwinium — Tags Deployment](https://docs.darwinium.com/docs/tags-deployment)
- [Darwinium — Event API](https://docs.darwinium.com/docs/event-api)
---
*Screenshots in this guide are from a reference deployment. Replace org names, hostnames, client IDs and account identifiers with your own.*