How to use the loopback4-authentication.STRATEGY.BEARER function in loopback4-authentication

To help you get started, we’ve selected a few loopback4-authentication 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 sourcefuse / loopback4-starter / src / modules / audit / audit-log.controller.ts View on Github external
@authenticate(STRATEGY.BEARER)
  @authorize([PermissionKey.CreateAudit])
  @post('/audit-logs', {
    responses: {
      '200': {
        description: 'AuditLog model instance',
        content: {'application/json': {schema: {'x-ts-type': AuditLog}}},
      },
    },
  })
  async create(@requestBody() auditLog: AuditLog): Promise {
    return await this.auditLogRepository.create(auditLog);
  }

  @authenticate(STRATEGY.BEARER)
  @authorize([PermissionKey.ViewAudit])
  @get('/audit-logs/count', {
    responses: {
      '200': {
        description: 'AuditLog model count',
        content: {'application/json': {schema: CountSchema}},
      },
    },
  })
  async count(
    @param.query.object('where', getWhereSchemaFor(AuditLog))
    where?: Where,
  ): Promise {
    return await this.auditLogRepository.count(where);
  }
github sourcefuse / loopback4-starter / src / modules / user-tenants / tenant.controller.ts View on Github external
@authenticate(STRATEGY.BEARER)
  @authorize([PermissionKey.ViewTenant])
  @get('/tenants/{id}', {
    responses: {
      '200': {
        description: 'Tenant model instance',
        content: {'application/json': {schema: {'x-ts-type': Tenant}}},
      },
    },
  })
  async findById(@param.path.number('id') id: number): Promise {
    return await this.tenantRepository.findById(id);
  }

  @authenticate(STRATEGY.BEARER)
  @authorize([PermissionKey.UpdateTenant])
  @patch('/tenants/{id}', {
    responses: {
      '204': {
        description: 'Tenant PATCH success',
      },
    },
  })
  async updateById(
    @param.path.number('id') id: number,
    @requestBody() tenant: Tenant,
  ): Promise {
    await this.tenantRepository.updateById(id, tenant);
  }

  @authenticate(STRATEGY.BEARER)
github sourcefuse / loopback4-starter / src / modules / roles / role.controller.ts View on Github external
@authorize([PermissionKey.UpdateRole])
  @patch('/roles/{id}', {
    responses: {
      '204': {
        description: 'Role PATCH success',
      },
    },
  })
  async updateById(
    @param.path.number('id') id: number,
    @requestBody() role: Role,
  ): Promise {
    await this.roleRepository.updateById(id, role);
  }

  @authenticate(STRATEGY.BEARER)
  @authorize([PermissionKey.UpdateRole])
  @put('/roles/{id}', {
    responses: {
      '204': {
        description: 'Role PUT success',
      },
    },
  })
  async replaceById(
    @param.path.number('id') id: number,
    @requestBody() role: Role,
  ): Promise {
    await this.roleRepository.replaceById(id, role);
  }

  @authenticate(STRATEGY.BEARER)
github sourcefuse / loopback4-starter / src / modules / user-tenants / user.controller.ts View on Github external
@authenticate(STRATEGY.BEARER)
  @authorize([PermissionKey.CreateAnyUser, PermissionKey.CreateTenantUser])
  @post('/users', {
    responses: {
      '200': {
        description: 'User model instance',
        content: {'application/json': {schema: {'x-ts-type': User}}},
      },
    },
  })
  async create(@requestBody() user: User): Promise {
    return await this.userRepository.create(user);
  }

  @authenticate(STRATEGY.BEARER)
  @authorize([
    PermissionKey.ViewAnyUser,
    PermissionKey.ViewOwnUser,
    PermissionKey.ViewTenantUser,
  ])
  @get('/users/count', {
    responses: {
      '200': {
        description: 'User model count',
        content: {'application/json': {schema: CountSchema}},
      },
    },
  })
  async count(
    @param.query.object('where', getWhereSchemaFor(User)) where?: Where,
  ): Promise {