Created
April 30, 2021 09:06
-
-
Save bizley/b5dfd172dc27b730943afed921ee7757 to your computer and use it in GitHub Desktop.
FLoC Permissions Policy Header for Yii 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This adds Permissions-Policy header to all Yii 2 app responses blocking FLoC. | |
* What is Federated Learning of Cohorts (FLoC)? - read https://web.dev/floc/ | |
* Google’s FLoC Is a Terrible Idea - read https://www.eff.org/pl/deeplinks/2021/03/googles-floc-terrible-idea | |
*/ | |
$config = [ | |
// ... other configuration | |
'components' => [ | |
// ... other components configuration | |
'response' => [ | |
'on beforeSend' => function () { | |
Yii::$app->response->headers->add('permissions-policy', 'interest-cohort=()'); | |
} | |
], | |
], | |
]; | |
return $config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment