Skip to content

Commit

Permalink
Fix #817 - Add additional avatar URLs to IMG CSP
Browse files Browse the repository at this point in the history
  • Loading branch information
maxxcrawford committed May 26, 2021
1 parent 5438e77 commit 7aa3a69
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions privaterelay/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,18 @@
)
# maps fxa profile hosts to respective avatar hosts for CSP
AVATAR_IMG_SRC_MAP = {
'https://stable.dev.lcip.org/profile/v1': 'stable.dev.lcip.org',
'https://profile.stage.mozaws.net/v1': 'mozillausercontent.com',
'https://profile.accounts.firefox.com/v1': 'firefoxusercontent.com',
'https://stable.dev.lcip.org/profile/v1': [
'stable.dev.lcip.org',
'https://stable.dev.lcip.org/profile/v1/avatar/w',
],
'https://profile.stage.mozaws.net/v1': [
'mozillausercontent.com',
'https://profile.stage.mozaws.net/v1/avatar/w',
],
'https://profile.accounts.firefox.com/v1': [
'firefoxusercontent.com',
'https://profile.accounts.firefox.com/v1/avatar/w',
],
}
AVATAR_IMG_SRC = AVATAR_IMG_SRC_MAP[config(
'FXA_PROFILE_ENDPOINT', 'https://profile.accounts.firefox.com/v1'
Expand All @@ -73,11 +82,8 @@
'https://www.google-analytics.com/',
)
CSP_STYLE_SRC = ("'self'",)
CSP_IMG_SRC = (
"'self'",
AVATAR_IMG_SRC,
)
REFERRER_POLICY = 'strict-origin-when-cross-origin'
CSP_IMG_SRC = ["'self'"] + AVATAR_IMG_SRC
REFERRER_POLICY = 'strict-origin-when-cross-origin' \

ALLOWED_HOSTS = []
DJANGO_ALLOWED_HOST = config('DJANGO_ALLOWED_HOST', None)
Expand Down

0 comments on commit 7aa3a69

Please sign in to comment.