-
-
Notifications
You must be signed in to change notification settings - Fork 901
feat: add security_post_denormalize
in ApiProperty
#4184
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
Changes from all commits
d079d0c
6f6ee14
a209247
4de8bb9
7de1dff
9fc673a
699f8e0
c178a85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,17 @@ class SecuredDummy | |
*/ | ||
private $adminOnlyProperty = ''; | ||
|
||
/** | ||
* @var string Secret property, only readable/writable by owners | ||
* | ||
* @ODM\Field | ||
* @ApiProperty( | ||
* security="object == null or object.getOwner() == user", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it still useful? |
||
* securityPostDenormalize="object.getOwner() == user", | ||
* ) | ||
*/ | ||
private $ownerOnlyProperty = ''; | ||
|
||
/** | ||
* @var string The owner | ||
* | ||
|
@@ -187,6 +198,16 @@ public function setAdminOnlyProperty(?string $adminOnlyProperty) | |
$this->adminOnlyProperty = $adminOnlyProperty; | ||
} | ||
|
||
public function getOwnerOnlyProperty(): ?string | ||
{ | ||
return $this->ownerOnlyProperty; | ||
} | ||
|
||
public function setOwnerOnlyProperty(?string $ownerOnlyProperty) | ||
{ | ||
$this->ownerOnlyProperty = $ownerOnlyProperty; | ||
} | ||
|
||
public function getOwner(): string | ||
{ | ||
return $this->owner; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,17 @@ class SecuredDummy | |
*/ | ||
private $adminOnlyProperty = ''; | ||
|
||
/** | ||
* @var string Secret property, only readable/writable by owners | ||
* | ||
* @ORM\Column | ||
* @ApiProperty( | ||
* security="object == null or object.getOwner() == user", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it still useful? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But if there is already a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Found the answer myself: it's because it is used for the |
||
* securityPostDenormalize="object.getOwner() == user", | ||
* ) | ||
*/ | ||
private $ownerOnlyProperty = ''; | ||
|
||
/** | ||
* @var string The owner | ||
* | ||
|
@@ -198,6 +209,16 @@ public function setAdminOnlyProperty(?string $adminOnlyProperty) | |
$this->adminOnlyProperty = $adminOnlyProperty; | ||
} | ||
|
||
public function getOwnerOnlyProperty(): ?string | ||
{ | ||
return $this->ownerOnlyProperty; | ||
} | ||
|
||
public function setOwnerOnlyProperty(?string $ownerOnlyProperty) | ||
{ | ||
$this->ownerOnlyProperty = $ownerOnlyProperty; | ||
} | ||
|
||
public function getOwner(): string | ||
{ | ||
return $this->owner; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it possible to modify a property of a resource without the right to do so before?
If so, isn't it a bugfix for 2.6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I'm aware of. This is only reverting the properties that fail the new
security_post_denormalize
check. Properties that fail thesecurity
check are still filtered from denormalization viaAbstractItemNormalizer::getAllowedAttributes()