当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Boom.forbidden函数代码示例

本文整理汇总了TypeScript中Boom.forbidden函数的典型用法代码示例。如果您正苦于以下问题:TypeScript forbidden函数的具体用法?TypeScript forbidden怎么用?TypeScript forbidden使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了forbidden函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: requestIsValid

  public requestIsValid(request: any): boolean {
    const license = this.adapter.getLicenseType();
    if (license === null) {
      throw Boom.badRequest('Missing license information');
    }
    if (!supportedLicenses.some(licenseType => licenseType === license)) {
      throw Boom.forbidden('License not supported');
    }
    if (this.adapter.licenseIsActive() === false) {
      throw Boom.forbidden('License not active');
    }

    return this.checkRequest(request);
  }
开发者ID:liuyepiaoxiang,项目名称:kibana,代码行数:14,代码来源:auth.ts

示例2: registerClusterCheckupRoutes

export function registerClusterCheckupRoutes(server: Legacy.Server) {
  const { callWithRequest } = server.plugins.elasticsearch.getCluster('admin');
  const isCloudEnabled = _.get(server.plugins, 'cloud.config.isCloudEnabled', false);

  server.route({
    path: '/api/upgrade_assistant/status',
    method: 'GET',
    options: {
      pre: [EsVersionPrecheck],
    },
    async handler(request) {
      try {
        return await getUpgradeAssistantStatus(callWithRequest, request, isCloudEnabled);
      } catch (e) {
        if (e.status === 403) {
          return Boom.forbidden(e.message);
        }

        return Boom.boomify(e, {
          statusCode: 500,
        });
      }
    },
  });
}
开发者ID:njd5475,项目名称:kibana,代码行数:25,代码来源:cluster_checkup.ts

示例3: function

        handler: async function (req, res, next) {
            const payload: Requests.UpdatePassword = req.validatedBody;
            let user = await UserDb.get(req.user._id);

            // Ensure the user's current password is correct
            if (!compareSync(payload.old_password, user.hashed_password)) {
                return next(boom.forbidden(`Your current password is incorrect.`));
            }

            // Change the user's password
            user.hashed_password = hashSync(payload.new_password);

            try {
                const updateResult = await UserDb.put(user._id, user, user._rev);
                user._rev = updateResult.rev
            } catch (e) {
                inspect("Failed to update user's password.", e);

                return next(e);
            }

            await res.withSessionToken(user);

            return next();
        }
开发者ID:nozzlegear,项目名称:Gearworks,代码行数:25,代码来源:users.ts

示例4: checkRequest

 private checkRequest(request: any): boolean {
   const authenticated = get(request, 'auth.isAuthenticated', null);
   if (authenticated === null) {
     throw Boom.forbidden('Missing authentication');
   }
   return authenticated;
 }
开发者ID:liuyepiaoxiang,项目名称:kibana,代码行数:7,代码来源:auth.ts

示例5: forbidApiAccess

 return function forbidApiAccess(request: any) {
   const licenseCheckResults = xpackMainPlugin.info.feature(pluginId).getLicenseCheckResults();
   if (!licenseCheckResults.showSpaces) {
     return Boom.forbidden(licenseCheckResults.linksMessage);
   } else {
     return '';
   }
 };
开发者ID:gingerwizard,项目名称:kibana,代码行数:8,代码来源:route_pre_check_license.ts

示例6: wrapEsError

export function wrapEsError(err: any) {
  const statusCode = err.statusCode;
  if (statusCode === 403) {
    return Boom.forbidden('Insufficient user permissions for managing Beats configuration');
  }

  return Boom.boomify(err, { statusCode: err.statusCode });
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:8,代码来源:wrap_es_error.ts

示例7: async

export const readOnlyMiddleware = async (resolve, root, args, context: Context, info) => {
  const operationType = get(info, 'operation.operation');
  if (!context.readOnly || (context.readOnly && operationType === 'query')) {
    return resolve(root, args, context, info);
  }

  // readOnly true, but operation is one of mutation or subscription
  throw Boom.forbidden('Only query allowed in readonly request', {code: ErrorCodes.MUTATION_IN_READONLY});
};
开发者ID:Canner,项目名称:canner,代码行数:9,代码来源:graphql.ts

示例8: async

  return async ({ ctx }: { ctx: Context }) => {
    const authorization = ctx.get('authorization');
    if (!authorization) {
      throw Boom.forbidden('authorization header required', {code: ErrorCodes.AUTH_HEADER_MISSING});
    }

    const accessToken = authorization.replace('Bearer ', '');
    if (!accessToken) {
      throw Boom.forbidden('access token required', {code: ErrorCodes.ACCESSTOKEN_MISSING});
    }

    // check with authHandler
    const authContext = await authHandler(accessToken);

    return {
      ...authContext
    };
  };
开发者ID:Canner,项目名称:canner,代码行数:18,代码来源:context.ts

示例9: ensureAuthorizedGlobally

  private async ensureAuthorizedGlobally(action: string, method: string, forbiddenMessage: string) {
    const checkPrivileges = this.authorization.checkPrivilegesWithRequest(this.request);
    const { username, hasAllRequested } = await checkPrivileges.globally(action);

    if (hasAllRequested) {
      this.auditLogger.spacesAuthorizationSuccess(username, method);
      return;
    } else {
      this.auditLogger.spacesAuthorizationFailure(username, method);
      throw Boom.forbidden(forbiddenMessage);
    }
  }
开发者ID:,项目名称:,代码行数:12,代码来源:

示例10: handleError

 function handleError(exportType: any, err: Error) {
   if (err instanceof esErrors['401']) {
     return boom.unauthorized(`Sorry, you aren't authenticated`);
   }
   if (err instanceof esErrors['403']) {
     return boom.forbidden(`Sorry, you are not authorized to create ${exportType} reports`);
   }
   if (err instanceof esErrors['404']) {
     return boom.boomify(err, { statusCode: 404 });
   }
   return err;
 }
开发者ID:elastic,项目名称:kibana,代码行数:12,代码来源:index.ts


注:本文中的Boom.forbidden函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。