add sentry js back in
This commit is contained in:
parent
6696188601
commit
e6ddf2f120
3
app.py
3
app.py
|
@ -81,13 +81,14 @@ def install_security_headers(resp):
|
||||||
csp = ("default-src 'none';"
|
csp = ("default-src 'none';"
|
||||||
"img-src 'self' https:;"
|
"img-src 'self' https:;"
|
||||||
"style-src 'self' 'unsafe-inline';"
|
"style-src 'self' 'unsafe-inline';"
|
||||||
"connect-src 'self';"
|
|
||||||
"frame-ancestors 'none';"
|
"frame-ancestors 'none';"
|
||||||
)
|
)
|
||||||
if 'SENTRY_DSN' in app.config:
|
if 'SENTRY_DSN' in app.config:
|
||||||
csp += "script-src 'self' https://cdn.ravenjs.com/;"
|
csp += "script-src 'self' https://cdn.ravenjs.com/;"
|
||||||
|
csp += "connect-src 'self' https://sentry.io/;"
|
||||||
else:
|
else:
|
||||||
csp += "script-src 'self';"
|
csp += "script-src 'self';"
|
||||||
|
csp += "connect-src 'self';"
|
||||||
|
|
||||||
if 'CSP_REPORT_URI' in app.config:
|
if 'CSP_REPORT_URI' in app.config:
|
||||||
csp += "report-uri " + app.config.get('CSP_REPORT_URI')
|
csp += "report-uri " + app.config.get('CSP_REPORT_URI')
|
||||||
|
|
15
routes.py
15
routes.py
|
@ -40,10 +40,7 @@ def inject_version():
|
||||||
@app.context_processor
|
@app.context_processor
|
||||||
def inject_sentry():
|
def inject_sentry():
|
||||||
if sentry:
|
if sentry:
|
||||||
client_dsn = app.config.get('SENTRY_DSN').split('@')
|
return dict(sentry=True)
|
||||||
client_dsn[:1] = client_dsn[0].split(':')
|
|
||||||
client_dsn = ':'.join(client_dsn[0:2]) + '@' + client_dsn[3]
|
|
||||||
return dict(sentry_dsn=client_dsn)
|
|
||||||
return dict()
|
return dict()
|
||||||
|
|
||||||
|
|
||||||
|
@ -338,3 +335,13 @@ def mastodon_login_step2(instance_url):
|
||||||
|
|
||||||
g.viewer = sess
|
g.viewer = sess
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
@app.route('/sentry/setup.js')
|
||||||
|
def sentry_setup():
|
||||||
|
client_dsn = app.config.get('SENTRY_DSN').split('@')
|
||||||
|
client_dsn[:1] = client_dsn[0].split(':')
|
||||||
|
client_dsn = ':'.join(client_dsn[0:2]) + '@' + client_dsn[3]
|
||||||
|
resp = make_response(render_template(
|
||||||
|
'sentry.js', sentry_dsn = client_dsn))
|
||||||
|
resp.headers.set('content-type', 'text/javascript')
|
||||||
|
return resp
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
<meta name='twitter:card' content='summary' />
|
<meta name='twitter:card' content='summary' />
|
||||||
<meta name='twitter:site:id' content='808418'/>
|
<meta name='twitter:site:id' content='808418'/>
|
||||||
|
|
||||||
{% if sentry_dsn -%}
|
{% if sentry -%}
|
||||||
<script defer src="https://cdn.ravenjs.com/3.17.0/raven.min.js" crossorigin="anonymous"
|
<script defer src="https://cdn.ravenjs.com/3.17.0/raven.min.js" crossorigin="anonymous"></script>
|
||||||
onload="Raven.config('{{sentry_dsn}}').install()"></script>
|
<script defer src="{{ url_for('sentry_setup') }}"></script>
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Raven.config('{{sentry_dsn}}').install()
|
Loading…
Reference in New Issue