Skip to content

Commit c632930

Browse files
committed
CSP: adjust configuration to fix errors on /collection/{slug} page.
Addressed to #226
1 parent 581412f commit c632930

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/main/java/ru/mystamps/web/support/spring/security/SecurityConfig.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,24 @@ protected void configure(HttpSecurity http) throws Exception {
122122
"default-src 'none'; "
123123
// 'self' is required for: our own CSS files
124124
// 'https://cdn.rawgit.com' is required for: languages.min.css (TODO: GH #246)
125+
// 'https://www.gstatic.com' is required for: Google Charts on collection page.
125126
// 'sha256-Dpm...' is required for: 'box-shadow: none; border: 0px;' inline CSS
126127
// that are using on /series/add and /series/{id} pages.
127-
+ "style-src 'self' https://cdn.rawgit.com "
128-
+ "'sha256-DpmxvnMJIlwkpmmAANZYNzmyfnX2PQCBDO4CB2BFjzU='; "
128+
// 'sha256-/kX...' is required for: 'overflow: hidden;' inline CSS that is using
129+
// bg Google Charts on collection page.
130+
+ "style-src 'self' https://cdn.rawgit.com https://www.gstatic.com "
131+
+ "'sha256-DpmxvnMJIlwkpmmAANZYNzmyfnX2PQCBDO4CB2BFjzU=' "
132+
+ "'sha256-/kXZODfqoc2myS1eI6wr0HH8lUt+vRhW8H/oL+YJcMg='; "
129133
// 'self' is required for: our own JS files
130134
// 'unsafe-inline' is required for: jquery.min.js (that is using code inside of
131135
// event handlers. We can't use hashing algorithms because they aren't supported
132136
// for handlers. In future, we should get rid of jQuery or use
133137
// 'unsafe-hashed-attributes' from CSP3. Details:
134138
// https://github.com/jquery/jquery/blob/d71f6a53927ad02d/jquery.js#L1441-L1447
135139
// and https://w3c.github.io/webappsec-csp/#unsafe-hashed-attributes-usage)
136-
+ "script-src 'self' 'unsafe-inline'; "
140+
// 'unsafe-eval' is required for: loader.js (for Google Charts)
141+
// 'https://www.gstatic.com' is required for: Google Charts on collection page.
142+
+ "script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.gstatic.com; "
137143
// 'self' is required for: AJAX requests from our scripts (country suggestions)
138144
+ "connect-src 'self'; "
139145
// 'self' is required for: uploaded images and its previews

0 commit comments

Comments
 (0)