Title: AclManager RetrievalStrategy is wrong (I think) · Issue #35 · Problematic/ProblematicAclManagerBundle · GitHub
Open Graph Title: AclManager RetrievalStrategy is wrong (I think) · Issue #35 · Problematic/ProblematicAclManagerBundle
X Title: AclManager RetrievalStrategy is wrong (I think) · Issue #35 · Problematic/ProblematicAclManagerBundle
Description: Hey, About this function : /** * @param mixed $domainObject * @param string $field * @param int $mask * @param UserInterface | TokenInterface | RoleInterface $securityIdentity * @param string $type * @param string $field * @param boolean...
Open Graph Description: Hey, About this function : /** * @param mixed $domainObject * @param string $field * @param int $mask * @param UserInterface | TokenInterface | RoleInterface $securityIdentity * @param string $type...
X Description: Hey, About this function : /** * @param mixed $domainObject * @param string $field * @param int $mask * @param UserInterface | TokenInterface | RoleInterface $securityIdentity * @param string $type...
Opengraph URL: https://github.com/Problematic/ProblematicAclManagerBundle/issues/35
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AclManager RetrievalStrategy is wrong (I think)","articleBody":"Hey, \n\nAbout this function : \n\n``` php\n /**\n * @param mixed $domainObject\n * @param string $field\n * @param int $mask\n * @param UserInterface | TokenInterface | RoleInterface $securityIdentity\n * @param string $type\n * @param string $field\n * @param boolean $replace_existing\n * @return \\Problematic\\AclManagerBundle\\Domain\\AbstractAclManager\n */\n protected function addPermission($domainObject, $field, $mask, $securityIdentity = null, $type = 'object', $replace_existing = false)\n {\n if(is_null($securityIdentity)){\n $securityIdentity = $this-\u003egetUser();\n }\n $context = $this-\u003edoCreatePermissionContext($type, $field, $securityIdentity, $mask);\n $oid = $this-\u003egetObjectIdentityRetrievalStrategy()-\u003egetObjectIdentity($domainObject);\n $acl = $this-\u003edoLoadAcl($oid);\n $this-\u003edoApplyPermission($acl, $context, $replace_existing);\n\n $this-\u003egetAclProvider()-\u003eupdateAcl($acl);\n\n return $this;\n }\n```\n\nWhen you enter in her via this function :\n\n``` php\n /**\n * {@inheritDoc}\n */\n public function addClassPermission($domainObject, $mask, $securityIdentity = null)\n {\n $this-\u003eaddPermission($domainObject, null, $mask, $securityIdentity, 'class', false);\n }\n```\n\nThe following line is wrong : `$oid = $this-\u003egetObjectIdentityRetrievalStrategy()-\u003egetObjectIdentity($domainObject);` in the way that use the wrong service (in `addPermission`function)\n\nBy default SecurityComponent provide this service `security.acl.object_identity_retrieval_strategy` but he can be apply only for `DomainObject` not for `Object`. And in case of call `AddClassPermission` or `serClassPermission` you didn't work with `DomainObject` but with `Object`.\n\nHere the code of `ObjectIdentityRetrievalStrategy` provided by default : \n\n``` php\n /**\n * {@inheritdoc}\n */\n public function getObjectIdentity($domainObject)\n {\n try {\n return ObjectIdentity::fromDomainObject($domainObject);\n } catch (InvalidDomainObjectException $failed) {\n return;\n }\n }\n```\n\nSo when add class permission like : `$aclManager-\u003eaddClassPermission(Media::CLASS, MaskBuilder::MASK_OPERATOR, $sid);` That trigger `InvalidDomainObjectException` and do nothing.\n\nSo, may i'm wrong ? or you must create your own `ObjectIdentityRetrievalStrategy` service to fix it ? (or dont call `ObjectIdentityRetrievalStrategy`in case of `Object`\n\nSo in my project I made a quick fix, to create my own service ObjectIdentityRetrievalStrategy, it's only for my need so to make it proper we must implement some setter, to configure identifier, but I only use `class` for this moment.\n\n``` php\nclass ObjectIdentityRetrievalStrategy extends \\Symfony\\Component\\Security\\Acl\\Domain\\ObjectIdentityRetrievalStrategy\n{\n /**\n * @param object $domainObject\n *\n * @return ObjectIdentityInterface|void\n */\n public function getObjectIdentity($domainObject)\n {\n if(is_string($domainObject)){\n return new ObjectIdentity('class', $domainObject);\n }\n\n return parent::getObjectIdentity($domainObject);\n }\n} \n```\n\nNOTE: On your example you show this : `$aclManager-\u003eaddClassPermission($comment, MaskBuilder::MASK_OWNER, $userEntity);` But when we work with `Object` the right call is `$aclManager-\u003eaddClassPermission(Comment::CLASS, MaskBuilder::MASK_OWNER, $userEntity);` because it's not a `DomainObject` We want add the permission of all instance of $comment, not specially $comment.\n","author":{"url":"https://github.com/jjsaunier","@type":"Person","name":"jjsaunier"},"datePublished":"2014-10-14T09:51:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/35/ProblematicAclManagerBundle/issues/35"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bf9c1f9a-d61c-479a-3c55-ff397d465ed5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B450:1D772C:2766AC0:33F9312:696B2765 |
| html-safe-nonce | e5d61d2c7ee60f1ca380c7b29e3a8d20748affabe82c9f645a801476cb4181c5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDUwOjFENzcyQzoyNzY2QUMwOjMzRjkzMTI6Njk2QjI3NjUiLCJ2aXNpdG9yX2lkIjoiNjg1MDgyNDU0OTQ2NTUzMjI2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f333f456bdf66d4adb076d599033fcd08c7dc5db2d8c7fd8a3305a37bba1f9fc |
| hovercard-subject-tag | issue:45731463 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Problematic/ProblematicAclManagerBundle/35/issue_layout |
| twitter:image | https://opengraph.githubassets.com/98e3bb6ca72df0d4231c4a8b9f3827e4f3f3e81fa74457663b0c2e05fabe521c/Problematic/ProblematicAclManagerBundle/issues/35 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/98e3bb6ca72df0d4231c4a8b9f3827e4f3f3e81fa74457663b0c2e05fabe521c/Problematic/ProblematicAclManagerBundle/issues/35 |
| og:image:alt | Hey, About this function : /** * @param mixed $domainObject * @param string $field * @param int $mask * @param UserInterface | TokenInterface | RoleInterface $securityIdentity * @param string $type... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jjsaunier |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/Problematic/ProblematicAclManagerBundle git https://github.com/Problematic/ProblematicAclManagerBundle.git |
| octolytics-dimension-user_id | 744424 |
| octolytics-dimension-user_login | Problematic |
| octolytics-dimension-repository_id | 1740896 |
| octolytics-dimension-repository_nwo | Problematic/ProblematicAclManagerBundle |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1740896 |
| octolytics-dimension-repository_network_root_nwo | Problematic/ProblematicAclManagerBundle |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width