You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/2-features/04-authentication.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -236,17 +236,23 @@ This paradigm is known as [policy-based access control](https://en.wikipedia.org
236
236
237
237
### Defining policies
238
238
239
-
To create a policy, you may define a method in any class and annotate it with the {b`#[Tempest\Auth\AccessControl\PolicyFor]`} attribute. Typically, this is done in a dedicated policy class.
239
+
To create a policy, you may define a method in any class and annotate it with the {b`#[Tempest\Auth\AccessControl\Policy]`} attribute. Typically, this is done in a dedicated policy class.
240
240
241
-
The attribute expects the class name of the resource as its first parameter, and an optional action name as the second parameter. If the action name is not provided, the kebab-cased method name is used instead.
241
+
The attribute expects the class name of the resource as its first parameter, and the action name as the second parameter. If the resource is not specified, it will be inferred by the method's first parameter. Similarly, if the action name is not provided, the kebab-cased method name is used instead.
Copy file name to clipboardExpand all lines: packages/auth/src/AccessControl/Policy.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -7,17 +7,17 @@
7
7
8
8
/**
9
9
* When applied on a method, this attribute indicates that the method is a policy method for the specified resource.
10
-
* The method must accept an action as its first parameter, the resource instance as its second, and the subject as its last.
10
+
* The method must accept the resource instance as its first parameter and the subject as its second one.
11
11
*/
12
12
#[Attribute(Attribute::TARGET_METHOD)]
13
-
finalclassPolicyFor
13
+
finalclassPolicy
14
14
{
15
15
/**
16
-
* @param class-string $resource A resource class that this policy applies to.
16
+
* @param class-string $resource A resource class that this policy applies to. If not specified, it will be inferred by the method's first argument.
17
17
* @param null|UnitEnum|string|iterable<string|UnitEnum|null> $action An optional action that this policy applies to. If null, the policy applies to all actions for the resource.
"The resource for policy `%s` could not be inferred because it is missing from the method's parameters. You must specify it in the attribute instead.",
"/The resource for policy `.*::missingResourceType` could not be inferred because it is missing from the method's parameters\. You must specify it in the attribute instead\./",
0 commit comments