How to use the boom.forbidden function in boom

To help you get started, we’ve selected a few boom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JKHeadley / appy-backend / server / policies / connectionAuth.js View on Github external
.then(function (result) {
          // EXPL: Only the primary user and those with root permissions can update the connection
          if (userId === result.primaryUser.toString() || request.auth.credentials.scope.includes('root')) {
            return next(null, true);
          }
          else {
            return next(Boom.forbidden("Not primary user."), false);
          }
        })
    }
github epochtalk / epochtalk / modules / ept-threads / authorization / createPoll.js View on Github external
error: Boom.forbidden('No Write Access'),
    type: 'dbValue',
    method: server.db.threads.getBoardWriteAccess,
    args: [threadId, server.plugins.acls.getUserPriority(auth)]
  });

  // is requester active
  var active = server.authorization.build({
    error: Boom.forbidden('Account Not Active'),
    type: 'isActive',
    server: server,
    userId: userId
  });

  // Check that user isn't banned from this board
  var notBannedFromBoard = server.authorization.common.isNotBannedFromBoard(Boom.forbidden('You are banned from this board'), server, userId, { threadId: threadId });

  // can create poll / ownership
  var ownerCond = [
    {
      // Permission based override
      error: Boom.badRequest('not admin'),
      type: 'hasPermission',
      server: server,
      auth: auth,
      permission: 'threads.createPoll.bypass.owner.admin'
    },
    {
      // is board moderator
      error: Boom.badRequest('not mod'),
      type: 'isMod',
      method: server.db.moderators.isModeratorWithThreadId,
github epochtalk / epochtalk / modules / ept-posts / authorization / update.js View on Github external
type: 'dbValue',
    method: server.db.posts.getPostsBoardInBoardMapping,
    args: [postId, server.plugins.acls.getUserPriority(auth)]
  });

  // write board
  var write = server.authorization.build({
    error: Boom.forbidden('No Write Access'),
    type: 'dbValue',
    method: server.db.posts.getBoardWriteAccess,
    args: [postId, server.plugins.acls.getUserPriority(auth)]
  });

  // -- is User Account Active
  var active = server.authorization.build({
    error: Boom.forbidden('Account Not Active'),
    type: 'isActive',
    server: server,
    userId: userId
  });

  // final promise
  return Promise.all([allowed, owner, deleted, read, write, tLocked, pLocked, active]);
};
github epochtalk / epochtalk / server / authorization / index.js View on Github external
promise = Promise.join(refPriority, authedPriority, samePriority, lowerPriority, function(referenced, current, same, lower) {
        var result = Boom.forbidden('You don\'t have permission to remove the roles from ' + refUsername);
        // lower and same are both false, forbidden
        if (!same && !lower) { return result; }
        // current has same or higher priority than referenced
        else if (same && current <= referenced) { result = true; }
        // current has higher priority than referenced
        else if (lower && current < referenced) { result = true; }

        return result;
      });
    }
github thm1118 / kibana-auth--xpack-plugin / server / lib / check_index_privilege.js View on Github external
server.plugins.security.getUser(request).then(function (user) {
                    // todo:  server.log not work here ,why?
                    server.log(["warn", "onPreHandler事件: user.index"], user);
                    if(user.index != '*' && index_name != user.index) {
                        // server.log(["warn", "onPreHandler事件"], "==============索引不匹配==========");
                        return reply(Boom.forbidden("无权访问"));
                    }else{
                        return reply.continue();
                    }
                }, _.flow(wrapError, reply));
github elastic / kibana / x-pack / legacy / plugins / spaces / server / lib / spaces_client / spaces_client.ts View on Github external
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);
    }
  }
github screwdriver-cd / screwdriver / plugins / pipelines / tokens / refresh.js View on Github external
return user.getPermissions(pipeline.scmUri).then((permissions) => {
                        if (!permissions.admin) {
                            throw boom.forbidden(`User ${username} `
                                + 'is not an admin of this repo');
                        }

                        if (token.pipelineId !== pipeline.id) {
                            throw boom.forbidden('Pipeline does not own token');
                        }

                        return token.refresh()
                            .then((refreshed) => {
                                reply(refreshed.toJson()).code(200);
                            });
                    });
                })
github epochtalk / epochtalk / modules / ept-users / authorization / update.js View on Github external
function isAllowed(server, auth) {
  return server.authorization.build({
    error: Boom.forbidden(),
    type: 'hasPermission',
    server: server,
    auth: auth,
    permission: 'users.update.allow'
  });
}
github synapsestudios / oidc-platform / api / src / plugins / access-token-scheme.js View on Github external
const onInvalidAccessToken = (request, reply) => {
      const clientId = get(request, 'query.client_id') || get(request, 'payload.client_id');
      const redirectUri = get(request, 'query.redirect_uri') || get(request, 'payload.redirect_uri');
      if (clientId && redirectUri) {
        provider.Client.find(clientId).then(client => {
          if (!client) {
            return reply(Boom.notFound('Client not found'));
          }
          if (client.redirectUris.indexOf(request.query.redirect_uri) < 0) {
            return reply(Boom.forbidden('redirect_uri not in whitelist'));
          } else {
            return reply.redirect(`${redirectUri}?error=unauthorized&error_description=invalid access token`);
          }
        });
      } else {
        return reply(Boom.forbidden('invalid access token'));
      }
    };