From beb11b0f41a7c6c18b6fc8c8698fe95b60afc1b3 Mon Sep 17 00:00:00 2001 From: Matthias Linhuber Date: Mon, 30 Sep 2024 14:18:14 +0200 Subject: [PATCH] Add cors settings --- roles/artemis/defaults/main.yml | 12 +++++++++++- roles/artemis/templates/application-prod.yml.j2 | 8 +++++--- roles/artemis/templates/artemis.env.j2 | 9 +++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/roles/artemis/defaults/main.yml b/roles/artemis/defaults/main.yml index bfa5398..a8ca5b0 100644 --- a/roles/artemis/defaults/main.yml +++ b/roles/artemis/defaults/main.yml @@ -248,8 +248,18 @@ artemis_eureka_instance_id: "{{ node_id }}" ############################################################################## # CORS Configuration +# This is the default config to work with scorpio and theia ############################################################################## -#artemis_CORS_allowed_origins: "*" + +# artemis_cors: +# allowed_methods: "*" +# allowed_headers: "*" +# exposed_headers: "Authorization,Link,X-Total-Count,Set-Cookie" +# allow_credentials: true +# max_age: 1800 +# allowed_origins: +# - "vscode-file://vscode-app" +# - "vscode-webview://*" ############################################################################## # Auto-generated Variables - No not alter! diff --git a/roles/artemis/templates/application-prod.yml.j2 b/roles/artemis/templates/application-prod.yml.j2 index 9d94f28..0698d2c 100644 --- a/roles/artemis/templates/application-prod.yml.j2 +++ b/roles/artemis/templates/application-prod.yml.j2 @@ -340,9 +340,11 @@ jhipster: token-validity-in-seconds-for-remember-me: 2592000 # Token is valid 30 days {% endif %} -{% if artemis_CORS_allowed_origins is defined and artemis_CORS_allowed_origins is not none %} - cors: - allowed-origins: {{ artemis_CORS_allowed_origins }} +{% if artemis_cors is defined and artemis_cors is not none %} + artemis_cors: + {% for key, value in cors.items() %} + {{ key }}: {{ value | to_nice_yaml(indent=2) | trim }} + {% endfor %} {% endif %} {% if is_multinode_install|bool == true and artemis_jhipster_registry_password is not none %} diff --git a/roles/artemis/templates/artemis.env.j2 b/roles/artemis/templates/artemis.env.j2 index fefd049..f7396b0 100644 --- a/roles/artemis/templates/artemis.env.j2 +++ b/roles/artemis/templates/artemis.env.j2 @@ -234,8 +234,13 @@ JHIPSTER_SECURITY_AUTHENTICATION_JWT_BASE64SECRET='{{ artemis_jhipster_jwt }}' JHIPSTER_SECURITY_AUTHENTICATION_JWT_TOKENVALIDITYINSECONDS='259200' JHIPSTER_SECURITY_AUTHENTICATION_JWT_TOKENVALIDITYINSECONDSFORREMEMBERME='2592000' {% endif %} -{% if artemis_CORS_allowed_origins is defined and artemis_CORS_allowed_origins is not none %} -JHIPSTER_CORS_ALLOWEDORIGINS='{{ artemis_CORS_allowed_origins }}' +{% if artemis_cors is defined and artemis_cors is not none %} +JHIPSTER_CORS_ALLOWEDMETHODS='{{ artemis_cors.allowed_methods | join(',') }}' +JHIPSTER_CORS_ALLOWEDHEADERS='{{ artemis_cors.allowed_headers | join(',') }}' +JHIPSTER_CORS_EXPOSEDHEADERS='{{ artemis_cors.exposed_headers }}' +JHIPSTER_CORS_ALLOWCREDENTIALS='{{ artemis_cors.allow_credentials }}' +JHIPSTER_CORS_MAXAGE='{{ artemis_cors.max_age }}' +JHIPSTER_CORS_ALLOWEDORIGINS='{{ artemis_cors.allowed_origins | join(',') }}' {% endif %} {% if is_multinode_install|bool == true and artemis_jhipster_registry_password is not none %} JHIPSTER_REGISTRY_PASSWORD='{{ artemis_jhipster_registry_password }}'