Skip to content

Commit 8d8c6cf

Browse files
authored
Merge pull request #290 from niden-code/5.9.x
reworded security and acl; reformat for warnings
2 parents 76415b7 + 8a20a08 commit 8d8c6cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+165
-164
lines changed

docs/acl.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ In this example, a [Role][acl-role] indicates who needs access to a specific [Co
3838
Using the [Phalcon\Acl][acl-acl] component, you can establish associations between these [Roles][acl-role] and [Components][acl-component], enhancing the application's security by allowing only specific roles to access designated components.
3939

4040
## Activation
41-
[Phalcon\Acl][acl-acl] relies on adapters to manage roles and components. Presently, the only available adapter is [Phalcon\Acl\Adapter\Memory][acl-adapter-memory]. While using the memory adapter significantly enhances ACL access speed, it comes with the trade-off of non-persistent memory. Therefore, developers need to implement a storage strategy for ACL data to avoid regenerating the ACL at every request. This is particularly crucial for large ACLs stored in a database or file system.
41+
[Phalcon\Acl][acl-acl] uses adapters to manage roles and components. Currently the built-in adapter is [Phalcon\Acl\Adapter\Memory][acl-adapter-memory]. The memory adapter is fast but non-persistent, so you should persist the ACL (cache or file) in production to avoid rebuilding it on every request.
4242

4343
The [Phalcon\Acl][acl-acl] constructor takes an adapter as its first parameter for retrieving information related to the control list.
4444

@@ -110,7 +110,7 @@ $acl->addRole('guest');
110110
```
111111

112112
## Adding Components
113-
A [Component][acl-component] in the context of Phalcon\Acl represents an area of the application where access is controlled. In an MVC application, this typically corresponds to a Controller. Although it is not mandatory, you can use the [Phalcon\Acl\Component][acl-component] class to define components in the application. It is important to add related actions to a component so that the ACL understands what it should control.
113+
A [Component][acl-component] in the context of Phalcon\Acl represents an area of the application where access is controlled. In an MVC application, this typically corresponds to a Controller. Although not required, you can use the [Phalcon\Acl\Component][acl-component] class to define components in the application. It is important to add related actions to a component so that the ACL understands what it should control.
114114

115115
There are two ways to add components to our list:
116116

@@ -225,6 +225,8 @@ $acl->allow('manager', 'admin', 'dashboard');
225225
$acl->allow('manager', 'reports', ['list', 'add']);
226226
$acl->allow('accounting', 'reports', '*');
227227
$acl->allow('*', 'session', '*');
228+
$acl->allow('*', '*', 'view');
229+
$acl->deny('guest', '*', 'view');
228230
```
229231

230232
In the above example:
@@ -234,13 +236,10 @@ In the above example:
234236
* `$acl->allow('*', 'session', '*');`: Wildcards can be used for mass matching roles, components, or actions. This line allows every role to access every action in the `session` component.
235237
* `$acl->allow('*', '*', 'view');`: This line gives access to the `view` action to every role. In MVC terms, it allows any role to access any controller that exposes a `viewAction`.
236238
* `$acl->deny('guest', '*', 'view');`: For the `guest` role, deny access to all components with the `view` action. Despite the default access level being `Acl\Enum::DENY`, this line specifically denies the `view` action to all roles and components. It ensures that the `guest` role only has access to the `session` component and the `login` and `logout` actions since guests are not logged into the application.
237-
* `$acl->allow('*', '*', 'view');`: This line gives access to the `view` action to every role. However, the following line excludes the `guest` role from that access:
238-
239-
```php
240-
$acl->deny('guest', '*', 'view');
241-
```
239+
* `$acl->allow('*', '*', 'view');`: This line gives access to the `view` action to every role.
240+
* `$acl->deny('guest', '*', 'view');`: This line excludes the `guest` role from the `view` access:
242241

243-
!!! danger "NOTE"
242+
!!! danger "DANGER"
244243

245244
Please be **VERY** careful when using the `*` wildcard. It is very easy to make a mistake and the wildcard, although it seems convenient, it may allow users to access areas of your application that they are not supposed to. The best way to be 100% sure is to write tests specifically to test the permissions and the ACL. These can be done in the `unit` test suite by instantiating the component and then checking the `isAllowed()` if it is `true` or `false`.
246245

@@ -665,7 +664,7 @@ if ($acl->isAllowed('manager', 'admin', 'dashboard')) {
665664
}
666665
```
667666

668-
It is a good practice to not use serialization of the ACL during development to ensure that your ACL is rebuilt with every request, while other adapters or means of serializing and storing the ACL in production.
667+
It is a good practice to not serialize the ACL during development to ensure that your ACL is rebuilt with every request, while other adapters or means of serializing and storing the ACL in production.
669668

670669
## Events
671670
[Phalcon\Acl][acl-acl] can work in conjunction with the [Events Manager][events] if present, to fire events to your application. Events are triggered using the type `acl`. Events that return `false` can stop the active role. The following events are available:

docs/api/phalcon_mvc.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,7 +2669,7 @@ $invoice->inv_total = 120;
26692669
$invoice->update();
26702670
```
26712671

2672-
!!! warning "NOTE"
2672+
!!! warning "WARNING"
26732673

26742674
When retrieving the record with `findFirst()`, you need to get the full
26752675
object back (no `columns` definition) but also retrieve it using the
@@ -14640,5 +14640,3 @@ Appends template before controller layout
1464014640
public function start();
1464114641
```
1464214642
Starts rendering process enabling the output buffering
14643-
14644-

docs/application-micro.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ $container = new Di();
3636
$app = new Micro($container);
3737
```
3838

39-
!!! warning "NOTE"
39+
!!! warning "WARNING"
4040

4141
Starting from Phalcon v5.3.0, the `Micro` object is no longer automatically registered in the dependency injection container with the name `application`. Developers are required to manage the application instance explicitly.
4242

@@ -308,7 +308,7 @@ Defining routes in a [Phalcon\Mvc\Micro][mvc-micro] application is straightforwa
308308
### Activation
309309
Routing is managed by the [Phalcon\Mvc\Router][mvc-router] object.
310310

311-
!!! warning "NOTE"
311+
!!! warning "WARNING"
312312

313313
Routes must always start with `/`
314314

@@ -994,7 +994,7 @@ $invoices->get('/delete/{id}', 'deleteAction');
994994
$app->mount($invoices);
995995
```
996996

997-
!!! warning "NOTE"
997+
!!! warning "WARNING"
998998

999999
The name that we bind each route has a suffix of `Action`. This is not necessary, your method can be called anything you like.
10001000

@@ -1655,7 +1655,7 @@ Middleware can be attached to a Micro application in three different events:
16551655
| `after` | After the handler has been executed |
16561656
| `finish` | After the response has been sent to the caller |
16571657

1658-
!!! warning "NOTE"
1658+
!!! warning "WARNING"
16591659

16601660
Multiple middleware classes can be attached to each of the above events, and they will be executed sequentially when the relevant event fires.
16611661

@@ -2199,7 +2199,7 @@ class RequestMiddleware implements MiddlewareInterface
21992199

22002200
This middleware is responsible for manipulating our response and sending it back to the caller as a JSON string. Therefore, we need to attach it to the `after` event of our Micro application.
22012201

2202-
!!! warning "NOTE"
2202+
!!! warning "WARNING"
22032203

22042204
We are using the `call` method for this middleware since we have nearly executed the whole request cycle.
22052205

@@ -2246,7 +2246,7 @@ class ResponseMiddleware implements MiddlewareInterface
22462246

22472247
Models can be utilized in Micro applications by instructing the application on how to find the relevant classes through an autoloader.
22482248

2249-
!!! warning "NOTE"
2249+
!!! warning "WARNING"
22502250

22512251
The relevant `db` service must be registered in your DI container.
22522252

@@ -2364,7 +2364,7 @@ $app->get(
23642364
);
23652365
```
23662366

2367-
!!! warning "NOTE"
2367+
!!! warning "WARNING"
23682368

23692369
The above example uses the [Phalcon\Mvc\View\Simple][mvc-view-simple] component, which uses relative paths instead of controllers and actions. You can use the [Phalcon\Mvc\View][mvc-view] component instead, but to do so, you will need to change the parameters passed to `render()`.
23702370

docs/application.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ try {
2727
}
2828
```
2929

30-
!!! warning "NOTE"
30+
!!! warning "WARNING"
3131

3232
`handle()` accepts a URI and will not operate without it. You can pass the `$_SERVER["REQUEST_URI"]` as a parameter
3333

docs/assets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ The output will include the file modification time in the URL:
736736
<link rel="stylesheet" href="css/bootstrap.css?ver=1558392141">
737737
```
738738

739-
!!! warning "NOTE"
739+
!!! warning "WARNING"
740740

741741
Using the auto version feature is not recommended for production environments due to unnecessary file system read operations.
742742

docs/autoload.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Loader
22
- - -
33

4-
!!! warning "NOTE"
4+
!!! warning "WARNING"
55

66
The `Phalcon\Autoload\Loader` class has been renamed `Phalcon\Autoload\Loader`. The functionality remains the same.
77

@@ -38,7 +38,7 @@ $loader->register();
3838

3939
You can always call the `isRegistered()` method to check if your autoloader is registered or not.
4040

41-
!!! warning "NOTE"
41+
!!! warning "WARNING"
4242

4343
If there is an error in registering the autoloader, the component will throw an exception.
4444

docs/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ echo config('app-name', 'default', '-'); // PHALCON
256256
echo config('app-unknown', 'default', '-'); // default
257257
```
258258

259-
!!! warning "NOTE"
259+
!!! warning "WARNING"
260260

261261
If the keys from your data contain special characters such as `.` or `-`, and you choose to use the same character for your delimiter when using the `path()` method, you will not get the desired results back, since `path()` will interpret the delimiter as a new nested level.
262262

docs/contributions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ When you create a pull request, we have a handy template to help you describe wh
1717
* put on hold, if a discussion is necessary (community, core team etc.)
1818
* rejected
1919

20-
!!! warning "NOTE"
20+
!!! warning "WARNING"
2121

2222
If your pull request is a new feature, it is best to discuss it with the core team first, to ensure that it will align with the evolution of the framework.
2323

24-
!!! danger "NOTE"
24+
!!! danger "DANGER"
2525

2626
Please make sure that the target branch that you send your pull request is correct and that you have already rebased your code. Pull requests to the **master** branch are not allowed
2727

@@ -35,7 +35,7 @@ We have removed the translations from v5.5.x onward. There was not that much tra
3535

3636
## Questions and Support
3737

38-
!!! danger "NOTE"
38+
!!! danger "DANGER"
3939

4040
We only accept bug reports, new feature requests and pull requests in GitHub. For questions regarding the usage of the framework or support requests please visit the [official discussions page][phalcon-discussions] or our [Discord][phalcon-discord] server.
4141

docs/controllers.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ class InvoicesController extends Controller
9292
}
9393
```
9494

95-
!!! warning "NOTE"
95+
!!! warning "WARNING"
9696

9797
The use of the `__construct()` method is not recommended.
9898

99-
!!! warning "NOTE"
99+
!!! warning "WARNING"
100100

101101
The `initialize()` method is only called if the `beforeExecuteRoute` event has been executed successfully. This is to ensure that if you have authorization checking code in the event, `initialize` will never be invoked
102102

@@ -116,7 +116,7 @@ class InvoicesController extends Controller
116116
}
117117
```
118118

119-
!!! warning "NOTE"
119+
!!! warning "WARNING"
120120

121121
Note that `onConstruct()` is executed even if the action to be executed does not exist in the controller or the user does not have access to it (assuming custom access control is implemented in the application).
122122

@@ -245,7 +245,7 @@ class InvoicesController extends Controller
245245
}
246246
```
247247

248-
!!! warning "NOTE"
248+
!!! warning "WARNING"
249249

250250
You will need to add additional code to ensure that the data passed is of the correct type and either use the default value or have a correct value. If not, you will end up with errors.
251251

@@ -626,4 +626,4 @@ $container->set(
626626
[application]: application.md
627627
[autoload]: autoload.md
628628
[routing]: routing.md
629-
[views]: views.md
629+
[views]: views.md

docs/datamapper.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
These components have been heavily influenced by [Aura PHP][auraphp] and [Atlas PHP][atlasphp]
77

8-
!!! warning "NOTE"
8+
!!! warning "WARNING"
99

1010
The full implementation of a DataMapper is not yet complete. There are however a few components that can be used in any project, such as the `Connection` and `Query/Select`
1111

@@ -2461,7 +2461,7 @@ $update->perform();
24612461
// inv_status_flag = :inv_status_flag
24622462
```
24632463

2464-
!!! warning "NOTE"
2464+
!!! warning "WARNING"
24652465

24662466
Using the `columns()` method you are not able to set the type of each parameter.
24672467

0 commit comments

Comments
 (0)