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

[Security] Rename $subject to $object #34764

Closed
vudaltsov opened this issue Dec 2, 2019 · 11 comments
Closed

[Security] Rename $subject to $object #34764

vudaltsov opened this issue Dec 2, 2019 · 11 comments
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed) Security Stalled

Comments

@vudaltsov
Copy link
Contributor

vudaltsov commented Dec 2, 2019

User creates an article. User is the subject (the one who does the action) and article is the object (what action is applied to). See https://www.lexico.com/en/grammar/subjects-and-objects or any other resource on the topic.

Currently we have a wrong variable name in Security, VoterInterface and exception classes. The AccessDecisionManagerInterface is nonetheless correct.

I propose to replace $subject with $object in 4.3 and redeprecate (see #19969) AccessDeniedException::(g|s)etSubject in master.

@xabbuh xabbuh added RFC RFC = Request For Comments (proposals about features that you want to be discussed) Security labels Dec 2, 2019
@garak
Copy link
Contributor

garak commented Dec 8, 2019

I'm not a native English speaker, but I can argue that "subject" is used instead of "object" in e-mail domain too (where the subject should be the sender and the object should be the title of e-mail).
So I never seen "subject" wrong here, while I agree that consistency should be targeted.

@vudaltsov
Copy link
Contributor Author

@garak , as far as i know, the subject in the e-mail domain is a brief summary of its contents.

@vudaltsov
Copy link
Contributor Author

The evidence for the subject/object meaning in the access control domain can be found here: https://en.wikibooks.org/wiki/Fundamentals_of_Information_Systems_Security/Access_Control_Systems

Authentication is the method of proving the subjects identity.

A subject is an active entity that requests access to a resource

Same here: https://www.eit.lth.se/fileadmin/eit/courses/eit060/lect/Lect5.pdf.
And anywhere else, can be googled easily https://www.google.com/search?q=access+control+subject.

@romaricdrigon
Copy link
Contributor

I understand why you dislike subject, but object feels less precise. Plus there's possible confusion with a PHP object, I think it makes the concept less clear to newcomers.

What about resource?

@vudaltsov
Copy link
Contributor Author

@romaricdrigon , that's a cool idea, I like it! Feels like it will resolve any problems with meaning.

@jvasseur
Copy link
Contributor

jvasseur commented Dec 9, 2019

I think we renamed it from object to subject to clear the confusion with the PHP object type so I'm against going back to object (resource would have the same problem since it's also a PHP type).

@vudaltsov
Copy link
Contributor Author

@jvasseur , I would disagree that nowadays PHP developers tend to judge about variable's type by its name in the first place. We all know that variable name is a semantic attribute in the first place, not a type declaration replacement. Variable name is the meaning of the value within the given context.

I think that resource is a better option, though. resource is not so commonly used, so it should minimize the type confusion. It's really hard to imagine that when smb sees AuthorizationCheckerInterface::isGranted($attributes, $resource = null): bool; the person decides to pass an fopen result or smth like that.

@vudaltsov
Copy link
Contributor Author

@wouterj , what do you think about this issue?

@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@carsonbot
Copy link

Friendly ping? Should this still be open? I will close if I don't hear anything.

@carsonbot
Copy link

Hey,

I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed) Security Stalled
Projects
None yet
Development

No branches or pull requests

6 participants