Skip to content

Commit 995dcf4

Browse files
authored
disabling runtime
1 parent 79497b2 commit 995dcf4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

README.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Yii2 integration of Content Security Policy Header
105105

106106
Possible integrations
107107
----------------
108-
CSP can work by **signature** or by **token** (*nonce*)
108+
CSP can work by **signature** or by the **nonce token**
109109
see:
110110

111111

@@ -121,7 +121,7 @@ Example:
121121
This kind of integration does not require patch to the framework code but it's space wasting and hard to mantain
122122
even with a small number of signatures.
123123

124-
Integration by token (nonce)
124+
Integration by nonce token
125125
----------------
126126
This kind of integration require some (small) patch at framework (\yii\helpers\BaseHtml) level to take full advantage of nonce token.
127127
The nonce feature (enabled by default) don't need maintenace once integrated and has reduced footprint on the header
@@ -239,6 +239,16 @@ In detail the line:
239239
echo '<script '.Yii::$app->response->getContentSecurityPolicyTokenAttribute().'>' . $view->renderPhpFile(__DIR__ . '/assets/toolbar.js') . '</script>';
240240
241241
```
242+
Runtime disabilitation
243+
----------------
244+
Since no header is sent until the ```render``` call it's possible to disable one or more modules as needed.
245+
 
246+
```php
247+
public function actionIndex() {
248+
Yii::$app->getResponse()->modules['sample-module']->enabled=false;
249+
return $this->render("index");
250+
}
251+
```
242252
243253
244254

0 commit comments

Comments
 (0)