@blazedpath/commons 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/blz-rds-postgres/syntaxis.json +1 -1
- package/blz-security/__test__/AuthorizationKpn.yaml +116 -17
- package/blz-security/__test__/secureUrl.test.js +2 -2
- package/blz-security/doc/README.md +3 -3
- package/blz-security/lab/index.js +11 -4
- package/blz-security/middleware/HapiServerAzureAd.js +3 -2
- package/blz-security/middleware/HapiServerKeycloak.js +5 -7
- package/blz-security/middleware/hapiServer.js +2 -1
- package/blz-security/secureUrlService.js +1 -2
- package/package.json +10 -5
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"addMonths": "%1$s + %2$s * INTERVAL '1 MONTH'",
|
|
36
36
|
"addSeconds": "%1$s + %2$s * INTERVAL '1 SECOND'",
|
|
37
37
|
"addYears": "%1$s + %2$s * INTERVAL '1 YEAR'",
|
|
38
|
-
"date": "
|
|
38
|
+
"date": "TO_DATE('%1$s-%2$s-%3$s', 'YYYY-MM-DD')",
|
|
39
39
|
"dateDiff": "DATE_PART('day', (%1$s) - (%2$s))",
|
|
40
40
|
"datetime": "TO_TIMESTAMP('%1$s-%2$s-%3$s %4$s:%5$s:%6$s', 'YYYY-MM-DD HH24:MI:SS')",
|
|
41
41
|
"datetimeDiff": "(((DATE_PART('day', %1$s - %2$s) * 24 + DATE_PART('hour', %1$s - %2$s)) * 60 + DATE_PART('minute', %1$s - %2$s)) * 60 + DATE_PART('second', %1$s - %2$s)) * 1000",
|
|
@@ -98,8 +98,6 @@ permissions:
|
|
|
98
98
|
enable: false
|
|
99
99
|
- path: customer-message
|
|
100
100
|
enable: false
|
|
101
|
-
- path: /debtor/**
|
|
102
|
-
enable: false
|
|
103
101
|
- path: /debtor-account-stage/**
|
|
104
102
|
enable: false
|
|
105
103
|
- path: debtor-account-stage
|
|
@@ -110,6 +108,8 @@ permissions:
|
|
|
110
108
|
enable: false
|
|
111
109
|
- path: /debtors/**
|
|
112
110
|
enable: false
|
|
111
|
+
- path: /debtor/**
|
|
112
|
+
enable: false
|
|
113
113
|
- path: /dim-messages/**
|
|
114
114
|
enable: false
|
|
115
115
|
- path: /dim-messages-entity/**
|
|
@@ -462,20 +462,20 @@ permissions:
|
|
|
462
462
|
|
|
463
463
|
# region Consumer Costumer Widgets Rules
|
|
464
464
|
# Filters (Alphabetic Order List, this rule will be disabled in all roles always)
|
|
465
|
-
- path: /
|
|
465
|
+
- path: /debtor/**
|
|
466
466
|
actions: filters_AlphabeticOrderList
|
|
467
467
|
enable: false
|
|
468
468
|
|
|
469
469
|
# Body - 360 Cards
|
|
470
|
-
- path: /
|
|
470
|
+
- path: /debtor/**
|
|
471
471
|
actions: cc_depositAccountCard
|
|
472
472
|
enable: false
|
|
473
473
|
|
|
474
|
-
- path: /
|
|
474
|
+
- path: /debtor/**
|
|
475
475
|
actions: cc_creditDisputeCard
|
|
476
476
|
enable: false
|
|
477
477
|
|
|
478
|
-
- path: /
|
|
478
|
+
- path: /debtor/**
|
|
479
479
|
actions: cc_settlementDiscountCard
|
|
480
480
|
enable: false
|
|
481
481
|
|
|
@@ -563,18 +563,48 @@ permissions:
|
|
|
563
563
|
# region Business Customer
|
|
564
564
|
|
|
565
565
|
# Body - 360 Cards
|
|
566
|
-
- path: /
|
|
566
|
+
- path: /debtor/**
|
|
567
567
|
actions: bc_depositAccountCard
|
|
568
568
|
enable: false
|
|
569
569
|
|
|
570
|
-
- path: /
|
|
570
|
+
- path: /debtor/**
|
|
571
571
|
actions: bc_creditDisputeCard
|
|
572
572
|
enable: false
|
|
573
573
|
|
|
574
|
-
- path: /
|
|
574
|
+
- path: /debtor/**
|
|
575
575
|
actions: bc_settlementDiscountCard
|
|
576
576
|
enable: false
|
|
577
577
|
|
|
578
|
+
- path: /debtor/**
|
|
579
|
+
actions: cc_cancelPaymentArrangement
|
|
580
|
+
enable: false
|
|
581
|
+
|
|
582
|
+
- path: /debtor/**
|
|
583
|
+
actions: cc_rejectDispute
|
|
584
|
+
enable: false
|
|
585
|
+
|
|
586
|
+
- path: /debtor/**
|
|
587
|
+
actions: cc_resolveDispute
|
|
588
|
+
enable: false
|
|
589
|
+
|
|
590
|
+
- path: /debtor/**
|
|
591
|
+
actions: cc_updateExemption
|
|
592
|
+
enable: false
|
|
593
|
+
|
|
594
|
+
- path: /debtor/**
|
|
595
|
+
actions: cc_editOldTrustee
|
|
596
|
+
enable: false
|
|
597
|
+
|
|
598
|
+
- path: /debtor/**
|
|
599
|
+
actions: cc_editNewTrustee
|
|
600
|
+
enable: false
|
|
601
|
+
|
|
602
|
+
# Dunning debtor option
|
|
603
|
+
|
|
604
|
+
- path: /debtor/**
|
|
605
|
+
actions: dunning_CreateFinancingAgreement,dunming_ReallocateTransaction
|
|
606
|
+
enable: false
|
|
607
|
+
|
|
578
608
|
# Dunning screen
|
|
579
609
|
- path: /dunning/**
|
|
580
610
|
actions: bc_dunningSuspendAccount
|
|
@@ -705,23 +735,27 @@ permissions:
|
|
|
705
735
|
# Home Rules
|
|
706
736
|
- name: agent_home
|
|
707
737
|
rules:
|
|
708
|
-
- path: /collection-home
|
|
738
|
+
- path: /collection-home
|
|
709
739
|
domain: agent
|
|
740
|
+
# Agent View Only
|
|
741
|
+
- name: agent_viewOnly
|
|
742
|
+
rules:
|
|
743
|
+
- path: /colm/**
|
|
744
|
+
- path: /debtors
|
|
745
|
+
domain: agent
|
|
710
746
|
# Consumer Costumer Rules
|
|
711
747
|
- name: agent_consumer_costumer
|
|
748
|
+
extends:
|
|
749
|
+
- agent_viewOnly
|
|
712
750
|
rules:
|
|
713
751
|
- path: consumer-debtor
|
|
714
752
|
- path: /debtors
|
|
715
753
|
- path: /debtor/**
|
|
716
754
|
domain: agent
|
|
717
|
-
- name: agent_viewOnly
|
|
718
|
-
rules:
|
|
719
|
-
- path: /colm/**
|
|
720
|
-
domain: agent
|
|
721
755
|
# 360 View
|
|
722
756
|
- name: agent_consumer_costumer_360View_settlementDiscountCard
|
|
723
757
|
rules:
|
|
724
|
-
- path: /
|
|
758
|
+
- path: /debtor/**
|
|
725
759
|
actions: cc_settlementDiscountCard
|
|
726
760
|
enable: true
|
|
727
761
|
domain: agent
|
|
@@ -793,17 +827,71 @@ permissions:
|
|
|
793
827
|
rules:
|
|
794
828
|
- path: organization-debtor
|
|
795
829
|
- path: /debtors
|
|
796
|
-
- path: /debtor/**
|
|
830
|
+
# - path: /debtor/**
|
|
797
831
|
domain: agent
|
|
798
832
|
|
|
799
833
|
# 360 View
|
|
800
834
|
- name: agent_business_costumer_360View_settlementDiscountCard
|
|
801
835
|
rules:
|
|
802
|
-
- path: /
|
|
836
|
+
- path: /debtor/**
|
|
803
837
|
actions: bc_settlementDiscountCard
|
|
804
838
|
enable: true
|
|
805
839
|
domain: agent
|
|
806
840
|
|
|
841
|
+
- name: agent_business_costumer_360View_cancelPaymentArrangement
|
|
842
|
+
rules:
|
|
843
|
+
- path: /debtor/**
|
|
844
|
+
actions: cc_cancelPaymentArrangement
|
|
845
|
+
enable: true
|
|
846
|
+
domain: agent
|
|
847
|
+
|
|
848
|
+
- name: agent_business_costumer_360View_resolveDispute
|
|
849
|
+
rules:
|
|
850
|
+
- path: /debtor/**
|
|
851
|
+
actions: cc_cc_resolveDispute
|
|
852
|
+
enable: true
|
|
853
|
+
domain: agent
|
|
854
|
+
|
|
855
|
+
- name: agent_business_costumer_360View_rejectDispute
|
|
856
|
+
rules:
|
|
857
|
+
- path: /debtor/**
|
|
858
|
+
actions: cc_rejectDispute
|
|
859
|
+
enable: true
|
|
860
|
+
domain: agent
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
- name: agent_business_costumer_360View_updateExemption
|
|
864
|
+
rules:
|
|
865
|
+
- path: /debtor/**
|
|
866
|
+
actions: cc_updateExemption
|
|
867
|
+
enable: true
|
|
868
|
+
domain: agent
|
|
869
|
+
|
|
870
|
+
- name: agent_business_costumer_360View_editNewTrustee
|
|
871
|
+
rules:
|
|
872
|
+
- path: /debtor/**
|
|
873
|
+
actions: cc_editNewTrustee
|
|
874
|
+
enable: true
|
|
875
|
+
domain: agent
|
|
876
|
+
|
|
877
|
+
- name: agent_business_costumer_360View_cc_editOldTrustee
|
|
878
|
+
rules:
|
|
879
|
+
- path: /debtor/**
|
|
880
|
+
actions: cc_editOldTrustee
|
|
881
|
+
enable: true
|
|
882
|
+
domain: agent
|
|
883
|
+
|
|
884
|
+
- name: agent_business_costumer_360View_dunning_CreateFinancingAgreement
|
|
885
|
+
rules:
|
|
886
|
+
- path: /debtor/**
|
|
887
|
+
actions: dunning_CreateFinancingAgreement
|
|
888
|
+
domain: agent
|
|
889
|
+
- name: agent_business_costumer_360View_dunming_ReallocateTransaction
|
|
890
|
+
rules:
|
|
891
|
+
- path: /debtor/**
|
|
892
|
+
actions: dunming_ReallocateTransaction
|
|
893
|
+
domain: agent
|
|
894
|
+
|
|
807
895
|
# Dunning screen
|
|
808
896
|
- name: agent_business_costumer_dunning_SuspendAccountCard
|
|
809
897
|
rules:
|
|
@@ -950,6 +1038,8 @@ permissions:
|
|
|
950
1038
|
actions: GET
|
|
951
1039
|
- path: /api/ms-operation-scheduler/**
|
|
952
1040
|
actions: GET
|
|
1041
|
+
- path: /api/ms-placement/**
|
|
1042
|
+
actions: GET
|
|
953
1043
|
- path: /api/bkr-ext/**
|
|
954
1044
|
actions: GET
|
|
955
1045
|
domain: agent
|
|
@@ -1001,6 +1091,7 @@ roles:
|
|
|
1001
1091
|
- name: Collections.ViewOnly
|
|
1002
1092
|
permissions:
|
|
1003
1093
|
- agent_home
|
|
1094
|
+
- agent_viewOnly
|
|
1004
1095
|
- agent_consumer_costumer
|
|
1005
1096
|
- agent_business_costumer
|
|
1006
1097
|
- agent_viewonly_portal_apis
|
|
@@ -1011,6 +1102,14 @@ roles:
|
|
|
1011
1102
|
- agent_task_management
|
|
1012
1103
|
- agent_entry_process
|
|
1013
1104
|
- agent_portal_apis
|
|
1105
|
+
- agent_business_costumer_360View_cancelPaymentArrangement
|
|
1106
|
+
- agent_business_costumer_360View_resolveDispute
|
|
1107
|
+
- agent_business_costumer_360View_rejectDispute
|
|
1108
|
+
- agent_business_costumer_360View_updateExemption
|
|
1109
|
+
- agent_business_costumer_360View_editOldTrustee
|
|
1110
|
+
- agent_business_costumer_360View_editNewTrustee
|
|
1111
|
+
- agent_business_costumer_360View_dunning_CreateFinancingAgreement
|
|
1112
|
+
- agent_business_costumer_360View_dunming_ReallocateTransaction
|
|
1014
1113
|
- name: Collections.FinanceBV
|
|
1015
1114
|
extends:
|
|
1016
1115
|
- Collections.ViewOnly
|
|
@@ -42,7 +42,7 @@ describe('SecureUrlService', () => {
|
|
|
42
42
|
} catch (error) {
|
|
43
43
|
expect(error.message).toBe('The token has expired.');
|
|
44
44
|
expect(error.name).toBe('SecureUrlError');
|
|
45
|
-
expect(error.code).toBe(
|
|
45
|
+
expect(error.code).toBe(410); // o el campo que uses para el código
|
|
46
46
|
}
|
|
47
47
|
})
|
|
48
48
|
|
|
@@ -64,7 +64,7 @@ describe('SecureUrlService', () => {
|
|
|
64
64
|
} catch (error) {
|
|
65
65
|
expect(error.message).toBe('The token has expired.');
|
|
66
66
|
expect(error.name).toBe('SecureUrlError');
|
|
67
|
-
expect(error.code).toBe(
|
|
67
|
+
expect(error.code).toBe(410); // o el campo que uses para el código
|
|
68
68
|
}
|
|
69
69
|
})
|
|
70
70
|
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
- path: ~/blazedapth/blz/blz-builder/burners/web-frontend/sources/startup/index.js
|
|
43
43
|
- path: ~/blazedapth/blz/blz-suite/backend/servers/web-frontend/index.js
|
|
44
44
|
- Se modifica Blz.setSecurityRule por BlzSecurity.setSecurityRule
|
|
45
|
-
- path: ~/blazedapth/blz/blz-
|
|
45
|
+
- path: ~/blazedapth/blz/blz-commons/js-generator/commands/set-security-rule.js
|
|
46
46
|
- Se modifica Blz.clearSecurityRules por BlzSecurity.clearSecurityRules
|
|
47
|
-
- path: ~/blazedapth/blz/blz-
|
|
47
|
+
- path: ~/blazedapth/blz/blz-commons/js-generator/commands/reset-security-rules.js
|
|
48
48
|
- Se agrega BlzSecurity en Blz_controls_RouteResolver
|
|
49
49
|
- path: ~/blazedapth/blz/blz-ui/assets/js/blz-wrappers/Blz_controls_RouteResolver.js
|
|
50
50
|
|
|
@@ -71,5 +71,5 @@ grunt prod-prod
|
|
|
71
71
|
- Documentation
|
|
72
72
|
- [security rules and options](https://docs-blz.bsn-dev.beesion.team/#/doc/security-rules-and-options)
|
|
73
73
|
- Demo
|
|
74
|
-
- [DemoAuth](~/blazedapth/blz/blz-
|
|
74
|
+
- [DemoAuth](~/blazedapth/blz/blz-commons/essentials/solutions/DemoAuth)
|
|
75
75
|
|
|
@@ -17,19 +17,26 @@ async function getAuthorizationService(configPath) {
|
|
|
17
17
|
|
|
18
18
|
;(async () => {
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
let result= null
|
|
21
21
|
|
|
22
22
|
const authorizationService = await getAuthorizationService('../__test__/AuthorizationKpn.yaml')
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
// expect('[{"path":"/api/ms-financing-setting/fnc-catalog","actions":"*","enable":true}]').toStrictEqual(result)
|
|
25
25
|
|
|
26
26
|
// console.log(authorizationService.getFrontendSecurityRules(["Configuration.Admin"],["config"] ))
|
|
27
27
|
// console.log(JSON.stringify(authorizationService.getFrontendSecurityRules(['Configuration.Admin'],['agent'] )))
|
|
28
|
-
|
|
28
|
+
// let result = authorizationService.checkAuthorize('/ep-manual-credit/undefined', null, ['Configuration.Admin'], ['agent'])
|
|
29
|
+
// console.log(result)
|
|
30
|
+
// result = authorizationService.checkAuthorize('/ep-manual-credit/undefined', null, ['Collections.Admin','Collections.Finance','Configuration.Admin'], ['agent'])
|
|
31
|
+
// console.log(result)
|
|
32
|
+
result = authorizationService.checkAuthorize('/debtor/102592', 'dunning_CreateFinancingAgreement', ['Collections.ViewOnly'], ['agent'])
|
|
29
33
|
console.log(result)
|
|
30
|
-
result = authorizationService.checkAuthorize('/
|
|
34
|
+
result = authorizationService.checkAuthorize('/debtor/102592', 'dunning_CreateFinancingAgreement', ['Configuration.Admin'], ['agent'])
|
|
31
35
|
console.log(result)
|
|
32
36
|
|
|
37
|
+
// no debe tener acceso ViewOnly Financiamiento
|
|
38
|
+
//
|
|
39
|
+
|
|
33
40
|
|
|
34
41
|
|
|
35
42
|
|
|
@@ -594,12 +594,13 @@ class HapiServerAzureAd {
|
|
|
594
594
|
|
|
595
595
|
// Register the @hapi/cookie plugin
|
|
596
596
|
await server.register(hapiCookie);
|
|
597
|
-
|
|
597
|
+
|
|
598
|
+
const hapiCookiePassword = process.env.blz_hapiCookiePassword || 'supersecretpasswordmustbeatleast32characterslong';
|
|
598
599
|
// Define the cookie-based auth strategy
|
|
599
600
|
server.auth.strategy('cookieAuth', 'cookie', {
|
|
600
601
|
cookie: {
|
|
601
602
|
name: 'sid', // Primary session cookie
|
|
602
|
-
password:
|
|
603
|
+
password: hapiCookiePassword, // Encryption key
|
|
603
604
|
isSecure: true, // Should be true in production
|
|
604
605
|
isHttpOnly: true, // Prevents client-side JavaScript access
|
|
605
606
|
isSameSite: 'Lax', // Protects against CSRF
|
|
@@ -59,13 +59,10 @@ class HapiServerKeycloak {
|
|
|
59
59
|
this.securityService = null;
|
|
60
60
|
this.securityUrlCookieKey = null;
|
|
61
61
|
}
|
|
62
|
+
|
|
62
63
|
async generateGuid() {
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
const v = (c === 'x') ? r : (r & 0x3 | 0x8);
|
|
66
|
-
return v.toString(16);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
64
|
+
return crypto.randomUUID();
|
|
65
|
+
}
|
|
69
66
|
|
|
70
67
|
async connect(_securityService, hapiServer, config) {
|
|
71
68
|
contextConfig = config
|
|
@@ -630,11 +627,12 @@ class HapiServerKeycloak {
|
|
|
630
627
|
// Register the @hapi/cookie plugin
|
|
631
628
|
await server.register(hapiCookie);
|
|
632
629
|
|
|
630
|
+
const hapiCookiePassword = process.env.blz_hapiCookiePassword || 'supersecretpasswordmustbeatleast32characterslong';
|
|
633
631
|
// Define the cookie-based auth strategy
|
|
634
632
|
server.auth.strategy('cookieAuth', 'cookie', {
|
|
635
633
|
cookie: {
|
|
636
634
|
name: 'sid', // Primary session cookie
|
|
637
|
-
password:
|
|
635
|
+
password: hapiCookiePassword, // Encryption key
|
|
638
636
|
isSecure: true, // Should be true in production
|
|
639
637
|
isHttpOnly: true, // Prevents client-side JavaScript access
|
|
640
638
|
isSameSite: 'Lax', // Protects against CSRF
|
|
@@ -736,11 +736,12 @@ class HapiServer {
|
|
|
736
736
|
// Register the @hapi/cookie plugin
|
|
737
737
|
await server.register(hapiCookie);
|
|
738
738
|
|
|
739
|
+
const hapiCookiePassword = process.env.blz_hapiCookiePassword || 'supersecretpasswordmustbeatleast32characterslong';
|
|
739
740
|
// Define the cookie-based auth strategy
|
|
740
741
|
server.auth.strategy('cookieAuth', 'cookie', {
|
|
741
742
|
cookie: {
|
|
742
743
|
name: 'sid', // Primary session cookie
|
|
743
|
-
password:
|
|
744
|
+
password: hapiCookiePassword, // Encryption key
|
|
744
745
|
isSecure: true, // Should be true in production
|
|
745
746
|
isHttpOnly: true, // Prevents client-side JavaScript access
|
|
746
747
|
isSameSite: 'Lax', // Protects against CSRF
|
|
@@ -41,8 +41,7 @@ module.exports = class SecureUrlService {
|
|
|
41
41
|
const path = url.split('?')[0];
|
|
42
42
|
const session_key = isBase64(_session_key)?atob(_session_key):_session_key
|
|
43
43
|
const key = `${session_key}${btoa(decodeURIComponent(path))}`;
|
|
44
|
-
const
|
|
45
|
-
const token = CryptoJS.AES.encrypt((getNow()).toString(), key).toString();
|
|
44
|
+
const token = CryptoJS.AES.encrypt((Date.now()).toString(), key).toString();
|
|
46
45
|
return encodeURIComponent(token);
|
|
47
46
|
}
|
|
48
47
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blazedpath/commons",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "commos library for blazedpath applications",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "UNLICENSED",
|
|
8
|
-
"publishConfig": {
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
9
11
|
"dependencies": {
|
|
10
12
|
"@hapi/boom": "^10.0.1",
|
|
11
13
|
"@hapi/call": "^9.0.1",
|
|
@@ -79,7 +81,7 @@
|
|
|
79
81
|
"@types/node": "20.11.17",
|
|
80
82
|
"jest": "^29.7.0"
|
|
81
83
|
},
|
|
82
|
-
|
|
84
|
+
"bin": {
|
|
83
85
|
"blz-security": "."
|
|
84
86
|
},
|
|
85
87
|
"eslintConfig": {
|
|
@@ -92,6 +94,9 @@
|
|
|
92
94
|
},
|
|
93
95
|
"overrides": {
|
|
94
96
|
"shelljs": "0.9.2",
|
|
95
|
-
"cross-spawn": "7.0.6"
|
|
97
|
+
"cross-spawn": "7.0.6",
|
|
98
|
+
"glob": "^12.0.0",
|
|
99
|
+
"qs": "^6.14.1",
|
|
100
|
+
"jws": "^4.0.1"
|
|
96
101
|
}
|
|
97
|
-
}
|
|
102
|
+
}
|