Skip to content

Commit 6c48ba8

Browse files
authored
Merge pull request #22 from rootcodelabs/User-authority-data
user-authority: User changes and API Authorization flows
2 parents fde0284 + 1cfdc81 commit 6c48ba8

File tree

15 files changed

+75
-137
lines changed

15 files changed

+75
-137
lines changed

DSL/Liquibase/changelog/classifier-script-v1-user-management.sql

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,13 @@ CREATE TABLE public."user_authority" (
2929
authority_name VARCHAR[] NOT NULL,
3030
created TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
3131
CONSTRAINT user_authority_pkey PRIMARY KEY (id)
32-
);
32+
);
33+
34+
-- changeset kalsara Magamage:classifier-script-v1-changeset3
35+
36+
INSERT INTO public."user" (login,password_hash,first_name,last_name,id_code,display_name,status,csa_title,csa_email)
37+
VALUES ('EE30303039914','ok','classifier','test','EE30303039914','classifier','active','Title','classifier.doe@example.com');
38+
39+
INSERT INTO public."user_authority" ( user_id, authority_name)
40+
VALUES ('EE30303039914', ARRAY['ROLE_ADMINISTRATOR', 'ROLE_MODEL_TRAINER'] );
41+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
SELECT is_connect
1+
SELECT is_connect, subscription_id
22
FROM integration_status
33
WHERE platform=:platform::platform;

DSL/Ruuter.private/DSL/GET/.guard

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ guard_success:
2424

2525
guard_fail:
2626
return: "unauthorized"
27-
status: 200
27+
status: 400
2828
next: end

DSL/Ruuter.private/DSL/GET/classifier/integration/outlook/token.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ get_refresh_token:
1414
body:
1515
platform: 'OUTLOOK'
1616
result: res
17+
next: set_refresh_token
1718

1819
set_refresh_token:
1920
assign:
20-
refresh_token: "[#OUTLOOK_REFRESH_KEY]" #${res.response.body.token}
21+
refresh_token: ${res.response.body[0].token}
2122
next: check_refresh_token
2223

2324
check_refresh_token:
@@ -26,6 +27,8 @@ check_refresh_token:
2627
next: get_access_token
2728
next: return_not_found
2829

30+
#not supported for internal requests
31+
2932
get_access_token:
3033
call: http.post
3134
args:
@@ -49,4 +52,4 @@ return_result:
4952
return_not_found:
5053
status: 404
5154
return: "refresh token not found"
52-
next: end
55+
next: end

DSL/Ruuter.private/DSL/POST/.guard

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ guard_success:
2424

2525
guard_fail:
2626
return: "unauthorized"
27-
status: 200
27+
status: 400
2828
next: end

DSL/Ruuter.private/DSL/POST/auth/.guard

Lines changed: 0 additions & 4 deletions
This file was deleted.

DSL/Ruuter.private/DSL/POST/auth/login.yml

Lines changed: 0 additions & 79 deletions
This file was deleted.

DSL/Ruuter.private/DSL/POST/classifier/integration/outlook/label.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ declaration:
1414
- field: folderId
1515
type: string
1616
description: "Body field 'folderId'"
17+
headers:
18+
- field: cookie
19+
type: string
20+
description: "Cookie field"
1721

1822
extract_request_data:
1923
assign:
@@ -31,6 +35,8 @@ get_token_info:
3135
call: http.get
3236
args:
3337
url: "[#CLASSIFIER_RUUTER_PRIVATE]/classifier/integration/outlook/token"
38+
headers:
39+
cookie: ${incoming.headers.cookie}
3440
result: res
3541
next: assign_access_token
3642

DSL/Ruuter.private/DSL/POST/classifier/integration/outlook/subscribe.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ declaration:
1111
- field: is_connect
1212
type: boolean
1313
description: "Body field 'isConnect'"
14+
headers:
15+
- field: cookie
16+
type: string
17+
description: "Cookie field"
1418

1519
extract_request_data:
1620
assign:
17-
is_connect: ${incoming.body.isConnect}
21+
is_connect: ${incoming.body.is_connect}
1822
next: get_platform_integration_status
1923

2024
get_platform_integration_status:
@@ -28,8 +32,8 @@ get_platform_integration_status:
2832

2933
assign_db_platform_integration_data:
3034
assign:
31-
db_platform_status: ${res.response.body.is_connect}
32-
subscription_id: ${res.response.body.subscription_id}
35+
db_platform_status: ${res.response.body[0].isConnect}
36+
subscription_id: ${res.response.body[0].subscriptionId}
3337
next: validate_request
3438

3539
validate_request:
@@ -41,7 +45,7 @@ validate_request:
4145
get_token_info:
4246
call: http.get
4347
args:
44-
url: "[#CLASSIFIER_RUUTER_PRIVATE]/classifier/integration/outlook/token"
48+
url: "[#CLASSIFIER_RUUTER_PRIVATE_INTERNAL]/internal/xyz"
4549
result: res
4650
next: assign_access_token
4751

@@ -52,7 +56,7 @@ assign_access_token:
5256

5357
check_integration_type:
5458
switch:
55-
- condition: ${is_connect === true && subscription_id == null}
59+
- condition: ${is_connect === true && subscription_id === null}
5660
next: subscribe_outlook
5761
- condition: ${is_connect === false && subscription_id !== null}
5862
next: unsubscribe_outlook
@@ -66,10 +70,10 @@ subscribe_outlook:
6670
Authorization: ${'Bearer ' + access_token}
6771
body:
6872
changeType: "created,updated"
69-
notificationUrl: "[#CLASSIFIER_RUUTER_PRIVATE]/classifier/integration/outlook/accept"
73+
notificationUrl: "https://f789-111-223-191-66.ngrok-free.app/classifier/integration/outlook/accept"
7074
resource: "me/mailFolders('inbox')/messages"
71-
expirationDateTime: "2024-07-02T21:10:45.9356913Z"
72-
clientState: "state"
75+
expirationDateTime: "2024-07-06T21:10:45.9356913Z"
76+
clientState: "secretClientValue"
7377
result: res_subscribe
7478
next: check_subscribe_response
7579

@@ -84,15 +88,15 @@ set_subscription_data:
8488
args:
8589
url: "[#CLASSIFIER_RESQL]/connect-platform"
8690
body:
87-
id: ${res_subscribe.response.id}
91+
id: ${res_subscribe.response.body.id}
8892
platform: 'OUTLOOK'
8993
result: set_status_res
9094
next: check_db_status
9195

9296
unsubscribe_outlook:
9397
call: http.delete
9498
args:
95-
url: "https://graph.microsoft.com/v1.0/subscriptions/${res_data.response.subscriptionId}"
99+
url: "https://graph.microsoft.com/v1.0/subscriptions/${subscription_id}"
96100
headers:
97101
Authorization: ${'Bearer ' + access_token}
98102
result: res_unsubscribe

DSL/Ruuter.private/DSL/POST/classifier/integration/toggle-platform.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ declaration:
1414
- field: platform
1515
type: string
1616
description: "Body field 'platform'"
17+
headers:
18+
- field: cookie
19+
type: string
20+
description: "Cookie field"
1721

1822
extract_request_data:
1923
assign:
2024
operation: ${incoming.body.operation}
2125
platform: ${incoming.body.platform}
26+
cookie: ${incoming.headers.cookie}
2227
next: check_operation
2328

2429
check_operation:
@@ -43,25 +48,25 @@ check_platform:
4348
switch:
4449
- condition: ${platform === 'jira'}
4550
next: assign_jira_url
46-
- condition: ${operation === 'outlook'}
51+
- condition: ${platform === 'outlook'}
4752
next: assign_outlook_url
48-
- condition: ${operation === 'pinal'}
53+
- condition: ${platform === 'pinal'}
4954
next: assign_pinal_url
5055
next: platform_not_support
5156

5257
assign_jira_url:
5358
assign:
54-
url: "jira/cloud/toggle-subscription"
59+
url: "jira/cloud/subscribe"
5560
next: route_to_platform
5661

5762
assign_outlook_url:
5863
assign:
59-
url: "outlook/toggle-subscription"
64+
url: "outlook/subscribe"
6065
next: route_to_platform
6166

6267
assign_pinal_url:
6368
assign:
64-
url: "pinal/toggle-subscription"
69+
url: "pinal/subscribe"
6570
next: route_to_platform
6671

6772
route_to_platform:
@@ -70,6 +75,7 @@ route_to_platform:
7075
url: "[#CLASSIFIER_RUUTER_PRIVATE]/classifier/integration/${url}"
7176
headers:
7277
type: json
78+
cookie: ${cookie}
7379
body:
7480
is_connect: ${is_connect}
7581
result: res

DSL/Ruuter.private/DSL/TEMPLATES/check-user-authority.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ check_cookie_info_response:
3131

3232
check_user_authority:
3333
switch:
34-
- condition: ${res.response.body.authorities.includes("ROLE_ADMINISTRATOR") || res.response.body.authorities.includes("ROLE_ANALYST")}
34+
- condition: ${res.response.body.authorities.includes("ROLE_ADMINISTRATOR") || res.response.body.authorities.includes("ROLE_MODEL_TRAINER")}
3535
next: return_authorized
3636
next: return_unauthorized
3737

DSL/Ruuter.public/DSL/POST/auth/login.yml

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,16 @@ declaration:
55
method: post
66
accepts: json
77
returns: json
8-
namespace: backoffice
8+
namespace: classifier
99
allowlist:
1010
body:
1111
- field: login
1212
type: string
1313
description: "Body field 'login'"
1414
- field: password
15-
type: stringDSL/Ruuter.public/DSL/POST/login.yml
15+
type: string
1616
description: "Body field 'password'"
1717

18-
getIsPasswordAuthEnabled:
19-
assign:
20-
isPasswordAuthEnabled: "[#PASSWORD_AUTH_ENABLED]"
21-
22-
checkPasswordLoginEnabled:
23-
switch:
24-
- condition: ${isPasswordAuthEnabled === true || isPasswordAuthEnabled.toLowerCase() === "true"}
25-
next: extractRequestData
26-
next: return_password_login_disabled
27-
2818
extractRequestData:
2919
assign:
3020
login: ${incoming.body.login}
@@ -34,7 +24,7 @@ extractRequestData:
3424
getUserWithRole:
3525
call: http.post
3626
args:
37-
url: "[#CHATBOT_RESQL]/get-user-with-roles"
27+
url: "[#CLASSIFIER_RESQL]/get-user-with-roles"
3828
body:
3929
login: ${login}
4030
password: ${password}
@@ -50,7 +40,7 @@ check_user_result:
5040
get_session_length:
5141
call: http.post
5242
args:
53-
url: "[#CHATBOT_RESQL]/get-configuration"
43+
url: "[#CLASSIFIER_RESQL]/get-configuration"
5444
body:
5545
key: "session_length"
5646
result: session_result
@@ -59,7 +49,7 @@ get_session_length:
5949
generate_cookie:
6050
call: http.post
6151
args:
62-
url: "[#CHATBOT_TIM]/jwt/custom-jwt-generate"
52+
url: "[#CLASSIFIER_TIM]/jwt/custom-jwt-generate"
6353
body:
6454
JWTName: "customJwtCookie"
6555
expirationInMinutes: ${session_result.response.body[0]?.value ?? '120'}
@@ -75,18 +65,6 @@ assign_cookie:
7565
Secure: true
7666
HttpOnly: true
7767
SameSite: "Lax"
78-
next: setCustomerSupportAgentAway
79-
80-
setCustomerSupportAgentAway:
81-
call: http.post
82-
args:
83-
url: "[#CHATBOT_RESQL]/set-customer-support-status"
84-
body:
85-
active: false
86-
userIdCode: ${login}
87-
created: ${new Date().toISOString()}
88-
status: "offline"
89-
result: setCustomerSupportAgentAwayResult
9068
next: return_value
9169

9270
return_value:
@@ -99,8 +77,3 @@ return_user_not_found:
9977
status: 400
10078
return: "User Not Found"
10179
next: end
102-
103-
return_password_login_disabled:
104-
status: 400
105-
return: "Password login is disabled"
106-
next: end

0 commit comments

Comments
 (0)