Open Charging Technology · Whitepapers

Open Charging Technology TOTP — HTTP Authentication

Version 1.0 — Draft, 2026-11-20 CC-BY-SA 4.0 · OpenChargingTechnology/Whitepapers · conformance suite: OpenChargingCloud/TOTPConformanceTests

This document specifies how the tokens of the Open Charging Technology TOTP Token Format are carried in HTTP for machine-to-machine authentication — as a drop-in replacement for HTTP Basic Authentication and for long-lived static bearer tokens (e.g. OCPI-style Authorization: Token …). Three bindings are defined:

The native bindings are implemented by Vanaheimr Hermod, the Authorization: TOTP scheme also by TOTP.ts; Appendix A records the implementation status. Unlike the token format itself — frozen by deployed verifiers and finalized — this binding document is a draft: of the server-side verification it specifies, the Authorization: TOTP scheme and the TOTP request header have landed (in Hermod's WebSocket server, the scheme held to the verification vectors of section 11) — with raw tokens over every version of HTTP, with bound tokens where the WebSocket is opened over HTTP/3 — and its wire details may still change.

1. Introduction

HTTP Basic Authentication ships a static password with every request: one captured request, one log line, one misconfigured proxy, and the credential is compromised until somebody rotates it. Replacing the password with a TOTP bounds that damage to the token's validity time (30 seconds by default), and adding TLS channel binding (section 6.2) removes even that window: a bound token is useless outside the TLS session it was derived for.

The tokens themselves — derivation, parameters, validation rules, the previous/current/next acceptance window — are defined in the token format specification and are not redefined here. This document only defines how they travel in HTTP requests and how HTTP servers verify them.

Typical deployments: OCPP charging station WebSocket connections (the HTTP Upgrade handshake, section 7, today mostly protected by Basic Auth), OCPI peer connections, and internal service-to-service APIs.

2. Conventions

The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" are to be interpreted as described in RFC 2119 and RFC 8174 when, and only when, they appear in all capitals.

Token format spec refers to totp-token-format.md. The login is the name under which the verifier looks up a peer's TOTP configuration (shared secret, validity time, length, alphabet, hash algorithm, and whether its tokens are bound to the TLS session — the TOTPConfig of token format spec Appendix B). It is deliberately not called a "user": a login names a role — a charging station, a backend service, a tenant — and nothing about it implies a natural person. Base64 is the Base64 encoding of RFC 4648 section 4, with padding.

3. Prerequisites

Client and verifier share a TOTP configuration per login, provisioned out of band. The verifier maintains a mapping login → TOTP configuration; the client knows its own login and configuration. Both sides agree in it on whether the login's tokens are raw or bound to the TLS session (section 6.2): the native Authorization: TOTP scheme carries no signal for it, so a client cannot talk a binding down, and a verifier never has to guess. How the mapping is provisioned and rotated is out of scope (token format spec section 8 states the requirements on the secret itself).

4. TOTP over HTTP Basic Authentication

The simplest deployment needs no new wire format at all: the client puts the current token into Basic's password field, exactly as defined by RFC 7617:

credentials  = "Basic" SP base64( login ":" totp )

Example — login chargingstation-0001, token CN63y502maVh (the defaults-mid-slot vector of the canonical test vectors):

GET /ocpp HTTP/1.1
Host: csms.example.com
Authorization: Basic Y2hhcmdpbmdzdGF0aW9uLTAwMDE6Q042M3k1MDJtYVZo

The verifier decodes the credentials per RFC 7617 and verifies the password as a presented token — the procedure of section 5.3, steps 2–3, unchanged.

What this buys. The "password" now rotates itself every validity interval: an observed or logged credential dies within the acceptance window instead of living until somebody remembers to rotate it. On the client this is often a zero-code change — every HTTP stack, proxy, load balancer and CLI on earth already speaks Basic, and many devices can be pointed at a rotating password without touching their firmware. Only the server's password comparison changes.

What it cannot do — Basic is traditional, and it shows:

Deployments that control both ends SHOULD therefore use the native scheme of section 5; the Basic binding is the zero-friction migration path, and a verifier MAY accept both during a transition.

5. The Authorization: TOTP scheme

5.1. Syntax

The credentials are a list of auth-params (RFC 9110 section 11.3), exactly as that specification recommends for new schemes:

credentials  = "TOTP" 1*SP #auth-param

; defined parameters:
;   login = <Base64 of the UTF-8 encoded login>          (MANDATORY)
;   totp  = <Base64 of the UTF-8 encoded TOTP>           (MANDATORY)

Example — login chargingstation-0001, raw token CN63y502maVh (the defaults-mid-slot vector of the canonical test vectors):

GET /ocpp HTTP/1.1
Host: csms.example.com
Authorization: TOTP login="Y2hhcmdpbmdzdGF0aW9uLTAwMDE=", totp="Q042M3k1MDJtYVZo"

The same login, configured for channel binding, with a TLS-channel-bound token (gAzxPfYtmRgd, the tls-binding-sha256 vector) — the header has the very same form:

Authorization: TOTP login="Y2hhcmdpbmdzdGF0aW9uLTAwMDE=", totp="Z0F6eFBmWXRtUmdk"

Unlike Basic Authentication — which Base64-encodes login:password as one string and therefore cannot represent a ":" inside the login (RFC 7617 section 2) — login and token are encoded separately here, so both may contain any Unicode character, including ":".

5.2. Client behaviour

For every request the client computes the current token for its configuration (token format spec section 4) — bound to the TLS session of the connection the request travels on where the configuration asks for channel binding (section 6.2) — and sends it as above. A client that cannot derive exporter material for that connection sends no token for a login configured for binding, rather than a raw one. A token MAY be reused for consecutive requests within its remaining validity time; clients MUST NOT send a cached token beyond that.

5.3. Server verification

On receiving the header, the verifier:

  1. Parses the auth-params: unknown parameters are ignored; duplicate parameters, a missing login or totp and invalid Base64 are rejected as malformed (section 8). login and totp are Base64-decoded and UTF-8-decoded.
  2. Looks up the TOTP configuration for the login. An unknown login is rejected exactly like a wrong token (section 8).
  3. Computes previous, current and next for its own clock and the login's configuration — where the configuration asks for channel binding, with the exporter material of the receiving TLS session, under the rules of section 6.2; otherwise raw — and accepts iff the presented token equals one of the three: the acceptance window of token format spec section 7, including its guidance: constant-time comparison, no widening of the window, single-use enforcement and rate limiting where replay matters.

A login whose configuration asks for channel binding takes bound tokens only: a verifier MUST NOT accept a raw token for it — not in this scheme, not as the password of the Basic binding (section 4), not as type 0 of the TOTP request header (section 6). Where the receiving connection exports no keying material, such a login is therefore not let in at all.

Requests without an Authorization header, and requests that fail verification, are answered with 401 Unauthorized; the response SHOULD carry a challenge:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: TOTP realm="ocpp"

The realm parameter is OPTIONAL and follows RFC 9110 section 11.

6. The TOTP request header

6.1. Syntax

For deployments where the peer's login is already established — a mutual TLS connection, a per-client URL path, an already-authenticated session — the token travels in a dedicated request header, prefixed with a one-digit type. This binding descends from the proprietary Token-style authentication that GitHub's REST API originally defined (Authorization: token <token>) and that e-mobility protocols such as OCPI later adopted (Authorization: Token <static-token>): the same lightweight shape, except that the token now exchanges itself every validity interval instead of being a static, long-lived secret.

TOTP-header  = "TOTP:" OWS totp-type SP totp-value OWS
totp-type    = "0" / "1"
totp-value   = 1*VCHAR   ; a token of the token format spec
Type Meaning
0 A raw token (token format spec section 4).
1 A token bound to this TLS session (token format spec section 6).

Examples — the defaults-mid-slot and tls-binding-sha256 vectors:

TOTP: 0 CN63y502maVh
TOTP: 1 gAzxPfYtmRgd

Verifiers MUST reject unknown type digits.

6.2. TLS v1.3 channel binding

A bound token is derived with TLS exporter material per token format spec section 6 (label EXPORTER-Time-Based-One-Time-Password-v1, empty context, 32 bytes RECOMMENDED). The verifier derives the same material from its own side of the TLS connection the request arrived on, and verifies against tokens computed with it. A captured bound token is useless on any other connection, which makes replay impractical even if the token leaks into a log.

Channel binding MUST only be used on TLS v1.3 (or newer) connections — earlier TLS versions have no exporter interface with these properties. A verifier that cannot derive exporter material for the receiving connection MUST reject a bound token; it MUST NOT fall back to verifying it as raw.

These rules apply to channel binding in either native binding: the TOTP request header signals it with type digit 1; in the Authorization: TOTP scheme the login's configuration says it (section 5.1), and a bound token arriving on a connection without exporter material is rejected there as well. A login configured for binding takes no type 0 token in the TOTP request header (section 5.3); a login configured for raw tokens MAY take a type 1 token where the verifier can derive the material — that is more than it asked for.

6.3. Verification

As in section 5.3, steps 2–3, with the login taken from the connection context instead of the header, and — for type 1 — the exporter material of the receiving TLS session applied to the token derivation on the verifier's side as well.

6.4. Caching

Generic HTTP caches do not know that the TOTP header carries a credential: the request looks unauthenticated to them, so a shared cache could store a response to an authenticated request and serve it to an unauthenticated client. Servers authenticating via the TOTP request header MUST therefore mark such responses Cache-Control: private (or no-store). Vary: TOTP is NOT a substitute — with tokens changing every validity interval it merely fragments the cache without expressing that the header is a credential. (The Authorization-based bindings of sections 4 and 5 do not need this rule: RFC 9111 section 3.5 already restricts caching of responses to requests with an Authorization header field.)

7. WebSocket handshakes

All three bindings apply unchanged to the HTTP Upgrade request of a WebSocket handshake (RFC 6455) — the primary use in OCPP, where a charging station's WebSocket connection is today typically protected by HTTP Basic Auth. They apply in the same way to the extended CONNECT request that opens a WebSocket over HTTP/2 (RFC 8441) or HTTP/3 (RFC 9220): the credentials travel as header fields of that request, and it is that request the server verifies before it answers 200. A bound token (section 6.2) is bound to the TLS session of the connection the request travels on — over HTTP/3, the TLS session of the QUIC connection — so every WebSocket opened on one connection shows a token bound to the same session. Verification happens once, during the handshake; an accepted connection stays authenticated for its lifetime. Deployments needing periodic re-authentication of long-lived connections re-establish the connection or use an application-level mechanism; in OCPP the TOTP then also plays its other role, in dynamic QR codes (token format spec section 1.2).

8. Error handling

9. Protocol considerations (RFC 9110 §16.4.2)

RFC 9110 section 16.4.2 lists considerations for new authentication schemes. This scheme is private-use (see the third point), but answers them anyway:

10. Security considerations

11. Test vectors (normative for the native scheme)

The Authorization: TOTP scheme is covered by canonical vectors in the normative annex: test-vectors/totp-http-auth-vectors.json, gated as a whole file by the capability httpAuthentication:

Harnesses of implementations without the capability skip the file declaratively (a visible skip, never silence). The token values inside come from the canonical token vectors (defaults-mid-slot, tls-binding-sha256, …).

Server-side verification (section 5.3, with sections 6.2 and 8) has vectors of its own: test-vectors/totp-http-verification-vectors.json, gated by the capability httpVerification. The file names one verifier — a login → configuration mapping and a clock — and each vector one Authorization header (or none) together with the verifier's answer: accepted (naming the authenticated login), rejected (401) or malformed (400, or 401). They cover the acceptance window (previous, current and next — never two slots), per-login configurations, unknown logins, exact token comparison (no prefix, no case folding, no trimming), a login configured for channel binding on a verifier without exporter material (no token of it is let in, a withdrawn tlscb=false changing nothing), and duplicate parameters, of which neither value may win. The verifier holds no TLS exporter material; no presented token is bound, so a verifier that does reaches the very same outcomes. Its clock lies at least 10 seconds before the end of its slot for every login, so a harness may drive a live server's clock to it.

The Basic binding (section 4) gets no vectors of its own: its encoding is RFC 7617's, not ours, and the tokens are the token format's — and no implementation verifies it yet. The TOTP request header's value is a bare token (its wire format is trivial); its channel binding semantics are exercised through the scheme vectors.

12. References

Appendix A — Implementation status (informative)

Piece Hermod TOTP.ts
Token derivation yes yes
TOTP over Basic Authentication (section 4) — existing RFC 7617 machinery; only the server-side password check changes wire: yes. Verification: yes, in the WebSocket server (BasicCredentialsAreKnown): the password of a Basic login is its static password, or the previous, the current or the next one-time password of its TOTP configuration - a raw one, so a login whose configuration asks for the binding (TLSChannelBinding) is not let in this way. A login may have both during a transition. Not verified by the plain HTTP server wire: needs no helper (generateTOTPs() as the password), verification: no
Authorization: TOTP — build & parse as auth-params: login, totp; unknown parameters, the withdrawn tlscb among them, ignored (Hermod: HTTPTOTPAuthentication; TOTP.ts: formatTOTPAuthorization / parseTOTPAuthorization; vector-driven tests on both sides) yes; sent by the WebSocket client under its TOTPLogin, with a token of the moment for every attempt, a reconnect included — raw over every version of HTTP, bound, where its TOTPConfig asks for it (TLSChannelBinding), by a client told to open its WebSocket over HTTP/3 and nothing else yes
TOTP request header — build & parse (TOTPHTTPHeader), auto-attached by the HTTP client from its TOTPConfig wire: yes — raw, and bound (type 1) by a WebSocket client without a login that opens its WebSocket over HTTP/3. Verification (section 6.3): yes, in the WebSocket server, where the server says who a connection is known as (TOTPLoginOfAConnection, unset by default — unset, the header lets nobody in) and the request carries no Authorization: raw over every version of HTTP, bound over HTTP/3, as for the scheme. The Cache-Control of section 6.4 is not set: the answers to a WebSocket handshake are not cacheable. Not verified by the plain HTTP server no
TLS exporter material (channel binding derivation) derivation: yes; on a connection: over HTTP/3 only. SslStream, the TLS of the clients and servers over HTTP/1.1 and HTTP/2, exposes no exporter; Hermod's own QUIC, their TLS over HTTP/3, does, and both sides of a WebSocket opened over HTTP/3 take it from there. A client whose TOTPConfig asks for binding and that is not told HTTP/3 and nothing else — one left the choice of the version included, since it may come to an SslStream — sends nothing and says why, rather than a token weaker than configured yes (tlsExporterMaterialOf, TLS v1.3 only)
Server-side verification of Authorization: TOTP (section 5.3) against the login → config mapping — the verification vectors (httpVerification) yes, in the WebSocket server (AWebSocketEndpoint.AuthenticateAsync against ClientTOTPConfig, TOTPIsTheOneOf), for a WebSocket opened by an Upgrade over HTTP/1.1 and by an extended CONNECT over HTTP/2 (RFC 8441) or HTTP/3 (RFC 9220) alike. The login's TOTPConfig says raw or bound (TLSChannelBinding): raw tokens over all three; bound tokens over HTTP/3, verified with the exporter material of the QUIC connection the request arrived on. Over HTTP/1.1 and HTTP/2 a login configured for binding is not let in, as section 6.2 requires of a verifier without exporter material. A login whose configuration asks for binding takes no raw token, in no binding; in the TOTP request header, one that does not takes a bound token (type 1) all the same where it can verify it no — a client library (a worked example in its README)
The challenge WWW-Authenticate: TOTP (section 5.3, SHOULD) yes, in the WebSocket server: its 401 names TOTP where it has one-time passwords and Basic where it has passwords or takes a raw one-time password as one (section 4) — both in one field value where it has both (RFC 9110 section 11.6.1), realm included. A client of the reference implementation does not act on the challenge: it sends its credentials preemptively —
Single-use enforcement (section 5.3, OPTIONAL) no, on purpose: a request lost on its way would leave its sender waiting for the next slot (section 10) —
Rate limiting of failed attempts (section 5.3) no: left to the operator of the server, with whatever else limits its requests —

What the reference implementation lacks is a state of that implementation, and no condition this document waits for:

The Hermod column is as of Hermod 2c8a5d72 (2026-11-19), which took the binding out of the Authorization: TOTP header and into the login's configuration. That a WebSocket opened over HTTP/2 or HTTP/3 is authenticated as one opened over HTTP/1.1, and that a bound token is sent and verified over HTTP/3, is held by tests of the stack built on it as well (WWCP_Core bb22ff9a, WWCP_OCPP 9afd4153, ChargingStation 8a41c97): a station is let in with its login and token, and refused with another secret, another login or an unknown one, over each of the three; over HTTP/3 it is let in with a token bound to its connection, by a CSMS that asks for the binding and by one that does not; and a CSMS that asks for the binding takes no raw token over any of them. For the TOTP request header, the login a connection is known as is there the networking node its path names (WWCP_Core b7a1bb61), and its 401 carries the challenge as well (WWCP_Core 5574d041). A networking node is let in with a one-time password as its Basic password too, and is who its path and its login say (WWCP_Core 036e2696).