Skip to content

Unexpected behaviour on get method #6

@harukaze-sm

Description

@harukaze-sm

Steps to reproduce

  • Tried to use feathers-casl with prisma adapter, but setting permissions to specific issues gives the following error
{
    "name": "NotFound",
    "message": "No record found for id 'ckzqtphw00000hz3x1g9szk3f' and query.id 'ckzqtphw00000hz3x1g9szk3f'",
    "code": 404,
    "className": "not-found",
    "errors": {}
}
  • simple example to reproduce this issue
// abilities.ts https://feathers-casl.netlify.app/getting-started.html#about for better reference 
import { createAliasResolver, makeAbilityFromRules } from 'feathers-casl';
import { AbilityBuilder, Ability } from '@casl/ability';
import { User } from '@prisma/client';

export const defineRulesFor = (user: User) => {
  const { can, rules } = new AbilityBuilder(Ability);

  can('read', 'users', { id: user.id }); # note that { id: user.id } causes this issue
  can('update', 'users', { id: user.id });
  can('delete', 'users', { id: user.id });

  return rules;
};
import { authorize } from 'feathers-casl/dist';

 before: {
    all: [authenticate('jwt'), loadAbilities()], // load abilities are basically same as https://feathers-casl.netlify.app/getting-started.html#add-abilities-to-hooks-context
    get: [authorize()], // this hook causes the JSON response written at the top
  },

Expected behavior

It should allow user to get only info related to their id, and give 403 on any other user

Actual behavior

image

System details

Macbook Pro M1 13inch
MacOS Monterey 12.2

Module versions (especially the part that's not working):

feathers-prisma@0.5.6
feathers-casl@0.7.1

NodeJS version:

v16.13.0

Operating System:

MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions