SatisfiesParentSecurityPolicy.php 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /*
  3. * Copyright 2010 Johannes M. Schmitt <schmittjoh@gmail.com>
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. namespace JMS\SecurityExtraBundle\Annotation;
  18. /**
  19. * This must be declared on classes which inherit from classes that have
  20. * requested method invocation securing capabilities.
  21. *
  22. * It indicates to the analyzer that the developer is aware of these security
  23. * restrictions, and has applied them to the root class in an appropriate
  24. * fashion.
  25. *
  26. * We cannot do this automatically without properly analyzing the control flow,
  27. * and in some cases it is not possible at all. See the following example:
  28. *
  29. * <code>
  30. * // child class
  31. * public function editComment($commentId)
  32. * {
  33. * // retrieve comment from database
  34. * $comment = $this->entityManager->find($commentId);
  35. *
  36. * return parent::editComment($comment);
  37. * }
  38. *
  39. * // base class which is inherited from
  40. * /**
  41. * * @SecureParam(name="comment", permissions="EDIT")
  42. * *\/
  43. * public function editComment(Comment $comment)
  44. * {
  45. * // do some supposedly secure action
  46. * }
  47. * <code>
  48. *
  49. * The above example can be rewritten so that we can apply security checks
  50. * automatically:
  51. *
  52. * <code>
  53. * // child class
  54. * public function editComment($commentId)
  55. * {
  56. * // retrieve comment from database
  57. * $comment = $this->entityManager->find($commentId);
  58. *
  59. * return $this->doEditComment($comment);
  60. * }
  61. *
  62. * // base class which is inherited from
  63. * /**
  64. * * @SecureParam(name="comment", permissions="EDIT")
  65. * *\/
  66. * protected function doEditComment(Comment $comment)
  67. * {
  68. * // do some secure action
  69. * }
  70. * </code>
  71. *
  72. * @Annotation
  73. * @Target("METHOD")
  74. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  75. */
  76. final class SatisfiesParentSecurityPolicy
  77. {
  78. }