Skip to content

Field workers

Field workers (for example drivers or warehouse staff) do not have platform accounts. They sign in to the platform with a worker code and a PIN from an enrolled device, through the platform’s /field/* routes and the field client libraries. The platform issues a short field access token bound to the device’s key. Your application never sees a PIN and hosts no field login: it only verifies what the device presents on each request. For the identity model see field workers; the framework rules are section 15 of the sessions and login specification.

Field authentication is off by default. Sessions and bearer tokens work as before.

It needs application(code) (a token’s audience must equal your application code) and auth.cookie-keys (the nonces below derive from them). Without either, start-up fails with a message that says which. The DPoP authorization scheme then works on every route that requires a context; without the opt-in it is answered 401.

AuthModule.builder()
.application(new ApplicationCode("orders")) // a token's audience must equal this
.fieldWorkers(FieldOptions.builder()
.permissions(FieldPermissions.byDeviceMode(Set.of("orders:gate:open", "orders:gate:view"), Set.of("orders:gate:view")))
.replayCache(lookup -> RedisFieldReplayCache.create(lookup.get(RedisConnections.class).defaultInstance()))
.build())
.build()

FieldOptions also takes proofWindow (default 24 hours).

When field workers are on, the OpenAPI document lists the dpop security scheme (HTTP scheme DPoP, bearerFormat fc-field+jwt), and context operations list session, bearer and dpop. Without field workers the document is unchanged.

Authorization: DPoP <field access token> and DPoP: <proof> (RFC 9449). The framework checks, in order:

  1. The token, with the same keys, cache and issuer as bearer tokens, RS256 only: JOSE typ fc-field+jwt, iss, aud equal to your application code, exp/nbf/iat, token_use field, sub starting fwu_, and client_id, client_identifier, sid and cnf.jkt present. device_id is absent on a device that is not enrolled (device_mode UNENROLLED). A device_mode that is neither PERSONAL nor SHARED is treated as SHARED, the lesser permission set. A pcr claim (a temporary-PIN token, valid only on the platform’s PIN change) is answered 403 PIN_CHANGE_REQUIRED.
  2. The proof: an ES256 JWS signed by the key named in its header, whose RFC 7638 thumbprint equals the token’s cnf.jkt; htm equals the method; htu equals auth.public-base-url plus the request path (no query; the Host header is never used); ath is the hash of the token; jti is present; iat is within the window.
  3. The application nonce and the replay cache.
Situation Answer
any refusal of the token or the proof 401 UNAUTHENTICATED, WWW-Authenticate: DPoP error="invalid_token" (the reason is logged at debug level)
no nonce, or one that is not valid 401 USE_DPOP_NONCE, WWW-Authenticate: DPoP error="use_dpop_nonce". The client retries once with the nonce in the response
a pcr token 403 PIN_CHANGE_REQUIRED
the platform’s keys or the replay cache cannot be read 503 UNAVAILABLE

There is no fall-back to the session cookie, CSRF does not apply (as for bearer tokens), and a 401 is never turned into a redirect. Every response to a DPoP request carries a fresh DPoP-Nonce header, success or error, so a client rarely needs the retry.

Field devices keep bad time, so a proof’s iat is accepted within 24 hours of your clock and freshness comes from a nonce. The platform’s nonces are stored platform-side, so your application issues its own, statelessly: a nonce is the five-minute bucket and a MAC of it under a key derived (HKDF-SHA256) from your cookie key. It is valid in its bucket and the next, under any configured cookie key, so rotating auth.cookie-keys does not break devices. Removing a key from the list does invalidate the nonces made with it. Nothing is stored.

A proof’s jti is remembered per device key for 11 minutes. The default is in memory, and start-up logs one warning saying so: with more than one replica a captured proof can be replayed against another replica inside the window. Applications with several replicas pass the Redis cache (key fw:dpop:{jkt}:{jti}, SET NX PX):

RedisFieldReplayCache, in framework-auth-redis.

A cache that cannot be reached answers 503: a proof is never accepted unchecked. Replay also needs the access token (because of ath) and is limited to the same method and URL.

The request’s Context has the principal fwu_... with kind FIELD_WORKER, the worker’s name as the subject name (the token’s name; an operator signed in as the worker is the actor), the client from the token (client_identifier: a field worker belongs to exactly one client), the application, and the permissions from your field mapping.

A request for another client is refused. Your client selector is consulted for field workers too. When it names a client other than the worker’s (an application that takes the client from the path, /api/clients/globex/..., with a worker of acme), the answer is 403 CLIENT_NOT_PERMITTED, the same as for a user of another client, before your field permission resolver runs. When it names the worker’s own client or the platform (no client named), the context’s client is the worker’s. So a handler need not compare the path’s client with the worker’s itself. The selector sees the worker as a principal of kind FIELD_WORKER with no clients; return the platform client rather than throwing for one you do not recognise.

routes.post("/api/v1/gates/open", gates::open,
RouteOptions.requiresContext()
.with(Auth.requireSource(Authenticated.Source.FIELD))
.with(Auth.require("orders:gate:open")));
Optional<FieldPrincipal> worker = Auth.current(request).orElseThrow().field();

FieldPrincipal holds the worker id and code, name, client id and identifier, application code, device id (empty when unenrolled), device mode (PERSONAL, SHARED or UNENROLLED), the actor (who is signed in as the worker), the authentication methods and time, the session id, the expiry and the thumbprint of the device key the token is bound to (cnf.jkt; a push ticket bound to a key is checked against it). The linked platform user, if any, is for audit correlation only and grants nothing: no permission, role or tier comes from it. A field worker has no roles, applications, clients or tier: no platform authority.

Use requireSource to make a route field-only (FIELD) or never-field (SESSION and BEARER).

Field permissions are mapped separately from sessions and bearer tokens. The default grants none, so a route that requires a permission refuses field workers until you map them. A fixed set (FieldPermissions.all(...) / auth.FieldPermissionsAll(...)) or one set per device mode (byDeviceMode(personal, shared), which gives shared kiosks less) cover most cases.

If the application keeps a worker’s roles in its own store, give a resolver instead. It is called on every authenticated field request with the request and the verified FieldPrincipal, and returns the permissions. Empty or null grants nothing. If it throws or returns an error, the request answers 503 UNAVAILABLE (with a fresh DPoP-Nonce), never “no permissions” and never 401 or 403, so a store outage makes the device retry. The last of the mapping and the resolver given wins.

FieldOptions.builder().permissionResolver((request, worker) -> /* permissions */ ...)

FieldTokens (Java; provided when field workers are on) verifies a token on its own, without a proof, for a check outside the request path.

Access tokens live ten minutes, so a revoked device or a suspended worker keeps a valid token until it expires. For an action that cannot wait (opening a gate, releasing a load), add the live check. It calls the platform’s POST /api/field-tokens/introspect with your application’s service account, which needs the permission platform:iam:field-token:introspect.

routes.post("/api/v1/gates/open", gates::open,
RouteOptions.requiresContext()
.with(Auth.requireSource(Authenticated.Source.FIELD))
.with(RequireLiveField.of(app, Duration.ofSeconds(30))));
  • active: false: 401 UNAUTHENTICATED with WWW-Authenticate: DPoP error="invalid_token".
  • The platform cannot be asked (unreachable, refuses the service account, answers nonsense, or the module is disabled): 503 UNAVAILABLE. It fails closed.
  • An active answer is remembered per login family (sid) for the given time (zero: always ask) and never past the token’s own expiry. An inactive answer is not remembered.
  • A request that is not a field worker’s is answered 403 FORBIDDEN. A present sub that differs from the request’s worker counts as inactive.

The platform emits platform:iam:field-worker:suspended, platform:iam:field-device:revoked and platform:iam:field-session:revoked. They are for application state (cached work assignments, open gate sessions), not for token validity: tokens expire on their own within ten minutes. Declare the subscription so the definition sync registers it. The handler may run more than once for one event, so make it idempotent. Data that lacks what its type needs is rejected, not retried; an error returned from the handler is a transient failure and the platform delivers again. See receivers.

Receivers receivers = app.get(Receivers.class);
receivers.onFieldRevocation((ctx, event) -> {
switch (event) {
case FieldRevocation.WorkerSuspended w -> assignments.dropFor(w.workerId());
case FieldRevocation.DeviceRevoked d -> gates.closeFor(d.deviceId());
case FieldRevocation.SessionRevoked s -> gates.closeSession(s.sessionId());
}
});

Subscribe with FieldRevocation.subscription(code, "/fc/dispatch"). To end a revoked worker’s push streams from the same handler: pushes.endStreams(PushHolders.of(event)).

SessionRevoked carries the login family (sessionId) only when one family was revoked (a refresh token presented again). When an administrator revokes every session of a worker or a device, you get the worker or device id and no session id.

TestOidcProvider provider = TestOidcProvider.start(clock);
TestFieldDevice device = TestFieldDevice.create(clock);
String token = provider.fieldToken("orders", device.jkt(), Map.of()); // any claim can be overridden
String proof = device.proof("GET", "https://app.example/api/me", nonce, token);
client.get("/api/me").header("Authorization", "DPoP " + token).header("DPoP", proof).send();

TestFieldDevice.proof(...) is valid unless you pass a Flaw (OTHER_DEVICE_KEY, BAD_SIGNATURE, WRONG_METHOD, WRONG_URL, WRONG_ATH, STALE, NO_JTI, NO_NONCE, WRONG_TYP, WRONG_ALG, PRIVATE_MEMBER). To get a nonce as a device does, send without one and read DPoP-Nonce from the 401 (TestFieldDevice.nonceFrom). AuthTesting.of(app).fieldRequest(worker, device, provider::signField, "POST", "/api/things") returns the Authorization and DPoP headers. Like all of AuthTesting it is refused unless APP_ENV is test.

The platform’s own conformance vectors (conformance/field/) run in both implementations.

  • No field login, PIN, enrolment or refresh happens here: those are the platform and the field libraries.
  • Field pages are pages the field library calls with fetch. No field cookie exists, and server-rendered field pages are not a thing.
  • Not checked: a request from a real field client library, and a real platform delivering the revocation events.