 that authentication fails."
   ([h authenticator failure-handler]
      (fn [req]
-       (let [auth (allowed-request? authenticator req)]
+       (let [auth (authenticate-request authenticator req)]
          (cond auth (h (merge req auth))
                failure-handler (failed-authentication failure-handler req)
                ;; Continue without merging auth


(defrecord HttpBasicRequestAuthenticator [user-authenticator user-roles]
  HttpRequestAuthenticator
  (allowed-request? [_ request]
    (when-let [auth (get-in request [:headers "authorization"])]
      (when-let [basic-creds (second (re-matches #"\QBasic\E\s+(.*)" auth))]
        (let [[username password] (->> (String. (DatatypeConverter/parseBase64Binary basic-creds) "UTF-8")


(defprotocol HttpRequestAuthenticator
  ;; Return a map, potentially containing entries to be merged with the request.
  (authenticate-request [_ request]))

(extend-protocol HttpRequestAuthenticator
  Boolean
  (authenticate-request [this request]
    (when this {})))

(defprotocol UserAuthenticator
