GWT CSP compliance ('unsafe-inline' rule)

766 views
Skip to first unread message

Yuriy Ostapyuk

unread,
Sep 9, 2019, 9:36:00 AM9/9/19
to GWT Users
Hello.

I'm struggling with GWT vs CSP problem, specifically 'unsafe-inline' rule.

I have an application with several deferred modules, which are compiled and linked with 'xsiframe' or 'direct_install' linkers. And my problem is that linkers use ScriptTagLoadingStrategy, which uses callbacks and eventually appends (and then deletes) <script> tag to GWT iframe with inline javascript in it, which in the end violates 'unsafe-inline' rule. I've experimented with default linkers and found out that 'sso' (SingleScriptLinker) fixes the problem, but unfortunately it's not the case for me, as it not support several modules/fragments.

So, I'm wondering maybe someone has already researched this problem or knows some kind of custom linker, which is using a different strategy to support CSP.

Thank you in advance for any help or suggestion.

Regards.

Thomas Broyer

unread,
Sep 9, 2019, 10:09:29 AM9/9/19
to GWT Users
Most important here in the end is the TODO comment; but that means you should be able to create your own custom linker that would override that method (and possibly others, e.g. getJsRunAsync).

But currently, yes, you need unsafe-inline (and/or CSP3's strict-dynamic, and/or CSP2's hash sources –it should be possible to compute those hashes at compile-time using a special linker; in the worst case a special CrossSiteIframeLinker's wrapDeferredFragment override–)

Yuriy Ostapyuk

unread,
Sep 10, 2019, 6:33:13 AM9/10/19
to GWT Users
Thank you so much for suggestions, it helped me.

Yegor

unread,
Apr 13, 2021, 3:55:37 PM4/13/21
to GWT Users
Hello Yuriy,
would you please share how you solved the issue.

Reply all
Reply to author
Forward
0 new messages