public function process(HTTPRequest $request, callable $next)
    {
        // don't authenticate if being run from command line
        if (Director::is_cli()) {
            return $next($request);
        }

        try {
            $request = $this->authenticator->authenticate($request);

            // set the current user
            if ($userID = $request->getHeader('oauth_user_id')) {
                Security::setCurrentUser(Member::get()->byID($userID));
            }
        } catch (AuthenticationException $exception) {
            // for middleware do nothing
        } catch (DatabaseException $exception) {
            // db not ready, ignore
        }

        // Pass the request on to the next responder in the chain
        return $next($request);
    }