Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 4 CSP don't support style-src-attr
#1

Hi, I have a problem to add style-src-attr 'unsafe-inline' rulle to CSP header. There is no "addStyleSrcAttr" function in CSP Library. 
Temporarily i solve this problem with my own custom CSP Library:

 ContentSecurityPolicy.php
// namespace App\Libraries;
.....
    public function addStyleSrcAttr($uri, ?bool $explicitReporting = null)
{
        $this->addOption($uri, 'styleSrcAttr', $explicitReporting ?? $this->reportOnly);
        return $this;
    }
....
    protected function buildHeaders(ResponseInterface $response)
    {
        // Ensure both headers are available and arrays...
        $response->setHeader('Content-Security-Policy', []);
        $response->setHeader('Content-Security-Policy-Report-Only', []);

        $directives = [
           ....
            'style-src'      => 'styleSrc',
            'style-src-attr'  => 'styleSrcAttr', // Added the new style attr
           ....
        ];
Reply


Messages In This Thread
Codeigniter 4 CSP don't support style-src-attr - by Styopi - 10-31-2023, 04:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB