Skip to content

Commit e9ff98a

Browse files
committed
added strong for details, fixed examples with User/Todo resource
1 parent 45b3aff commit e9ff98a

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

README.md

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ npm install
3434

3535
## Limitations
3636

37-
Additional security mechanisms like **CSRF tokens**, **rate limiting**, or **IP blocking** should be disabled during testing. Otherwise, they may interfere with the testing process. Temporarily disable such protections via environment variables or similar mechanisms to ensure accurate test results.
37+
Additional security mechanisms like **CSRF tokens**, **rate limiting**, or **IP blocking** should be disabled during testing. Otherwise, they may interfere with the testing process. For example, a `403 Forbidden` status code caused by IP blocking might be misinterpreted by the tool. Temporarily disable such protections via environment variables or similar mechanisms to ensure accurate test results.
3838

3939
Currently, only one resource per operation can be defined. The tool does not support multiple resources in a single route (e.g., `/groups/:groupId/members/:memberId`). Simple routes like `/members/:memberId` are fully supported.
4040

41-
Also, the tool only supports APIs that communicate via JSON. XML or other data formats are not yet supported.
41+
Also, the tool only supports APIs communicating via JSON. XML or other formats are not yet supported.
4242

4343
---
4444

4545
## Assumptions
4646

47-
The tool assumes that tested web applications follow this sequence when handling requests:
47+
The tool assumes tested web applications follow this sequence when handling requests:
4848

4949
1. User identity verification (*Authentication*)
5050
2. User permission verification (*Authorization*)
@@ -71,13 +71,13 @@ First, determine clearly which API routes represent resources and the type of ac
7171

7272
The following custom annotations (prefixed with `x-act-`) are required to specify resources and access types:
7373

74-
- `x-act-resource-name`: Indicates the resource accessed by the operation.
75-
- `x-act-resource-access`: Specifies the access type (`create`, `read`, `update`, `delete`).
74+
- `x-act-resource-name`: Indicates the resource accessed.
75+
- `x-act-resource-access`: Specifies access type.
7676

77-
Annotations can be provided inline or nested:
77+
Annotations can be inline or nested under `x-act`:
7878

7979
<details open>
80-
<summary>Example of Inline Annotation</summary>
80+
<summary><strong>Example of Inline Annotation</strong></summary>
8181

8282
```yaml
8383
x-act-resource-name: Todo
@@ -86,7 +86,7 @@ x-act-resource-access: read
8686
</details>
8787
8888
<details open>
89-
<summary>Example of Nested Annotation</summary>
89+
<summary><strong>Example of Nested Annotation</strong></summary>
9090
9191
```yaml
9292
x-act:
@@ -96,20 +96,20 @@ x-act:
9696
</details>
9797
9898
<details>
99-
<summary>Full Example of Resource Annotations</summary>
99+
<summary><strong>Complete Example of OpenAPI Annotations</strong></summary>
100100
101101
```yaml
102102
paths:
103103
/todos:
104104
get:
105105
# ...
106106
x-act:
107-
resource-name: User
107+
resource-name: Todo
108108
resource-access: read
109109
post:
110110
# ...
111111
x-act:
112-
resource-name: User
112+
resource-name: Todo
113113
resource-access: create
114114

115115
/todos/{id}:
@@ -122,33 +122,31 @@ paths:
122122
schema:
123123
type: string
124124
x-act:
125-
resource-name: User
125+
resource-name: Todo
126126
resource-access: read
127127
```
128128
</details>
129129
130-
Additionally, define security schemes in your OpenAPI file, either globally or at the individual operation level. For more details, refer to the [Security Scheme documentation](https://swagger.io/docs/specification/authentication/).
131-
132130
---
133131
134132
### 3. Annotating Authentication Endpoints
135133
136-
Ensure you have a valid security scheme defined. Refer to the [Security Scheme documentation](https://learn.openapis.org/specification/security.html).
134+
Before annotating authentication endpoints, ensure a valid security scheme is defined in your OpenAPI specification. See the [Security Scheme documentation](https://learn.openapis.org/specification/security.html).
137135
138-
To automate authentication, use these annotations:
136+
Use these annotations to allow the tool to authenticate automatically:
139137
140-
- `x-act-auth-endpoint`: Matches your security scheme key.
138+
- `x-act-auth-endpoint`: Must match your defined security scheme key and must be provided on operation-level.
141139
- `x-act-auth-field`:
142-
- `identifier`: Username/email.
143-
- `password`: Password.
144-
- `token`: Token field in response.
140+
- `identifier`: Username/email (request body)
141+
- `password`: Password (request body)
142+
- `token`: Token returned (response body)
145143

146144
> [!IMPORTANT]
147145
> For bearer authentication, the token field must be at the top level of the response. Nested fields like `{ data: { token: "<token>" } }` are currently not supported.
148146

149147

150148
<details>
151-
<summary>Example of an annotated Bearer token endpoint</summary>
149+
<summary><strong>Example of an Authentication Endpoint (Bearer)</strong></summary>
152150

153151
```yaml
154152
paths:
@@ -188,16 +186,16 @@ paths:
188186

189187
### 4. Defining Users and Resources
190188

191-
Define users and resources clearly, ensuring names match exactly (case-sensitive) those in the OpenAPI annotations.
189+
Define user-resource relationships explicitly. Resource names must match exactly (case-sensitive) the values used in the OpenAPI annotations (`x-act-resource-name`):
192190

193191
<details open>
194-
<summary>Example of User-Resource Definition</summary>
192+
<summary><strong>Example of User-Resource Definition</strong></summary>
195193

196194
```typescript
197195
import { User, Resource } from 'access-control-testing'
198196
199197
const user1 = new User('myusername', 'mysecretpassword')
200-
const todoResource = new Resource('Todo') // Matches 'Todo' exactly
198+
const todoResource = new Resource('Todo') // Name must exactly match OpenAPI spec annotation
201199
202200
user1.canView(todoResource, 123) // user1 can view Todo instance with identifier 123
203201
user1.canEdit(todoResource, 123) // user1 can edit Todo instance with identifier 123
@@ -213,13 +211,13 @@ user1.owns(todoResource) // user1 owns created Todo instances
213211

214212
Provide the following properties when configuring the tool:
215213

216-
- `apiBaseUrl`: Base URL of the API under test.
217-
- `openApiUrl`: URL to your annotated OpenAPI spec.
218-
- `users`: Array of user objects.
219-
- `resources`: Array of resource objects.
214+
- `apiBaseUrl`: The base URL where your API is accessible.
215+
- `openApiUrl`: URL pointing to your annotated OpenAPI spec.
216+
- `users`: Array of defined users.
217+
- `resources`: Array of defined resources.
220218

221219
<details open>
222-
<summary>Example of Tool Configuration</summary>
220+
<summary><strong>Example of Tool Configuration</strong></summary>
223221

224222
```typescript
225223
const users = [user1]
@@ -241,7 +239,7 @@ const act = new Act({
241239
After setup, tests are generated and executed as follows:
242240

243241
<details open>
244-
<summary>Example of Running Tests</summary>
242+
<summary><strong>Example of Running Tests</strong></summary>
245243

246244
```typescript
247245
import { Act, NodeTestRunner } from 'access-control-testing'

0 commit comments

Comments
 (0)