Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b2752c46
Commit
b2752c46
authored
Jul 05, 2016
by
Connor Shea
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only enable CSP policies when relevant features are enabled.
Gravatar, Google Analytics, Piwik, Recaptcha, etc.
parent
fa56c34b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletion
+27
-1
config/initializers/secure_headers.rb
config/initializers/secure_headers.rb
+27
-1
No files found.
config/initializers/secure_headers.rb
View file @
b2752c46
...
@@ -32,7 +32,7 @@ SecureHeaders::Configuration.default do |config|
...
@@ -32,7 +32,7 @@ SecureHeaders::Configuration.default do |config|
frame_src:
%w('self')
,
frame_src:
%w('self')
,
connect_src:
%w('self')
,
connect_src:
%w('self')
,
font_src:
%w('self')
,
font_src:
%w('self')
,
img_src:
%w('self'
www.gravatar.com secure.gravatar.com
https:)
,
img_src:
%w('self' https:)
,
media_src:
%w('none')
,
media_src:
%w('none')
,
object_src:
%w('none')
,
object_src:
%w('none')
,
script_src:
%w('unsafe-inline' 'self')
,
script_src:
%w('unsafe-inline' 'self')
,
...
@@ -46,7 +46,33 @@ SecureHeaders::Configuration.default do |config|
...
@@ -46,7 +46,33 @@ SecureHeaders::Configuration.default do |config|
report_uri:
%W(
#{
CSP_REPORT_URI
}
)
report_uri:
%W(
#{
CSP_REPORT_URI
}
)
}
}
# Allow Bootstrap Linter in development mode.
if
Rails
.
env
.
development?
if
Rails
.
env
.
development?
config
.
csp
[
:script_src
]
<<
"maxcdn.bootstrapcdn.com"
config
.
csp
[
:script_src
]
<<
"maxcdn.bootstrapcdn.com"
end
end
# Recaptcha
if
current_application_settings
.
recaptcha_enabled
config
.
csp
[
:script_src
]
<<
"https://www.google.com/recaptcha/"
config
.
csp
[
:script_src
]
<<
"https://www.gstatic.com/recaptcha/"
config
.
csp
[
:frame_src
]
<<
"https://www.google.com/recaptcha/"
end
# Gravatar
if
current_application_settings
.
gravatar_enabled?
config
.
csp
[
:img_src
]
<<
"www.gravatar.com"
config
.
csp
[
:img_src
]
<<
"secure.gravatar.com"
config
.
csp
[
:img_src
]
<<
Gitlab
.
config
.
gravatar
.
host
end
# Piwik
if
Gitlab
.
config
.
extra
.
has_key?
(
'piwik_url'
)
&&
Gitlab
.
config
.
extra
.
has_key?
(
'piwik_site_id'
)
config
.
csp
[
:script_src
]
<<
Gitlab
.
config
.
extra
.
piwik_url
config
.
csp
[
:img_src
]
<<
Gitlab
.
config
.
extra
.
piwik_url
end
# Google Analytics
if
Gitlab
.
config
.
extra
.
has_key?
(
'google_analytics_id'
)
config
.
csp
[
:script_src
]
<<
"https://www.google-analytics.com"
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment