I am using Flask with Flask-Talisman. My CSP is configured currently, for all routes as:
SELF = '\'self\''
csp = {
'default-src': [SELF, '*.gstatic.com'],
'connect-src': [SELF, 'https://fonts.googleapis.com', 'https://cdnjs.cloudflare.com'],
'frame-src': [SELF, 'https://js.stripe.com'],
'script-src': [SELF, 'https://cdnjs.cloudflare.com', 'https://js.stripe.com', 'https://www.googletagmanager.com'],
'style-src': [SELF, 'https://cdnjs.cloudflare.com', 'https://fonts.googleapis.com', '\'unsafe-inline\''],
'img-src': [SELF, '*', 'blob:', 'data:']
}
talisman.init_app(app, content_security_policy=csp, content_security_policy_nonce_in=['script-src'])
Whenever an external site tries to load my pages via iframe
they receive the error X-Frame-Options is SAMEORIGIN
, which is generally OK.
However I would like a single route to be accessible by external iframes on load. To achieve this I have followed the advice to set:
@talisman(frame_options=ALLOW_FROM, frame_options_allow_from='*')
before my specific route.
However Chrome does not allow this and reports an error. I beleive instead the CSP should instead be set. How should I re-write or re-configure my route to allow it to be accessed by external iframes in all browsers?