Interface ClientRegistrationPolicy


public interface ClientRegistrationPolicy

What decides who may register a client of their own at the registration endpoint (RFC 7591), and with what. Registration is off until one is given to clientRegistration(...) on the authorization server configurer.

The server parses and checks the request first, and only a request that passes reaches validate(HttpServer.Request, Map, RegisteredClient). What every self-registered client is, whatever the policy says:

  • public: token_endpoint_auth_method is none and it has no secret, since anybody can register one and a secret proves nothing about them;
  • PKCE (S256) is required, and so is the user's consent on every authorization, so that a client nobody vetted is never granted anything silently;
  • grant types authorization_code, optionally with refresh_token, and response type code;
  • one to five redirect addresses, each an https address, or an http one on 127.0.0.1 or [::1] -- any port is then accepted, as RFC 8252 asks for an application on the user's computer; no fragment, no user information;
  • scopes out of allowedScopes(), all of them when the request names none;
  • no resource servers and no audience of its own choosing.

A client that validate(HttpServer.Request, Map, RegisteredClient) returns which breaks one of these is not saved, and the request is answered 500: that is a mistake in the policy, not in the request.

  • Method Details

    • allowedScopes

      Set<String> allowedScopes()
      The scopes a self-registered client may be given. Required and not empty: there is no safe default for what a stranger's client may ask a user for.
    • validate

      RegisteredClient validate(HttpServer.Request request, Map<String,Object> metadata, RegisteredClient client)
      The validate-and-limit hook: refuse the registration by throwing a ClientRegistrationException, or return the client to save -- the one given, or one built from it with less (fewer redirects, fewer scopes, shorter token lifetimes). It is also the place to count registrations per address and refuse past a limit -- and the only such place: the endpoint takes anonymous requests, and every registration it accepts is a saved client, so a policy that accepts everything lets anyone fill the client table.
      Parameters:
      request - the HTTP request
      metadata - the client metadata the request sent, as parsed JSON
      client - the client the server would save
      Returns:
      the client to save