diff --git a/esap/accounts/api/views.py b/esap/accounts/api/views.py index 8aeef60d3317e9acc8d23ffdc72e4779bb5b85b6..a026f89dd35084961474b1d08f24ed0f3a24b8b3 100644 --- a/esap/accounts/api/views.py +++ b/esap/accounts/api/views.py @@ -1,10 +1,11 @@ +import logging +from django.contrib import auth from rest_framework import viewsets from rest_framework import permissions from .serializers import * from ..models import * -from django.contrib import auth - +logger = logging.getLogger(__name__) class EsapQuerySchemaViewSet(viewsets.ModelViewSet): """ @@ -57,16 +58,20 @@ class EsapUserProfileViewSet(viewsets.ModelViewSet): def get_queryset(self): # Returns nothing if no user_name supplied instead of all + print("EsapUserProfileViewSet.get_queryset()") + try: - # id_token = self.request.session["oidc_id_token"] - # uid = id_token["iss"]+id_token["sub"] - # preferred_username = id_token["preferred_username"] - # name = id_token["name"] - # access_token = self.request.session["oidc_access_token"] + id_token = self.request.session["oidc_id_token"] + + #uid = id_token["iss"]+id_token["sub"] + #preferred_username = id_token["preferred_username"] + #name = id_token["name"] + #access_token = self.request.session["oidc_access_token"] user = auth.get_user(self.request) user_email = user.email return EsapUserProfile.objects.filter(user_email=user_email) except AttributeError as e: + print('ERROR: '+str(e)) user_name = self.request.query_params.get("user_name", None) return EsapUserProfile.objects.filter(user_name=user_name) diff --git a/esap/docker/docker-compose-dev-cd.yml b/esap/docker/docker-compose-dev-cd.yml new file mode 100644 index 0000000000000000000000000000000000000000..cb4f7d382937aa342ef74638736b410a73690416 --- /dev/null +++ b/esap/docker/docker-compose-dev-cd.yml @@ -0,0 +1,111 @@ +version: '3.4' + +networks: + esap_network: + traefik_proxy: + external: + name: traefik_proxy + default: + driver: bridge + +services: + esap_api: + container_name: esap_api_query + image: git.astron.nl:5000/astron-sdc/esap-api-gateway + expose: + - 8000 + networks: + - traefik_proxy + - esap_network + labels: + - "traefik.enable=true" + - "traefik.http.routers.esap-api.entryPoints=esap-api-query" + - "traefik.http.routers.esap-api.service=esap-api" + - "traefik.http.routers.esap-api.rule=Host(`sdc-dev.astron.nl`) && PathPrefix(`/esap-api`)" + - "traefik.http.services.esap-api.loadbalancer.server.port=8000" + - "traefik.http.routers.esap-qstatic.entryPoints=esap-api-query" + - "traefik.http.routers.esap-qstatic.service=esap-qstatic" + - "traefik.http.routers.esap-qstatic.rule=Host(`sdc-dev.astron.nl`) && PathPrefix(`/static`)" + - "traefik.http.services.esap-qstatic.loadbalancer.server.port=8000" + env_file: + - $HOME/shared/oidc.env + restart: always + volumes: + - $HOME/shared/esap-gateway-query/:/shared + +# uncomment the following section if the esap-gui frontend has to run in a container. +# in that case, also adjust the /static/ proxy section in the esap_nginx.conf file +# esap_gui: +# build: +# context: $HOME/my_docker/esap-gui +# dockerfile: Dockerfile +# container_name: esap-gui-compose +# ports: +# - "8017:80" +# expose: +# - "8017" +# networks: +# - esap_network +# restart: always + + + esap_nginx: + build: + context: $HOME/shared + dockerfile: Dockerfile + container_name: esap_nginx + image: esap_nginx:latest + networks: + - traefik_proxy + - esap_network + labels: + - "traefik.enable=true" + + # route to esap-gui + - "traefik.http.routers.esap-gui.entryPoints=websecure" + - "traefik.http.routers.esap-gui.service=esap-gui" + - "traefik.http.routers.esap-gui.rule=Host(`sdc-dev.astron.nl`) && PathPrefix(`/esap-gui`)" + - "traefik.http.services.esap-gui.loadbalancer.server.port=80" + + # route to adex-gui + - "traefik.http.routers.adex-gui.entryPoints=websecure" + - "traefik.http.routers.adex-gui.service=adex-gui" + - "traefik.http.routers.adex-gui.rule=Host(`sdc-dev.astron.nl`) && PathPrefix(`/adex-gui`)" + - "traefik.http.services.adex-gui.loadbalancer.server.port=80" + + # route to astron-hips + - "traefik.http.routers.astron-hips.entryPoints=websecure" + - "traefik.http.routers.astron-hips.service=astron-hips" + - "traefik.http.routers.astron-hips.rule=Host(`sdc-dev.astron.nl`) && PathPrefix(`/astron-hips`)" + - "traefik.http.services.astron-hips.loadbalancer.server.port=80" + + # route the '/static' calls for the esap-gui frontend + - "traefik.http.routers.esap-static.entryPoints=websecure" + - "traefik.http.routers.esap-static.service=esap-static" + - "traefik.http.routers.esap-static.rule=Host(`sdc-dev.astron.nl`) && PathPrefix(`/static`)" + - "traefik.http.services.esap-static.loadbalancer.server.port=80" + + - "traefik.http.routers.esap-static_esap.entryPoints=websecure" + - "traefik.http.routers.esap-static_esap.service=esap-static_esap" + - "traefik.http.routers.esap-static_esap.rule=Host(`sdc-dev.astron.nl`) && PathPrefix(`/static_esap`)" + - "traefik.http.services.esap-static_esap.loadbalancer.server.port=80" + + # uncomment when the frontend connects to '/esap-api' instead of to 'https://sdc-dev.astron.nl:5555/esap-api' +# - "traefik.http.routers.esap-api-default.entryPoints=websecure" +# - "traefik.http.routers.esap-api-default.service=esap-api-default" +# - "traefik.http.routers.esap-api-default.rule=Host(`sdc-dev.astron.nl`) && PathPrefix(`/esap-api`)" +# - "traefik.http.services.esap-api-default.loadbalancer.server.port=80" + + # route to the '/oidc' authentication + - "traefik.http.routers.esap-oidc.entryPoints=websecure" + - "traefik.http.routers.esap-oidc.service=esap-oidc" + - "traefik.http.routers.esap-oidc.rule=Host(`sdc-dev.astron.nl`) && PathPrefix(`/oidc`)" + - "traefik.http.services.esap-oidc.loadbalancer.server.port=80" +# ports: +# - 80:80 + volumes: + - $HOME/shared:/shared + - $HOME/shared:/etc/nginx/conf.d + - $HOME/shared/static:/static + restart: always + diff --git a/esap/esap/esap_config.sqlite3 b/esap/esap/esap_config.sqlite3 index f6b14b5e4abf57d9642902f6e12a84fddb8a5298..dede72da85fc6e8f427cee05d7bfd247a116349d 100644 Binary files a/esap/esap/esap_config.sqlite3 and b/esap/esap/esap_config.sqlite3 differ diff --git a/esap/esap/settings/base.py b/esap/esap/settings/base.py index 47533eaddc27bc38e104dc117e6dd11deffd3403..3529fa5bcbb41e7c0de60a7463d1517b5f266d29 100644 --- a/esap/esap/settings/base.py +++ b/esap/esap/settings/base.py @@ -183,6 +183,10 @@ LOGGING = { 'handlers': ['my_handler', 'my_file_handler', 'mail_admins'], 'level': 'INFO', }, + 'accounts': { + 'handlers': ['my_handler', 'my_file_handler', 'mail_admins'], + 'level': 'INFO', + }, 'django': { 'handlers': ['console', 'mail_admins'], 'level': 'INFO', @@ -234,6 +238,6 @@ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') # configuration settings that can be requested through the REST API -VERSION = "ASTRON - version 13 nov 2020" +VERSION = "ESAP-API version 23 feb 2021" CONFIGURATION_DIR = os.path.join(BASE_DIR, 'configuration') CONFIGURATION_FILE = 'esap_default' diff --git a/esap/esap/settings/docker.py b/esap/esap/settings/docker.py index cf791400d2c2c051b39d73b624f341e257a9e94d..f51fff009ca1ca8eab1a72571965befd732ff834 100644 --- a/esap/esap/settings/docker.py +++ b/esap/esap/settings/docker.py @@ -20,11 +20,11 @@ DEBUG = True ALLOWED_HOSTS = ['*'] CORS_ORIGIN_ALLOW_ALL = True -# CORS_ALLOWED_ORIGINS = [ -# "https://sdc-dev.astron.nl", -#] -#CORS_ORIGIN_ALLOW_ALL = False -#CORS_ALLOW_CREDENTIALS = True +CORS_ALLOWED_ORIGINS = [ + "https://sdc-dev.astron.nl","https://sdc.astron.nl", +] +CORS_ORIGIN_ALLOW_ALL = False +CORS_ALLOW_CREDENTIALS = True # Application definition diff --git a/esap/logs/esap.log b/esap/logs/esap.log index 213b8d23c233118ff2abcc8715e2ef53dae15159..aa844b9aa838a6dd4a5611e3e2eb2e49bee64476 100644 --- a/esap/logs/esap.log +++ b/esap/logs/esap.log @@ -4577,3 +4577,22 @@ [10/Dec/2020 17:37:29,772] https://alta.astron.nl/altapi/dataproducts?collection=imaging_and_dataProductType=image_and_release__release_id=APERTIF_DR1_Imaging_and_page=1_and_dataProductSubType__in=calibratedVisibility,continuumMF,continuumChunk,imageCube,beamCube,polarisationImage,polarisationCube,continuumCube_and_page_size=50 [10/Dec/2020 17:37:29,774] query_controller.run_query() [10/Dec/2020 17:37:29,774] run-query: https://alta.astron.nl/altapi/dataproducts?collection=imaging&dataProductType=image&release__release_id=APERTIF_DR1_Imaging&page=1&dataProductSubType__in=calibratedVisibility,continuumMF,continuumChunk,imageCube,beamCube,polarisationImage,polarisationCube,continuumCube&page_size=50 +[23/Feb/2021 15:25:02,802] could not find 'waveband' in the query_params. Continuing... +[23/Feb/2021 15:25:02,803] query_controller.get_services() +[23/Feb/2021 15:25:34,623] query_controller.create_and_run_query() +[23/Feb/2021 15:25:34,625] query_controller.create_query() +[23/Feb/2021 15:25:34,636] ERROR: could not translating key collection 'collection', using it raw. +[23/Feb/2021 15:25:34,639] ERROR: could not translating key release__release_id 'release__release_id', using it raw. +[23/Feb/2021 15:25:34,641] query_controller.create_and_run_query() +[23/Feb/2021 15:25:34,641] construct_query: https://alta.astron.nl/altapi/dataproducts?collection=imaging_and_release__release_id=APERTIF_DR1_Imaging_and_dataProductSubType__in=calibratedVisibility,continuumMF,continuumChunk,imageCube,beamCube,polarisationImage,polarisationCube,continuumCube_and_page_size=50 +[23/Feb/2021 15:25:34,642] query_controller.create_query() +[23/Feb/2021 15:25:34,643] https://alta.astron.nl/altapi/dataproducts?collection=imaging_and_release__release_id=APERTIF_DR1_Imaging_and_dataProductSubType__in=calibratedVisibility,continuumMF,continuumChunk,imageCube,beamCube,polarisationImage,polarisationCube,continuumCube_and_page_size=50 +[23/Feb/2021 15:25:34,650] ERROR: could not translating key collection 'collection', using it raw. +[23/Feb/2021 15:25:34,651] query_controller.run_query() +[23/Feb/2021 15:25:34,651] ERROR: could not translating key release__release_id 'release__release_id', using it raw. +[23/Feb/2021 15:25:34,653] run-query: https://alta.astron.nl/altapi/dataproducts?collection=imaging&release__release_id=APERTIF_DR1_Imaging&dataProductSubType__in=calibratedVisibility,continuumMF,continuumChunk,imageCube,beamCube,polarisationImage,polarisationCube,continuumCube&page_size=50 +[23/Feb/2021 15:25:34,654] ERROR: could not translating key page 'page', using it raw. +[23/Feb/2021 15:25:34,656] construct_query: https://alta.astron.nl/altapi/dataproducts?collection=imaging_and_release__release_id=APERTIF_DR1_Imaging_and_page=1_and_dataProductSubType__in=calibratedVisibility,continuumMF,continuumChunk,imageCube,beamCube,polarisationImage,polarisationCube,continuumCube_and_page_size=50 +[23/Feb/2021 15:25:34,658] https://alta.astron.nl/altapi/dataproducts?collection=imaging_and_release__release_id=APERTIF_DR1_Imaging_and_page=1_and_dataProductSubType__in=calibratedVisibility,continuumMF,continuumChunk,imageCube,beamCube,polarisationImage,polarisationCube,continuumCube_and_page_size=50 +[23/Feb/2021 15:25:34,661] query_controller.run_query() +[23/Feb/2021 15:25:34,668] run-query: https://alta.astron.nl/altapi/dataproducts?collection=imaging&release__release_id=APERTIF_DR1_Imaging&page=1&dataProductSubType__in=calibratedVisibility,continuumMF,continuumChunk,imageCube,beamCube,polarisationImage,polarisationCube,continuumCube&page_size=50 diff --git a/esap/query/templates/query/index.html b/esap/query/templates/query/index.html index 55189e4da422239844bde687159a79487936af1b..fa925d24541cf8979858627b8c15a2bc25201c7f 100644 --- a/esap/query/templates/query/index.html +++ b/esap/query/templates/query/index.html @@ -70,7 +70,7 @@ </div> -<p class="footer" small>ASTRON - version 23 feb 2021 - 11:30</p> +<p class="footer" small>ASTRON - version 23 mar 2021 - 10:00</p> {% endblock %}