Skip to content

Commit 23e508c

Browse files
docs: security parameter (#1960)
1 parent fd12f71 commit 23e508c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

core/filters.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,3 +1880,24 @@ class ValidateParameter {}
18801880
```
18811881

18821882
You can also use your own constraint by setting the `constraints` option on a Parameter. In that case we won't setup the automatic validation for you and it'll replace our defaults.
1883+
1884+
1885+
### Parameter security
1886+
1887+
Parameters may have security checks:
1888+
1889+
``` php
1890+
<?php
1891+
use ApiPlatform\Metadata\GetCollection;
1892+
use ApiPlatform\Metadata\HeaderParameter;
1893+
use ApiPlatform\Metadata\QueryParameter;
1894+
1895+
#[GetCollection(
1896+
uriTemplate: 'security_parameters{._format}',
1897+
parameters: [
1898+
'sensitive' => new QueryParameter(security: 'is_granted("ROLE_ADMIN")'),
1899+
'auth' => new HeaderParameter(security: '"secretKey" == auth[0]'),
1900+
],
1901+
)]
1902+
class SecurityParameter {}
1903+
```

0 commit comments

Comments
 (0)