Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding project layer to repos #403

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions DSL/Resql/analytics/POST/get-new-nonce.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO request_nonces (valid_until) VALUES ( now() + interval '1 day') RETURNING nonce;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
INSERT INTO user_page_preferences (user_id, page_name, page_results,created)
VALUES (:user_id, :page_name, :page_results,:created::timestamp with time zone);
VALUES (:user_id, :page_name, :page_results,:created::timestamp with time zone);
1 change: 1 addition & 0 deletions DSL/Resql/analytics/POST/use-nonce.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
update request_nonces set used_at = now() where nonce = :updated_nonce and used_at is null returning nonce;
28 changes: 0 additions & 28 deletions DSL/Ruuter/GET/.guard

This file was deleted.

28 changes: 0 additions & 28 deletions DSL/Ruuter/POST/.guard

This file was deleted.

61 changes: 61 additions & 0 deletions DSL/Ruuter/analytics/GET/.guard
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
process_request:
switch:
- condition: ${ incoming.headers['x-ruuter-nonce'] != null }
next: verify_header_nonce
- condition: ${ incoming.params['ruuter-nonce'] != null }
next: verify_param_nonce
- condition: ${incoming.headers == null || incoming.headers.cookie == null}
next: guard_fail
next: authenticate

verify_header_nonce:
call: http.post
args:
url: "[#ANALYTICS_RESQL]/use-nonce"
body:
updated_nonce: ${incoming.headers['x-ruuter-nonce']}
result: nonce_response
next: check_inline

verify_param_nonce:
call: http.post
args:
url: "[#ANALYTICS_RESQL]/use-nonce"
body:
updated_nonce: ${incoming.params['ruuter-nonce']}
result: nonce_response
next: check_inline

check_inline:
inline: extAuth
result: extauth

check_nonce:
switch:
- condition: ${ !extauth || (nonce_response.response.body[0] == null) }
next: guard_fail
next: guard_success

authenticate:
template: "[#ANALYTICS_PROJECT_LAYER]/check-user-authority"
requestType: templates
headers:
cookie: ${incoming.headers.cookie}
result: authority_result
next: check_authority_result

check_authority_result:
switch:
- condition: ${authority_result !== "false"}
next: guard_success
next: guard_fail

guard_success:
return: "success"
status: 200
next: end

guard_fail:
return: "unauthorized"
status: 403
next: end
File renamed without changes.
File renamed without changes.
61 changes: 61 additions & 0 deletions DSL/Ruuter/analytics/POST/.guard
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
process_request:
switch:
- condition: ${ incoming.headers['x-ruuter-nonce'] != null }
next: verify_header_nonce
- condition: ${ incoming.params['ruuter-nonce'] != null }
next: verify_param_nonce
- condition: ${incoming.headers == null || incoming.headers.cookie == null}
next: guard_fail
next: authenticate

verify_header_nonce:
call: http.post
args:
url: "[#ANALYTICS_RESQL]/use-nonce"
body:
updated_nonce: ${incoming.headers['x-ruuter-nonce']}
result: nonce_response
next: check_inline

verify_param_nonce:
call: http.post
args:
url: "[#ANALYTICS_RESQL]/use-nonce"
body:
updated_nonce: ${incoming.params['ruuter-nonce']}
result: nonce_response
next: check_inline

check_inline:
inline: extAuth
result: extauth

check_nonce:
switch:
- condition: ${ !extauth || (nonce_response.response.body[0] == null) }
next: guard_fail
next: guard_success

authenticate:
template: "[#ANALYTICS_PROJECT_LAYER]/check-user-authority"
requestType: templates
headers:
cookie: ${incoming.headers.cookie}
result: authority_result
next: check_authority_result

check_authority_result:
switch:
- condition: ${authority_result !== "false"}
next: guard_success
next: guard_fail

guard_success:
return: "success"
status: 200
next: end

guard_fail:
return: "unauthorized"
status: 403
next: end
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ all_csas_away_for_total:
get_total:
call: http.post
args:
url: "[#ANALYTICS_DMAPPER]/hbs/analytics/merge-arrays"
url: "[#ANALYTICS_DMAPPER_HBS]/merge-arrays"
headers:
type: 'json'
body:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ check_for_required_parameters:
get_csv:
call: http.post
args:
url: "[#ANALYTICS_DMAPPER]/hbs/analytics/get-csv"
url: "[#ANALYTICS_DMAPPER_HBS]/get-csv"
headers:
type: 'csv'
body:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ get_metrics:
convert_data:
call: http.post
args:
url: "[#ANALYTICS_DMAPPER]/hbs/analytics/get-metric-rows"
url: "[#ANALYTICS_DMAPPER_HBS]/get-metric-rows"
headers:
type: "json"
body:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ get_metrics:
convert_data:
call: http.post
args:
url: "[#ANALYTICS_DMAPPER]/hbs/analytics/array-to-object"
url: "[#ANALYTICS_DMAPPER_HBS]/array-to-object"
headers:
type: "json"
body:
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions GUI/.env.development
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
REACT_APP_API_URL=http://localhost:8080
REACT_APP_RUUTER_API_URL=http://localhost:8080
REACT_APP_RUUTER_V2_ANALYTICS_API_URL=http://localhost:8080
REACT_APP_API_URL=http://localhost:8080/analytics
REACT_APP_RUUTER_API_URL=http://localhost:8080/analytics
REACT_APP_RUUTER_V2_ANALYTICS_API_URL=http://localhost:8080/analytics
REACT_APP_OPENSEARCH_DASHBOARD_URL=https://opensearch.org/
REACT_APP_OPENDATAPORT_URL=https://avaandmed.eesti.ee
REACT_APP_MENU_URL=https://admin.dev.buerokratt.ee
Expand All @@ -9,8 +9,8 @@ REACT_APP_APP_PORT=3001
REACT_APP_NOTIFICATION_NODE_URL=http://localhost:4040
REACT_APP_LOCAL=true
REACT_APP_BASE_API_PATH=/al
REACT_APP_AUTH_BASE_URL=http://localhost:8080
REACT_APP_DOCKER_RUUTER=http://ruuter:8080
REACT_APP_AUTH_BASE_URL=http://localhost:8080/analytics
REACT_APP_DOCKER_RUUTER=http://ruuter:8080/analytics
REACT_APP_CUSTOMER_SERVICE_LOGIN=http://localhost:3004/et/dev-auth
REACT_APP_CONVERSATIONS_BASE_URL=http://localhost:8080/chat
REACT_APP_TRAINING_BASE_URL=http://localhost:8080/training
Expand All @@ -19,7 +19,7 @@ REACT_APP_SERVICES_BASE_URL=http://localhost:8080/services
REACT_APP_SETTINGS_BASE_URL=http://localhost:8080/settings
REACT_APP_MONITORING_BASE_URL=http://localhost:8080/monitoring
REACT_APP_SERVICE_ID=analytics
REACT_APP_RUUTER_PRIVATE_API_URL=http://localhost:8080
REACT_APP_RUUTER_PRIVATE_API_URL=http://localhost:8080/analytics
REACT_APP_CSP="upgrade-insecure-requests; default-src 'self'; font-src 'self' data:; img-src 'self' data:; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; object-src 'none'; connect-src 'self' http://localhost:8080 http://localhost:8085 https://admin.dev.buerokratt.ee/chat/menu.json;"
REACT_APP_ENABLE_HIDDEN_FEATURES=TRUE
REACT_APP_MENU_JSON=[{"id":"conversations","label":{"et":"Vestlused","en":"Conversations"},"path":"/chat","children":[{"label":{"et":"Vastamata","en":"Unanswered"},"path":"/unanswered"},{"label":{"et":"Aktiivsed","en":"Active"},"path":"/active"},{"label":{"et":"Ootel","en":"Pending"},"path":"/pending"},{"label":{"et":"Ajalugu","en":"History"},"path":"/history"}]},{"id":"training","label":{"et":"Treening","en":"Training"},"path":"/training","children":[{"label":{"et":"Treening","en":"Training"},"path":"/training","children":[{"label":{"et":"Teemad","en":"Themes"},"path":"/training/intents"},{"label":{"et":"Avalikud teemad","en":"Public themes"},"path":"/training/common-intents"},{"label":{"et":"Teemade järeltreenimine","en":"Post training themes"},"path":"/training/intents-followup-training"},{"label":{"et":"Vastused","en":"Answers"},"path":"/training/responses"},{"label":{"et":"Reeglid","en":"Rules"},"path":"/training/rules"},{"label":{"et":"Konfiguratsioon","en":"Configuration"},"path":"/training/configuration"},{"label":{"et":"Vormid","en":"Forms"},"path":"/training/forms"},{"label":{"et":"Mälukohad","en":"Slots"},"path":"/training/slots"},{"label":{"et":"Automatic Teenused","en":"Automatic Services"},"path":"/auto-services"}]},{"label":{"et":"Ajaloolised vestlused","en":"Historical conversations"},"path":"/history","children":[{"label":{"et":"Ajalugu","en":"History"},"path":"/history/history"},{"label":{"et":"Pöördumised","en":"Appeals"},"path":"/history/appeal"}]},{"label":{"et":"Mudelipank ja analüütika","en":"Modelbank and analytics"},"path":"/analytics","children":[{"label":{"et":"Teemade ülevaade","en":"Overview of topics"},"path":"/analytics/overview"},{"label":{"et":"Mudelite võrdlus","en":"Comparison of models"},"path":"/analytics/models"},{"label":{"et":"Testlood","en":"testTracks"},"path":"/analytics/testcases"}]},{"label":{"et":"Treeni uus mudel","en":"Train new model"},"path":"/train-new-model"}]},{"id":"analytics","label":{"et":"Analüütika","en":"Analytics"},"path":"/analytics","children":[{"label":{"et":"Ülevaade","en":"Overview"},"path":"/overview"},{"label":{"et":"Vestlused","en":"Chats"},"path":"/chats"},{"label":{"et":"Tagasiside","en":"Feedback"},"path":"/feedback"},{"label":{"et":"Nõustajad","en":"Advisors"},"path":"/advisors"},{"label":{"et":"Avaandmed","en":"Reports"},"path":"/reports"}]},{"id":"services","label":{"et":"Teenused","en":"Services"},"path":"/services","children":[{"label":{"et":"Ülevaade","en":"Overview"},"path":"/overview"},{"label":{"et":"Uus teenus","en":"New Service"},"path":"/newService"},{"label":{"et":"Automatic Teenused","en":"Automatic Services"},"path":"/auto-services"},{"label":{"et":"Probleemsed teenused","en":"Faulty Services"},"path":"/faultyServices"}]},{"id":"settings","label":{"et":"Haldus","en":"Administration"},"path":"/settings","children":[{"label":{"et":"Kasutajad","en":"Users"},"path":"/users"},{"label":{"et":"Vestlusbot","en":"Chatbot"},"path":"/chatbot","children":[{"label":{"et":"Seaded","en":"Settings"},"path":"/chatbot/settings"},{"label":{"et":"Tervitussõnum","en":"Welcome message"},"path":"/chatbot/welcome-message"},{"label":{"et":"Välimus ja käitumine","en":"Appearance and behavior"},"path":"/chatbot/appearance"},{"label":{"et":"Erakorralised teated","en":"Emergency notices"},"path":"/chatbot/emergency-notices"}]},{"label":{"et":"Asutuse tööaeg","en":"Office opening hours"},"path":"/working-time"},{"label":{"et":"Sessiooni pikkus","en":"Session length"},"path":"/session-length"}]},{"id":"monitoring","label":{"et":"Seire","en":"Monitoring"},"path":"/monitoring","children":[{"label":{"et":"Aktiivaeg","en":"Working hours"},"path":"/uptime"}]}]
8 changes: 6 additions & 2 deletions constants.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[DSL]

ANALYTICS_RESQL=http://resql:8082
ANALYTICS_RESQL=http://resql:8082/analytics

ANALYTICS_RUUTER=http://ruuter:8080
ANALYTICS_RUUTER=http://ruuter:8080/analytics

ANALYTICS_DMAPPER=http://dmapper:3000

ANALYTICS_DMAPPER_HBS=http://dmapper:3000/hbs/analytics

ANALYTICS_PROJECT_LAYER=analytics

ANALYTICS_OPEN_DATA_SERVICE=https://avaandmed.eesti.ee

ANALYTICS_TIM=http://tim:8085
Expand Down
19 changes: 10 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
- application.logging.displayRequestContent=true
- application.logging.displayResponseContent=true
- application.logging.printStackTrace=true
- application.internalRequests.disabled=true
volumes:
- ./DSL/Ruuter:/DSL
- ./constants.ini:/app/constants.ini
Expand All @@ -34,7 +35,7 @@ services:
ports:
- 8082:8082
volumes:
- ./DSL/Resql:/workspace/app/templates/byk
- ./DSL/Resql:/DSL
networks:
- bykstack

Expand All @@ -57,20 +58,20 @@ services:
environment:
- NODE_ENV=development
- CHOKIDAR_USEPOLLING=true
- REACT_APP_API_URL=http://localhost:8080
- REACT_APP_API_URL=http://localhost:8080/analytics
- REACT_APP_OPENSEARCH_DASHBOARD_URL=https://opensearch.org/
- REACT_APP_OPENDATAPORT_URL=https://avaandmed.eesti.ee
- REACT_APP_RUUTER_API_URL=http://localhost:8080
- REACT_APP_RUUTER_V2_ANALYTICS_API_URL=http://localhost:8080
- REACT_APP_RUUTER_API_URL=http://localhost:8080/analytics
- REACT_APP_RUUTER_V2_ANALYTICS_API_URL=http://localhost:8080/analytics
- REACT_APP_MENU_URL=https://admin.dev.buerokratt.ee
- REACT_APP_MENU_PATH=/chat/menu.json
- REACT_APP_AUTH_BASE_URL=http://localhost:8080
- REACT_APP_AUTH_BASE_URL=http://localhost:8080/analytics
- REACT_APP_APP_PORT=3001
- REACT_APP_LOCAL=true
- REACT_APP_BASE_API_PATH=/
- PORT=3001
- REACT_APP_RUUTER_PRIVATE_API_URL=http://localhost:8080
- REACT_APP_DOCKER_RUUTER=http://ruuter:8080
- REACT_APP_RUUTER_PRIVATE_API_URL=http://localhost:8080/analytics
- REACT_APP_DOCKER_RUUTER=http://ruuter:8080/analytics
- REACT_APP_CUSTOMER_SERVICE_LOGIN=http://localhost:3004/et/dev-auth
- REACT_APP_CONVERSATIONS_BASE_URL=http://localhost:8080/chat
- REACT_APP_TRAINING_BASE_URL=http://localhost:8080/training
Expand Down Expand Up @@ -102,8 +103,8 @@ services:
image: data-mapper
volumes:
- ./DSL:/data
- ./DSL/DMapper/hbs:/workspace/app/views/analytics
- ./DSL/DMapper/js:/workspace/app/js/analytics
- ./DSL/DMapper/analytics/hbs:/workspace/app/views/analytics
- ./DSL/DMapper/analytics/js:/workspace/app/js/analytics
environment:
- PORT=3000
- CONTENT_FOLDER=/data
Expand Down