function authorizationMiddleware(request, response, api, log, callback) {
    if (!api) {
        return responseXMLBody(errors.AccessDenied, null, response, log);
    }
    const requestContexts = prepareRequestContexts(api, request);
    return async.waterfall([
        next => auth.server.doAuth(request, log, (err, userInfo, authorizationResults, streamingV4Params) => {
            if (err) {
                log.debug('authentication error', {
                    error: err,
                    method: request.method,
                    bucketName: request.bucketName,
                    objectKey: request.objectKey,
                });
            }
            /* eslint-disable no-param-reassign */
            request.authorizationResults = authorizationResults;
            request.streamingV4Params = streamingV4Params;
            /* eslint-enable no-param-reassign */
            return next(err, userInfo);
        }, 's3', requestContexts),
        (userInfo, next) => {
            // Ensure only supported HTTP verbs and actions are called,
            // otherwise deny access
            const requestType = apiToAction[api];
            if (!requestType) {
                return next(errors.AccessDenied);
            }
            const mdValParams = {
                bucketName: request.bucketName,
                authInfo: userInfo,
                requestType,
                request,
            };
            return next(null, mdValParams);
        },
        (mdValParams, next) => standardMetadataValidateBucket(mdValParams, request.actionImplicitDenies, log, next),
    ], (err, bucketMd) => {
        if (err || !bucketMd) {
            return responseXMLBody(err, null, response, log);
        }
        return callback(request, response, bucketMd, log);
    });
}
Query the authorization service for the request, and extract the bucket
and, if applicable, object metadata according to the request method.

@param {object} request - incoming request
@param {object} response - response object
@param {string} api - HTTP verb
@param {object} log - logger instance
@param {function} callback -
@returns {undefined}