mirror of https://gitlab.crans.org/nounous/nixos
nextcloud: CORS (cette fois c’est la bonne)
parent
eafe7b8e0b
commit
1f96169d8c
|
|
@ -54,28 +54,11 @@
|
|||
};
|
||||
|
||||
# Activation CORS pour récuppérer les agendas depuis le wiki
|
||||
# On est obligé de répéter les headers communs de sécurité car ils ne sont pas au même niveau
|
||||
# https://github.com/yandex/gixy/blob/master/docs/en/plugins/addheaderredefinition.md
|
||||
services.nginx.virtualHosts.${config.services.nextcloud.hostName}.locations."~* /remote.php/dav/public-calendars/[a-z]+\?export".extraConfig =
|
||||
let
|
||||
base_headers = ''
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header X-Robots-Tag noindex, nofollow;
|
||||
add_header X-Permitted-Cross-Domain-Policies none;
|
||||
add_header X-Frame-Options sameorigin;
|
||||
add_header Referrer-Policy no-referrer;
|
||||
# TODO: à mettre que sur /remote.php/dav/public-calendars/ pour éviter des requêtes malveillantes depuis le wiki.
|
||||
services.nginx.virtualHosts.${config.services.nextcloud.hostName}.extraConfig = ''
|
||||
add_header 'Access-Control-Allow-Origin' 'https://mediawiki.crans.org' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
|
||||
'';
|
||||
in
|
||||
''
|
||||
${base_headers}
|
||||
if ($request_method = 'OPTIONS') {
|
||||
${base_headers}
|
||||
add_header 'Access-Control-Max-Age' 86400;
|
||||
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
||||
add_header 'Content-Length' 0;
|
||||
return 204;
|
||||
}
|
||||
add_header 'Access-Control-Allow-Methods' 'GET' always;
|
||||
add_header 'Access-Control-Allow-Credentials' 'false' always;
|
||||
add_header 'Vary' 'Origin' always;
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue