From 35928f4d4d165dbd38b823dc904957443db1ab3f Mon Sep 17 00:00:00 2001 From: Andrey Zhavoronkov Date: Tue, 28 Apr 2020 15:18:28 +0300 Subject: [PATCH 1/3] fixed wrong redirect from backend server --- .vscode/launch.json | 7 ++++++- cvat/settings/base.py | 24 +++++++++++++----------- cvat_proxy/conf.d/cvat.conf.template | 20 +++++++++----------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 1fefab7fee5b..12d232b14b40 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -37,7 +37,12 @@ ], "django": true, "cwd": "${workspaceFolder}", - "console": "internalConsole" + "console": "internalConsole", + "env": { + "UI_SCHEME": "http", + "UI_HOST": "localhost", + "UI_PORT": "3000", + } }, { "name": "server: chrome", diff --git a/cvat/settings/base.py b/cvat/settings/base.py index 6bf38049e8c7..4f6cd1bc58ba 100644 --- a/cvat/settings/base.py +++ b/cvat/settings/base.py @@ -189,17 +189,19 @@ def generate_ssh_keys(): # Cross-Origin Resource Sharing settings for CVAT UI UI_SCHEME = os.environ.get('UI_SCHEME', 'http') -UI_HOST = os.environ.get('UI_HOST', 'localhost') -UI_PORT = os.environ.get('UI_PORT', '3000') -CORS_ALLOW_CREDENTIALS = True -CSRF_TRUSTED_ORIGINS = [UI_HOST] -UI_URL = '{}://{}'.format(UI_SCHEME, UI_HOST) - -if UI_PORT and UI_PORT != '80': - UI_URL += ':{}'.format(UI_PORT) - -CORS_ORIGIN_WHITELIST = [UI_URL] -CORS_REPLACE_HTTPS_REFERER = True +UI_HOST = os.environ.get('UI_HOST') +UI_PORT = os.environ.get('UI_PORT') +UI_URL = '' +if UI_HOST: + CORS_ALLOW_CREDENTIALS = True + CSRF_TRUSTED_ORIGINS = [UI_HOST] + UI_URL = '{}://{}'.format(UI_SCHEME, UI_HOST) + + if UI_PORT and UI_PORT != '80': + UI_URL += ':{}'.format(UI_PORT) + + CORS_ORIGIN_WHITELIST = [UI_URL] + CORS_REPLACE_HTTPS_REFERER = True STATICFILES_FINDERS = [ 'django.contrib.staticfiles.finders.FileSystemFinder', diff --git a/cvat_proxy/conf.d/cvat.conf.template b/cvat_proxy/conf.d/cvat.conf.template index c208417426dd..084ce189ea7a 100644 --- a/cvat_proxy/conf.d/cvat.conf.template +++ b/cvat_proxy/conf.d/cvat.conf.template @@ -8,30 +8,28 @@ server { listen 80; server_name ${CVAT_HOST}; + proxy_pass_header X-CSRFToken; + proxy_set_header Host $http_host; + proxy_pass_header Set-Cookie; + location ~* /api/.*|git/.*|tensorflow/.*|auto_annotation/.*|analytics/.*|static/.*|admin|admin/.*|documentation/.*|dextr/.*|reid/.* { proxy_pass http://cvat:8080; - proxy_pass_header X-CSRFToken; - proxy_set_header Host $http_host; - proxy_pass_header Set-Cookie; } - location / { - # workaround for match location by arguments + # workaround for match location by arguments + location = / { error_page 418 = @annotation_ui; if ( $query_string ~ "^id=\d+.*" ) { return 418; } + proxy_pass http://cvat_ui; + } + location / { proxy_pass http://cvat_ui; - proxy_pass_header X-CSRFToken; - proxy_set_header Host $http_host; - proxy_pass_header Set-Cookie; } # old annotation ui, will be removed in the future. location @annotation_ui { proxy_pass http://cvat:8080; - proxy_pass_header X-CSRFToken; - proxy_set_header Host $http_host; - proxy_pass_header Set-Cookie; } } From 7242781d233c35955a73afe3918f65e090cd64d3 Mon Sep 17 00:00:00 2001 From: Andrey Zhavoronkov Date: Tue, 28 Apr 2020 17:29:53 +0300 Subject: [PATCH 2/3] updated changelog and documetation --- CHANGELOG.md | 1 + cvat/apps/documentation/installation.md | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bb8a898aed6..d6a9b167991b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - CVAT new UI: add arrows on a mouse cursor () - Delete point bug (in new UI) () - Fix apache startup after PC restart (https://github.com/opencv/cvat/pull/1467) +- Open task button doesn't work (https://github.com/opencv/cvat/pull/1474) ### Security - diff --git a/cvat/apps/documentation/installation.md b/cvat/apps/documentation/installation.md index 86b4b08fa44e..ec59168e2894 100644 --- a/cvat/apps/documentation/installation.md +++ b/cvat/apps/documentation/installation.md @@ -539,34 +539,33 @@ server { server { listen 443 ssl; server_name ${CVAT_HOST}; + + proxy_pass_header X-CSRFToken; + proxy_set_header Host $http_host; + proxy_pass_header Set-Cookie; + ssl_certificate /cert/certificate.cer; ssl_certificate_key /cert/certificate.key; location ~* /api/.*|git/.*|tensorflow/.*|auto_annotation/.*|analytics/.*|static/.*|admin|admin/.*|documentation/.*|dextr/.*|reid/.* { proxy_pass http://cvat:8080; - proxy_pass_header X-CSRFToken; - proxy_set_header Host $http_host; - proxy_pass_header Set-Cookie; } - location / { - # workaround for match location by arguments + # workaround for match location by arguments + location = / { error_page 418 = @annotation_ui; if ( $query_string ~ "^id=\d+.*" ) { return 418; } + proxy_pass http://cvat_ui; + } + location / { proxy_pass http://cvat_ui; - proxy_pass_header X-CSRFToken; - proxy_set_header Host $http_host; - proxy_pass_header Set-Cookie; } # old annotation ui, will be removed in the future. location @annotation_ui { proxy_pass http://cvat:8080; - proxy_pass_header X-CSRFToken; - proxy_set_header Host $http_host; - proxy_pass_header Set-Cookie; } } ``` From 1e17779f65c51c9acaac7c6db25179aa6d0a7fac Mon Sep 17 00:00:00 2001 From: Andrey Zhavoronkov Date: Thu, 30 Apr 2020 12:36:54 +0300 Subject: [PATCH 3/3] fixed comments --- .vscode/launch.json | 7 +------ cvat/settings/base.py | 14 -------------- cvat/settings/development.py | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 12d232b14b40..1fefab7fee5b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -37,12 +37,7 @@ ], "django": true, "cwd": "${workspaceFolder}", - "console": "internalConsole", - "env": { - "UI_SCHEME": "http", - "UI_HOST": "localhost", - "UI_PORT": "3000", - } + "console": "internalConsole" }, { "name": "server: chrome", diff --git a/cvat/settings/base.py b/cvat/settings/base.py index 4f6cd1bc58ba..7f0513a1c2e6 100644 --- a/cvat/settings/base.py +++ b/cvat/settings/base.py @@ -187,21 +187,7 @@ def generate_ssh_keys(): 'dj_pagination.middleware.PaginationMiddleware', ] -# Cross-Origin Resource Sharing settings for CVAT UI -UI_SCHEME = os.environ.get('UI_SCHEME', 'http') -UI_HOST = os.environ.get('UI_HOST') -UI_PORT = os.environ.get('UI_PORT') UI_URL = '' -if UI_HOST: - CORS_ALLOW_CREDENTIALS = True - CSRF_TRUSTED_ORIGINS = [UI_HOST] - UI_URL = '{}://{}'.format(UI_SCHEME, UI_HOST) - - if UI_PORT and UI_PORT != '80': - UI_URL += ':{}'.format(UI_PORT) - - CORS_ORIGIN_WHITELIST = [UI_URL] - CORS_REPLACE_HTTPS_REFERER = True STATICFILES_FINDERS = [ 'django.contrib.staticfiles.finders.FileSystemFinder', diff --git a/cvat/settings/development.py b/cvat/settings/development.py index 9205c8d51d7c..40e597ee682e 100644 --- a/cvat/settings/development.py +++ b/cvat/settings/development.py @@ -26,3 +26,17 @@ 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } + +# Cross-Origin Resource Sharing settings for CVAT UI +UI_SCHEME = os.environ.get('UI_SCHEME', 'http') +UI_HOST = os.environ.get('UI_HOST', 'localhost') +UI_PORT = os.environ.get('UI_PORT', 3000) +CORS_ALLOW_CREDENTIALS = True +CSRF_TRUSTED_ORIGINS = [UI_HOST] +UI_URL = '{}://{}'.format(UI_SCHEME, UI_HOST) + +if UI_PORT and UI_PORT != '80': + UI_URL += ':{}'.format(UI_PORT) + +CORS_ORIGIN_WHITELIST = [UI_URL] +CORS_REPLACE_HTTPS_REFERER = True