Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class ApiKeyAuthenticationFilter

  1. Object
  2. ApiKeyAuthenticationFilter

ImplementsSecurityFilter

Authenticates a request from the API key it presents, in X-API-Key or as Authorization: Bearer <key>.

A bearer value is taken for an API key only when it starts with the configured prefix; any other is left for whatever verifies tokens. So one chain can accept both, and the prefix is what tells them apart. A value in X-API-Key is always a key, and one without the prefix is refused.

The key is checked on every request and nothing is kept. A request without one passes through untouched; one whose key is unknown or revoked is answered 401 at once, and is not told which.

Methods

public HttpServer.Response doFilter(HttpServer.Request request, FilterChain chain) throws ExceptionThe answer to request; null when nothing under the chain routes it, which the server answers 404.

Inherited methods

Method details

doFilter

public HttpServer.Response doFilter(HttpServer.Request request, FilterChain chain) throws Exception
The answer to request; null when nothing under the chain routes it, which the server answers 404.

Throws

Exception