Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access policies are ineffective for modifying abstract types, leading to the ability to directly modify entity types by altering abstract types. #6133

Closed
sdghf opened this issue Sep 21, 2023 · 2 comments · Fixed by #6136
Assignees

Comments

@sdghf
Copy link

sdghf commented Sep 21, 2023

  • EdgeDB Version:3.3+d5734dd
  • EdgeDB CLI Version:EdgeDB CLI 3.5.0+e1ad387
  • OS Version: macos 13.4.1

Steps to Reproduce:


module default {
    global current_user_id: uuid;

    global current_user := (
        select User filter .id = global current_user_id
    );
   abstract type User{
        required role: str

        access policy allow_all
            allow all
            using (global current_user.role ?= 'admin'){
              errmessage := 'forbid'
            };

        access policy only_read
            allow select
            using (global current_user.role ?= 'readonly'){
              errmessage := 'forbid'
            };
    }

     type Customer extending User{
       required mobile: str
    }

}
  1. Set the current user's role to 'readonly'.

I was surprised that I could successfully modify the abstract type 'User' directly, which resulted in unintentional changes to 'Customer.' However, attempting to directly modify the 'Customer' entity type was unsuccessful. This has left me puzzled.

image
image

@raddevon raddevon added the bug label Sep 21, 2023
@msullivan
Copy link
Member

I have no idea how I accidentally assigned Dave and Dijana to this issue; this one goes to me :(

@msullivan
Copy link
Member

The bug is that parent access policies for updates and deletes are not properly applied to children if the children do not have any access policies of their own.
As a temporary workaround, you can add dummy access policies to the children type, like

access policy dummy allow select using (false)

And I'm working on a fix right now, and it'll be out in 3.4

msullivan added a commit that referenced this issue Sep 21, 2023
Previously we would spuriously ignore the policies on those children,
as the result of an incorrect mechanism being used to detect when a
type has policies when compiling DML.

Just check in the obvious way.

Fixes #6133
msullivan added a commit that referenced this issue Sep 21, 2023
…#6136)

Previously we would spuriously ignore the policies on those children,
as the result of an incorrect mechanism being used to detect when a
type has policies when compiling DML.

Just check in the obvious way.

Fixes #6133
msullivan added a commit that referenced this issue Sep 21, 2023
…#6136)

Previously we would spuriously ignore the policies on those children,
as the result of an incorrect mechanism being used to detect when a
type has policies when compiling DML.

Just check in the obvious way.

Fixes #6133
msullivan added a commit that referenced this issue Sep 27, 2023
…#6136)

Previously we would spuriously ignore the policies on those children,
as the result of an incorrect mechanism being used to detect when a
type has policies when compiling DML.

Just check in the obvious way.

Fixes #6133
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants