Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nonce CSP is not supported #29

Closed
mariusaustr opened this issue Sep 22, 2021 · 1 comment
Closed

Nonce CSP is not supported #29

mariusaustr opened this issue Sep 22, 2021 · 1 comment

Comments

@mariusaustr
Copy link

There is no way to use nonce content security policy, since Coderello\SharedData\SharedData::render() method returns <script> with no way to inject additional data.

public function render(): string
    {
        return '<script>'
            .'window["'.$this->getJsNamespace().'"]='.$this->toJson().';'
            .'window["sharedDataNamespace"]="'.$this->getJsNamespace().'";'
            .($this->getJsHelperEnabled() ? $this->getJsHelper().';' : '')
            .'</script>';
    }

I think either class constructor or render method could accept nonce value.

@hivokas
Copy link
Member

hivokas commented Oct 22, 2021

Thanks, @mariusaustr! It makes sense.

I've published a new release to support that: https://github.com/coderello/laravel-shared-data/releases/tag/3.2.0

@hivokas hivokas closed this as completed Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants