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

Implement createAccess for File entities #5479

Closed
indigoxela opened this issue Jan 29, 2022 · 6 comments
Closed

Implement createAccess for File entities #5479

indigoxela opened this issue Jan 29, 2022 · 6 comments
Assignees

Comments

@indigoxela
Copy link
Member

All core entities except File implement a createAccess() override. As the default return value of Entity::access is TRUE, this leads to the problem that the value for File is always TRUE - ignoring "create files" permission.

Our assumption is currently, that not creating that override when adding entity_access in #3011 was an oversight.

I'm not sure if this is a bug or a feature request. Feedback is welcome.

Also related: #4975 - TRUE is a dangerous default value, anyway.

@indigoxela
Copy link
Member Author

Need to also consider 'bypass file access', the check is still incomplete.

@indigoxela
Copy link
Member Author

Need to also consider 'bypass file access'

Done.

@argiepiano
Copy link

Code looks good to me. I tested by invoking the method directly, and also through entity_access, and it works for me. 👍🏽

Incidentally, at the moment, this method is only used by entity_access. The file module, unlike other entity modules in core (node, comment and taxonomy), never invokes this method to check for create permission. Instead, this check is performed in file_file_access() by directly calling user_access. Perhaps this should be changed in a separate issue, to mirror the way it's done by those modules, and thus avoid checking for create access in two separate places?

Before marking this as RTBC perhaps it'd be good to get some feedback about the above.

@klonos
Copy link
Member

klonos commented Feb 6, 2022

pinging @backdrop/core-committers ^^

@indigoxela
Copy link
Member Author

The file module, unlike other entity modules in core (node, comment and taxonomy), never invokes this method to check for create permission.

Yes, there seem to be some inconsistencies, which deserve a closer look. Unlike other access checks (view, update, delete - which are sometimes more fine-granular), it should (in theory) be possible to use createAccess consistently across entities. But I'd suggest to do that in a follow-up - the hook system might require some extra considerations.

@indigoxela
Copy link
Member Author

Closing in favor of #5480

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

Successfully merging a pull request may close this issue.

3 participants