From 69d2a50e2e58d0c14f9904e5eafaaa2fcdf38c60 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Dutta Date: Fri, 19 May 2023 17:33:22 +0530 Subject: [PATCH] sulu: 2.2.1 --- sulu/sulu-base/Makefile | 4 +-- sulu/sulu-builder/Makefile | 4 +-- sulu/sulu-builder/files/etc/config/sulu | 1 + .../files/etc/sulu/nginx.locations | 7 ++--- sulu/sulu-builder/files/etc/sulu/sulu.sh | 30 +++++++++++++------ 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/sulu/sulu-base/Makefile b/sulu/sulu-base/Makefile index 0f96107e4..cd11977c4 100644 --- a/sulu/sulu-base/Makefile +++ b/sulu/sulu-base/Makefile @@ -5,11 +5,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sulu-base -PKG_VERSION:=2.2.0 +PKG_VERSION:=2.2.1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://dev.iopsys.eu/websdk/sulu.git -PKG_SOURCE_VERSION:=1edef130673d186c9ffe030b9a1a3614974c1fad +PKG_SOURCE_VERSION:=c10972cca9b1938738dc45846f33545d1c7dcbdc PKG_MIRROR_HASH:=skip SULU_MOD:=core diff --git a/sulu/sulu-builder/Makefile b/sulu/sulu-builder/Makefile index 2bc7dd172..c20b18486 100644 --- a/sulu/sulu-builder/Makefile +++ b/sulu/sulu-builder/Makefile @@ -5,12 +5,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sulu-builder -PKG_VERSION:=2.2.0 +PKG_VERSION:=2.2.1 PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://dev.iopsys.eu/websdk/sulu-builder.git -PKG_SOURCE_VERSION:=8797cb3efffdfac3d27a6d665f271b13d07d8335 +PKG_SOURCE_VERSION:=926a1c05140ce321058ae586a5f3b7e232571a13 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_SOURCE_VERSION) PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz PKG_BUILD_DIR:=$(BUILD_DIR)/sulu-$(PKG_VERSION)/sulu-builder-$(PKG_SOURCE_VERSION) diff --git a/sulu/sulu-builder/files/etc/config/sulu b/sulu/sulu-builder/files/etc/config/sulu index 9aadabf67..e66b38434 100644 --- a/sulu/sulu-builder/files/etc/config/sulu +++ b/sulu/sulu-builder/files/etc/config/sulu @@ -1,4 +1,5 @@ config global 'global' option role_based_access '1' + option SessionMode 'Require' list user 'admin' list user 'user' diff --git a/sulu/sulu-builder/files/etc/sulu/nginx.locations b/sulu/sulu-builder/files/etc/sulu/nginx.locations index 1b2d0b542..223da29ac 100644 --- a/sulu/sulu-builder/files/etc/sulu/nginx.locations +++ b/sulu/sulu-builder/files/etc/sulu/nginx.locations @@ -8,7 +8,7 @@ location /sitemap.xml { return 200 "User-agent: *\nDisallow: /\n"; } -location /ws { +location /wss { proxy_pass_request_headers on; proxy_cache off; proxy_http_version 1.1; @@ -29,13 +29,11 @@ location /ws { location / { autoindex on; - expires -1; if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,Content-Type,Range'; - add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; @@ -45,6 +43,7 @@ location / { add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,Content-Type,Range' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; - add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; } + expires -1; + add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; } diff --git a/sulu/sulu-builder/files/etc/sulu/sulu.sh b/sulu/sulu-builder/files/etc/sulu/sulu.sh index 467550f22..766c81313 100644 --- a/sulu/sulu-builder/files/etc/sulu/sulu.sh +++ b/sulu/sulu-builder/files/etc/sulu/sulu.sh @@ -53,6 +53,11 @@ function _get_sulu_root() echo "${root:-/sulu}" } +function _get_sulu_session_mode() +{ + echo "$(uci -q get sulu.global.SessionMode)" +} + function _get_usp_upstream_port() { local port @@ -94,10 +99,11 @@ function update_nginx_template() function generate_sulu_conn_config() { - local rbac users SCONFIG + local rbac users SCONFIG session rbac="${1}" users="$(_get_sulu_users)" + session="$(_get_sulu_session_mode)" SCONFIG="$(_get_sulu_root)/config/connectionConfig.json" json_init; @@ -110,8 +116,12 @@ function generate_sulu_conn_config() json_add_object 'rbac'; json_add_string 'toId' "$(_get_endpoint_id)"; json_add_int 'port' "$(_get_sulu_tls_port)"; - json_add_string 'path' "/ws"; - json_add_boolean 'useSession' 1; + json_add_string 'path' "/wss"; + + if [ "${session}" = "Require" ]; then + json_add_boolean 'useSession' 1; + fi + json_add_string 'protocol' 'wss'; json_add_array 'auth'; json_close_array; @@ -132,7 +142,7 @@ function generate_sulu_conn_config() json_add_string 'fromId' 'proto::interop-usp-controller'; json_add_string 'toId' "$(_get_endpoint_id)"; json_add_int 'port' "$(_get_sulu_tls_port)"; - json_add_string 'path' "/ws"; + json_add_string 'path' "/wss"; json_add_string 'protocol' 'wss'; json_add_string 'publishEndpoint' "/usp/endpoint"; json_add_string 'subscribeEndpoint' "/usp/controller"; @@ -210,7 +220,7 @@ function _update_obuspa_config() function _remove_obuspa_config() { - local restart + local restart session restart=0 if [ "$(uci_get obuspa localmqtt)" == "mqtt" ]; then @@ -229,10 +239,11 @@ function _remove_obuspa_config() } function _update_obuspa_config_rbac() { - local agent users restart + local agent users restart session agent="$(_get_agent_id)" users="$(_get_sulu_users)" + session="$(_get_sulu_session_mode)" restart=0 for f in ${users}; do @@ -267,11 +278,12 @@ function _update_obuspa_config_rbac() { uci_set obuspa ${sec} Topic "/usp/${agent}/${f}/controller" uci_set obuspa ${sec} mqtt "mqtt_sulu_$f" uci_set obuspa ${sec} assigned_role_name "$f" - uci_set obuspa ${sec} SessionMode "Require" restart=1 fi - if ! uci_get obuspa ${sec} SessionMode >/dev/null 2>&1; then - uci_set obuspa ${sec} SessionMode "Require" + + obMode="$(uci_get obuspa ${sec} SessionMode)" + if [ "${session}" != "${obMode}" ]; then + uci_set obuspa ${sec} SessionMode "${session}" restart=1 fi done