@burgan-tech/morph-idm-runtime 0.0.1 → 0.0.3
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/burgan-tech-morph-idm-runtime-0.0.3.tgz +0 -0
- package/morph-idm/Schemas/client/client-update-1.0.0.json +263 -0
- package/morph-idm/Schemas/{user → person}/person-master-1.0.0.json +1 -1
- package/morph-idm/Schemas/token/token-start-1.0.0.json +6 -19
- package/morph-idm/Schemas/user/user-master-1.0.0.json +46 -1
- package/morph-idm/Schemas/user-login/retry-login-1.0.0.json +39 -0
- package/morph-idm/Tasks/call-device-start-1.0.0.json +1 -1
- package/morph-idm/Tasks/call-device-update-1.0.0.json +1 -1
- package/morph-idm/Tasks/consent/consent-auto-select-script.json +16 -0
- package/morph-idm/Tasks/{user/send-push-task.json → device/search-device-task.json} +5 -5
- package/morph-idm/Tasks/get-device-1.0.0.json +1 -1
- package/morph-idm/Tasks/person/get-person-by-task.json +19 -0
- package/morph-idm/Tasks/person/person-update-direct-transition.json +23 -0
- package/morph-idm/Tasks/token/token-create-jwt.json +0 -1
- package/morph-idm/Tasks/token/token-redeem-trigger.json +22 -0
- package/morph-idm/Tasks/token/user-login-get-as-filterable.json +22 -0
- package/morph-idm/Tasks/user/evaluate-failed-login-script.json +18 -0
- package/morph-idm/Tasks/user/get-phone-from-person-task.json +20 -0
- package/morph-idm/Tasks/user/otp-code-generator.json +15 -0
- package/morph-idm/Tasks/user/send-otp-sms-task.json +26 -0
- package/morph-idm/Tasks/user/user-update-password-fail-count.json +24 -0
- package/morph-idm/Tasks/user-login/auth-code-generator.json +17 -0
- package/morph-idm/Tasks/user-login/increment-local-fail-count.json +17 -0
- package/morph-idm/Tasks/user-login/password-verify.json +26 -0
- package/morph-idm/Tasks/user-login/push-send-task.json +25 -0
- package/morph-idm/TestCases/test-123/.httpyac.json +15 -0
- package/morph-idm/TestCases/test-123/01-person.http +95 -0
- package/morph-idm/TestCases/test-123/02-user.http +83 -0
- package/morph-idm/TestCases/test-123/03-scope.http +65 -0
- package/morph-idm/TestCases/test-123/04-consent.http +66 -0
- package/morph-idm/TestCases/test-123/05-device.http +86 -0
- package/morph-idm/TestCases/test-123/06-user-login.http +206 -0
- package/morph-idm/TestCases/test-123/README.md +112 -0
- package/morph-idm/TestCases/test-123/cleanup.js +49 -0
- package/morph-idm/TestCases/test-123/cleanup.sh +20 -0
- package/morph-idm/TestCases/test-123/cleanup.sql +45 -0
- package/morph-idm/TestCases/test-123/http-client.env.json +13 -0
- package/morph-idm/TestCases/test-123/run-setup.sh +42 -0
- package/morph-idm/TestCases/test-auto-consent/.httpyac.json +14 -0
- package/morph-idm/TestCases/test-auto-consent/01-person.http +72 -0
- package/morph-idm/TestCases/test-auto-consent/02-user.http +74 -0
- package/morph-idm/TestCases/test-auto-consent/03-scope.http +66 -0
- package/morph-idm/TestCases/test-auto-consent/04-device.http +56 -0
- package/morph-idm/TestCases/test-auto-consent/05-user-login.http +132 -0
- package/morph-idm/TestCases/test-auto-consent/README.md +36 -0
- package/morph-idm/TestCases/test-auto-consent/cleanup.js +47 -0
- package/morph-idm/TestCases/test-auto-consent/run-setup.sh +50 -0
- package/morph-idm/TestCases/test-multiple-consent/.httpyac.json +17 -0
- package/morph-idm/TestCases/test-multiple-consent/01-person.http +103 -0
- package/morph-idm/TestCases/test-multiple-consent/02-user.http +83 -0
- package/morph-idm/TestCases/test-multiple-consent/03-scope-2.http +66 -0
- package/morph-idm/TestCases/test-multiple-consent/03-scope.http +66 -0
- package/morph-idm/TestCases/test-multiple-consent/04-consent-1.http +67 -0
- package/morph-idm/TestCases/test-multiple-consent/04-consent-2.http +66 -0
- package/morph-idm/TestCases/test-multiple-consent/05-device.http +87 -0
- package/morph-idm/TestCases/test-multiple-consent/06-user-login.http +183 -0
- package/morph-idm/TestCases/test-multiple-consent/README.md +37 -0
- package/morph-idm/TestCases/test-multiple-consent/cleanup.js +46 -0
- package/morph-idm/TestCases/test-multiple-consent/cleanup.sh +20 -0
- package/morph-idm/TestCases/test-multiple-consent/run-setup.sh +53 -0
- package/morph-idm/Views/user-login/push-waiting.json +28 -0
- package/morph-idm/Views/user-login/start.json +28 -0
- package/morph-idm/Workflows/client/client-1.0.0.json +8 -3
- package/morph-idm/Workflows/client/execute/client-update.http +763 -0
- package/morph-idm/Workflows/client/execute/client.http +13 -5
- package/morph-idm/Workflows/client/src/CreateRsaByHttpCallMapping.csx +10 -14
- package/morph-idm/Workflows/client/src/PasswordGeneratorMapping.csx +0 -1
- package/morph-idm/Workflows/consent-selection/consent-selection-1.0.0.json +37 -6
- package/morph-idm/Workflows/consent-selection/execute/multi-consent-selection.http +209 -0
- package/morph-idm/Workflows/consent-selection/src/ConsentSelectedMapping.csx +18 -22
- package/morph-idm/Workflows/consent-selection/src/CreateAutoConsentMapping.csx +45 -45
- package/morph-idm/Workflows/consent-selection/src/MultipleConsentsRule.csx +12 -8
- package/morph-idm/Workflows/consent-selection/src/NoConsentEligibleRule.csx +6 -22
- package/morph-idm/Workflows/consent-selection/src/SingleConsentAutoSelectMapping.csx +63 -0
- package/morph-idm/Workflows/consent-selection/src/SingleConsentRule.csx +11 -22
- package/morph-idm/Workflows/device/execute/device-ios.http +0 -6
- package/morph-idm/Workflows/device/execute/search.http +32 -0
- package/morph-idm/Workflows/person/execute/person-123.http +191 -0
- package/morph-idm/Workflows/person/execute/person.http +196 -0
- package/morph-idm/Workflows/{user → person}/person-1.0.0.json +24 -1
- package/morph-idm/Workflows/token/execute/token.http +14 -3
- package/morph-idm/Workflows/token/password-subflow.json +1 -1
- package/morph-idm/Workflows/token/src/AuthCodeRedeemMapping.csx +114 -0
- package/morph-idm/Workflows/token/src/AuthCodeValidationRule.csx +27 -0
- package/morph-idm/Workflows/token/src/CreateRsaJwtMapping.csx +28 -16
- package/morph-idm/Workflows/token/src/StatusSuccessRule.csx +27 -0
- package/morph-idm/Workflows/token/src/TokenCreatedRule.csx +32 -0
- package/morph-idm/Workflows/token/src/UserLoginGetAsFilterableMapping.csx +204 -0
- package/morph-idm/Workflows/token/token-1.0.0.json +109 -41
- package/morph-idm/Workflows/user/execute/create-user-1234567890.http +16 -4
- package/morph-idm/Workflows/user/execute/create-user-migration.http +179 -0
- package/morph-idm/Workflows/user/execute/create-user-person-password.http +78 -32
- package/morph-idm/Workflows/user/src/EvaluateFailedLoginMapping.csx +75 -0
- package/morph-idm/Workflows/user/src/FailCountMaxRule.csx +33 -0
- package/morph-idm/Workflows/user/src/GetPhoneFromPersonMapping.csx +139 -0
- package/morph-idm/Workflows/user/src/HasPasswordsRule.csx +43 -0
- package/morph-idm/Workflows/user/src/OtpSentSuccessRule.csx +46 -0
- package/morph-idm/Workflows/user/src/PasswordGeneratedSuccessRule.csx +73 -0
- package/morph-idm/Workflows/user/src/PhoneFetchedSuccessRule.csx +35 -0
- package/morph-idm/Workflows/user/src/ResetPasswordFailCountMapping.csx +88 -0
- package/morph-idm/Workflows/user/src/SendOtpSmsMapping.csx +357 -0
- package/morph-idm/Workflows/user/src/UserPasswordGeneratorMapping.csx +33 -6
- package/morph-idm/Workflows/user/user-1.0.0.json +365 -5
- package/morph-idm/Workflows/{user → user-login}/execute/user-login.http +155 -32
- package/morph-idm/Workflows/user-login/src/AuthCodeGeneratorMapping.csx +44 -0
- package/morph-idm/Workflows/{user/src/GetClientMapping.csx → user-login/src/ClientGetMapping.csx} +6 -4
- package/morph-idm/Workflows/{user/src/TriggerConsentSelectionAsSubFlowMapping.csx → user-login/src/ConsentSelectionSubFlowMapping.csx} +19 -20
- package/morph-idm/Workflows/user-login/src/DeviceSearchMapping.csx +128 -0
- package/morph-idm/Workflows/{user → user-login}/src/GrantValidationRule.csx +5 -1
- package/morph-idm/Workflows/user-login/src/HasFailCountRule.csx +32 -0
- package/morph-idm/Workflows/user-login/src/MaxRetriesReachedRule.csx +32 -0
- package/morph-idm/Workflows/user-login/src/NoSecurityImageRule.csx +33 -0
- package/morph-idm/Workflows/user-login/src/NoSecurityQuestionRule.csx +65 -0
- package/morph-idm/Workflows/user-login/src/OtpCodeGenerateMapping.csx +37 -0
- package/morph-idm/Workflows/{user/src/SendOtpMapping.csx → user-login/src/OtpSendMapping.csx} +13 -7
- package/morph-idm/Workflows/user-login/src/OtpVerifiedRule.csx +35 -0
- package/morph-idm/Workflows/user-login/src/PasswordFailCountResetMapping.csx +77 -0
- package/morph-idm/Workflows/user-login/src/PasswordFailCountUpdateMapping.csx +80 -0
- package/morph-idm/Workflows/user-login/src/PasswordVerifyMapping.csx +172 -0
- package/morph-idm/Workflows/user-login/src/PersonFetchedRule.csx +32 -0
- package/morph-idm/Workflows/user-login/src/PersonGetMapping.csx +61 -0
- package/morph-idm/Workflows/user-login/src/PersonUpdateMapping.csx +105 -0
- package/morph-idm/Workflows/user-login/src/PersonUpdatedRule.csx +32 -0
- package/morph-idm/Workflows/{user/src/SendPushMapping.csx → user-login/src/PushSendMapping.csx} +22 -11
- package/morph-idm/Workflows/user-login/src/PushVerifiedRule.csx +31 -0
- package/morph-idm/Workflows/{user/src/GetScopesByUserMapping.csx → user-login/src/ScopesByUserGetMapping.csx} +24 -22
- package/morph-idm/Workflows/user-login/src/TokenGenerationSuccessRule.csx +33 -0
- package/morph-idm/Workflows/{user/src/TriggerTokenWorkflowAsSubFlowMapping.csx → user-login/src/TokenSubFlowMapping.csx} +7 -13
- package/morph-idm/Workflows/user-login/src/UserFoundRule.csx +19 -0
- package/morph-idm/Workflows/{user/src/GetUserMapping.csx → user-login/src/UserGetMapping.csx} +5 -3
- package/morph-idm/Workflows/user-login/src/UserStatusActiveRule.csx +34 -0
- package/morph-idm/Workflows/user-login/src/UserValidHasFailCountRule.csx +39 -0
- package/morph-idm/Workflows/user-login/src/UserValidNoFailCountRule.csx +39 -0
- package/morph-idm/Workflows/user-login/user-login.1.0.0.json +1828 -0
- package/package.json +1 -1
- package/vnext.config.json +3 -3
- package/burgan-tech-morph-idm-runtime-0.0.1.tgz +0 -0
- package/morph-idm/Schemas/client/client-update-master-1.0.0.json +0 -201
- package/morph-idm/Workflows/client/client-update-1.0.0.json +0 -202
- package/morph-idm/Workflows/client-manager/client-manager-1.0.0.json +0 -217
- package/morph-idm/Workflows/client-manager/execute/client-manager.http +0 -214
- package/morph-idm/Workflows/client-manager/src/ClientCreatedRule.csx +0 -28
- package/morph-idm/Workflows/client-manager/src/ClientExistsRule.csx +0 -25
- package/morph-idm/Workflows/client-manager/src/CreateClientSubFlowMapping.csx +0 -63
- package/morph-idm/Workflows/client-manager/src/GetClientForManagerMapping.csx +0 -59
- package/morph-idm/Workflows/user/src/ApproveRule.csx +0 -16
- package/morph-idm/Workflows/user/src/AutoConsentCreatedRule.csx +0 -20
- package/morph-idm/Workflows/user/src/AutoConsentRequiredRule.csx +0 -77
- package/morph-idm/Workflows/user/src/CheckDeviceByUserReferenceMapping.csx +0 -66
- package/morph-idm/Workflows/user/src/ClientValidationFailRule.csx +0 -28
- package/morph-idm/Workflows/user/src/ConsentValidationRule.csx +0 -36
- package/morph-idm/Workflows/user/src/CreateAutoConsentMapping.csx +0 -171
- package/morph-idm/Workflows/user/src/DeviceFoundForLoginRule.csx +0 -32
- package/morph-idm/Workflows/user/src/DeviceNotFoundForLoginRule.csx +0 -31
- package/morph-idm/Workflows/user/src/GetConsentMapping.csx +0 -27
- package/morph-idm/Workflows/user/src/GetDeviceMapping.csx +0 -52
- package/morph-idm/Workflows/user/src/GetScopeMapping.csx +0 -139
- package/morph-idm/Workflows/user/src/GrantValidationFailRule.csx +0 -48
- package/morph-idm/Workflows/user/src/OtpVerifiedRule.csx +0 -31
- package/morph-idm/Workflows/user/src/PushVerifiedRule.csx +0 -31
- package/morph-idm/Workflows/user/src/RejectRule.csx +0 -16
- package/morph-idm/Workflows/user/src/ScopeValidationFailRule.csx +0 -67
- package/morph-idm/Workflows/user/src/ScopeValidationRule.csx +0 -67
- package/morph-idm/Workflows/user/src/TokenGenerationSuccessRule.csx +0 -28
- package/morph-idm/Workflows/user/src/UserValidationFailRule.csx +0 -36
- package/morph-idm/Workflows/user/src/VerifyOtpMapping.csx +0 -65
- package/morph-idm/Workflows/user/src/VerifyPushMapping.csx +0 -65
- package/morph-idm/Workflows/user/user-login.1.0.0.json +0 -1144
- /package/morph-idm/Workflows/{user → person}/person-cdc-worker.1.0.0.json +0 -0
- /package/morph-idm/Workflows/{user → person}/person-upsert-1.0.0.json +0 -0
- /package/morph-idm/Workflows/scope/execute/{scope-individual.http → scope-individual-1234567890-1234567890.http} +0 -0
- /package/morph-idm/Workflows/{user → user-login}/execute/README-LOGIN.md +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/ClientValidationRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/ConsentSelectedRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/IsIbWebClientWithDeviceRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/NonIbWebClientWithDeviceRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/OtpSentRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/PushSentRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/ScopeFetchedRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/UserValidationRule.csx +0 -0
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
using System;
|
|
2
|
-
using System.Collections.Generic;
|
|
3
|
-
using System.Dynamic;
|
|
4
|
-
using System.Threading.Tasks;
|
|
5
|
-
using BBT.Workflow.Definitions;
|
|
6
|
-
using BBT.Workflow.Scripting;
|
|
7
|
-
using BBT.Workflow.Scripting.Functions;
|
|
8
|
-
|
|
9
|
-
/// <summary>
|
|
10
|
-
/// Mapping for creating auto-consent via consent workflow subflow.
|
|
11
|
-
/// Prepares the consent data from user-login instance data.
|
|
12
|
-
/// </summary>
|
|
13
|
-
public class CreateAutoConsentMapping : ScriptBase, ISubFlowMapping
|
|
14
|
-
{
|
|
15
|
-
public Task<ScriptResponse> InputHandler(ScriptContext context)
|
|
16
|
-
{
|
|
17
|
-
dynamic expandoObject = new ExpandoObject();
|
|
18
|
-
|
|
19
|
-
// Get user key
|
|
20
|
-
var userKey = context.Instance?.Data?.userName?.ToString() ?? string.Empty;
|
|
21
|
-
|
|
22
|
-
// Get client key
|
|
23
|
-
var clientId = context.Instance?.Data?.clientId?.ToString() ?? string.Empty;
|
|
24
|
-
|
|
25
|
-
// Get the first auto-consent eligible scope
|
|
26
|
-
var autoConsentScopes = context.Instance?.Data?.autoConsentScopes;
|
|
27
|
-
var selectedScope = string.Empty;
|
|
28
|
-
|
|
29
|
-
if (autoConsentScopes != null)
|
|
30
|
-
{
|
|
31
|
-
foreach (var scope in autoConsentScopes)
|
|
32
|
-
{
|
|
33
|
-
selectedScope = scope?.ToString();
|
|
34
|
-
if (!string.IsNullOrEmpty(selectedScope))
|
|
35
|
-
{
|
|
36
|
-
break; // Use the first eligible scope
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Fallback to first requested scope if no auto-consent scope found
|
|
42
|
-
if (string.IsNullOrEmpty(selectedScope))
|
|
43
|
-
{
|
|
44
|
-
var scopes = context.Instance?.Data?.scopes;
|
|
45
|
-
if (scopes != null)
|
|
46
|
-
{
|
|
47
|
-
foreach (var scope in scopes)
|
|
48
|
-
{
|
|
49
|
-
selectedScope = scope?.ToString();
|
|
50
|
-
if (!string.IsNullOrEmpty(selectedScope))
|
|
51
|
-
{
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Build consent key: {user}-{client}-{scope}
|
|
59
|
-
var consentKey = $"{userKey}-{clientId}-{selectedScope}";
|
|
60
|
-
|
|
61
|
-
// Get scope details for the selected scope
|
|
62
|
-
var scopeDetails = context.Instance?.Data?.scopeDetails;
|
|
63
|
-
dynamic selectedScopeDetail = null;
|
|
64
|
-
|
|
65
|
-
if (scopeDetails != null)
|
|
66
|
-
{
|
|
67
|
-
foreach (var detail in scopeDetails)
|
|
68
|
-
{
|
|
69
|
-
if (detail?.key?.ToString() == selectedScope)
|
|
70
|
-
{
|
|
71
|
-
selectedScopeDetail = detail;
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Prepare consent data
|
|
78
|
-
expandoObject.key = consentKey;
|
|
79
|
-
expandoObject.tags = new List<string> { "auto-consent", "login-flow" };
|
|
80
|
-
|
|
81
|
-
// Build attributes for consent
|
|
82
|
-
var attributes = new ExpandoObject() as IDictionary<string, object>;
|
|
83
|
-
|
|
84
|
-
// User reference
|
|
85
|
-
attributes["user"] = new {
|
|
86
|
-
domain = "morph-idm",
|
|
87
|
-
workflow = "user",
|
|
88
|
-
key = userKey,
|
|
89
|
-
version = "1.0.0"
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// Client reference
|
|
93
|
-
attributes["client"] = new {
|
|
94
|
-
domain = "morph-idm",
|
|
95
|
-
workflow = "client",
|
|
96
|
-
key = clientId,
|
|
97
|
-
version = "1.0.0"
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// Scope reference
|
|
101
|
-
attributes["scope"] = new {
|
|
102
|
-
domain = "morph-idm",
|
|
103
|
-
workflow = "scope",
|
|
104
|
-
key = selectedScope,
|
|
105
|
-
version = "1.0.0"
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// Set default position from scope organization if available
|
|
109
|
-
if (selectedScopeDetail != null && HasProperty(selectedScopeDetail, "group"))
|
|
110
|
-
{
|
|
111
|
-
// Use default position - can be enhanced later
|
|
112
|
-
attributes["position"] = "self-access";
|
|
113
|
-
}
|
|
114
|
-
else
|
|
115
|
-
{
|
|
116
|
-
attributes["position"] = "self-access";
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Default roles for auto-consent
|
|
120
|
-
attributes["roles"] = new List<object>
|
|
121
|
-
{
|
|
122
|
-
new { role = "idm.self-access", allowance = "allow" }
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// Set consent timestamps
|
|
126
|
-
attributes["grantedAt"] = DateTime.UtcNow.ToString("o");
|
|
127
|
-
attributes["expiresAt"] = DateTime.UtcNow.AddYears(1).ToString("o"); // 1 year default
|
|
128
|
-
|
|
129
|
-
// Flag to indicate this is auto-consent (for AutoConsentRule in consent workflow)
|
|
130
|
-
attributes["isAutoConsent"] = true;
|
|
131
|
-
|
|
132
|
-
expandoObject.attributes = attributes;
|
|
133
|
-
|
|
134
|
-
LogInformation($"CreateAutoConsentMapping InputHandler: Creating auto-consent for user={userKey}, client={clientId}, scope={selectedScope}, key={consentKey}");
|
|
135
|
-
|
|
136
|
-
return Task.FromResult(new ScriptResponse
|
|
137
|
-
{
|
|
138
|
-
Data = expandoObject,
|
|
139
|
-
Headers = null
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
public async Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
144
|
-
{
|
|
145
|
-
// Extract the created consent info from subflow response
|
|
146
|
-
var consentKey = context.Body?.key?.ToString();
|
|
147
|
-
var consentState = context.Body?.state?.ToString();
|
|
148
|
-
|
|
149
|
-
LogInformation($"CreateAutoConsentMapping OutputHandler: Auto-consent created - key={consentKey}, state={consentState}");
|
|
150
|
-
|
|
151
|
-
// Store the created consent info for subsequent steps
|
|
152
|
-
return new ScriptResponse
|
|
153
|
-
{
|
|
154
|
-
Data = new
|
|
155
|
-
{
|
|
156
|
-
autoConsentCreated = true,
|
|
157
|
-
autoConsentKey = consentKey,
|
|
158
|
-
autoConsentState = consentState,
|
|
159
|
-
// Also set consentSnapshot for compatibility with existing flow
|
|
160
|
-
consentSnapshot = new
|
|
161
|
-
{
|
|
162
|
-
key = consentKey,
|
|
163
|
-
roles = context.Body?.data?.roles,
|
|
164
|
-
expiresAt = context.Body?.data?.expiresAt
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
Headers = null
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
using System.Threading.Tasks;
|
|
2
|
-
using BBT.Workflow.Scripting;
|
|
3
|
-
using BBT.Workflow.Scripting.Functions;
|
|
4
|
-
|
|
5
|
-
/// <summary>
|
|
6
|
-
/// Rule: Device found for login - skip OTP
|
|
7
|
-
/// Returns true if device is found and trusted
|
|
8
|
-
/// </summary>
|
|
9
|
-
public class DeviceFoundForLoginRule : ScriptBase, IConditionMapping
|
|
10
|
-
{
|
|
11
|
-
public async Task<bool> Handler(ScriptContext context)
|
|
12
|
-
{
|
|
13
|
-
// Check if device was found
|
|
14
|
-
if (!HasProperty(context.Instance?.Data, "deviceFound"))
|
|
15
|
-
{
|
|
16
|
-
LogWarning("DeviceFoundForLoginRule: deviceFound property not found");
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
var deviceFound = context.Instance?.Data?.deviceFound;
|
|
21
|
-
|
|
22
|
-
if (deviceFound == true)
|
|
23
|
-
{
|
|
24
|
-
LogInformation("DeviceFoundForLoginRule: Device found, skipping OTP");
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
LogInformation("DeviceFoundForLoginRule: Device not found, OTP required");
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
using System.Threading.Tasks;
|
|
2
|
-
using BBT.Workflow.Scripting;
|
|
3
|
-
using BBT.Workflow.Scripting.Functions;
|
|
4
|
-
|
|
5
|
-
/// <summary>
|
|
6
|
-
/// Rule: Device not found for login - requires OTP
|
|
7
|
-
/// Returns true if device is not found
|
|
8
|
-
/// </summary>
|
|
9
|
-
public class DeviceNotFoundForLoginRule : ScriptBase, IConditionMapping
|
|
10
|
-
{
|
|
11
|
-
public async Task<bool> Handler(ScriptContext context)
|
|
12
|
-
{
|
|
13
|
-
// Check if device was found
|
|
14
|
-
if (!HasProperty(context.Instance?.Data, "deviceFound"))
|
|
15
|
-
{
|
|
16
|
-
LogWarning("DeviceNotFoundForLoginRule: deviceFound property not found, assuming OTP required");
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
var deviceFound = context.Instance?.Data?.deviceFound;
|
|
21
|
-
|
|
22
|
-
if (deviceFound != true)
|
|
23
|
-
{
|
|
24
|
-
LogInformation("DeviceNotFoundForLoginRule: Device not found, OTP required");
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
using System.Threading.Tasks;
|
|
2
|
-
using BBT.Workflow.Scripting;
|
|
3
|
-
|
|
4
|
-
public class GetConsentMapping : IMapping
|
|
5
|
-
{
|
|
6
|
-
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
7
|
-
{
|
|
8
|
-
var triggerTask = (task as GetInstanceDataTask)!;
|
|
9
|
-
|
|
10
|
-
LogInformation($"GetConsentMapping Instance InputHandler: {context.Instance?.Data?.consentId}");
|
|
11
|
-
|
|
12
|
-
triggerTask.SetInstance(context.Instance?.Data?.consentId ?? string.Empty);
|
|
13
|
-
return Task.FromResult(new ScriptResponse());
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public async Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
17
|
-
{
|
|
18
|
-
return new ScriptResponse
|
|
19
|
-
{
|
|
20
|
-
Data = new
|
|
21
|
-
{
|
|
22
|
-
consent = context.Body
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
using System.Threading.Tasks;
|
|
2
|
-
using BBT.Workflow.Definitions;
|
|
3
|
-
using BBT.Workflow.Scripting;
|
|
4
|
-
using BBT.Workflow.Scripting.Functions;
|
|
5
|
-
|
|
6
|
-
public class GetDeviceMapping : ScriptBase, IMapping
|
|
7
|
-
{
|
|
8
|
-
public Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
9
|
-
{
|
|
10
|
-
var triggerTask = (task as GetInstanceDataTask)!;
|
|
11
|
-
|
|
12
|
-
var deviceKey = HasProperty(context.Instance.Data, "deviceId") ? context.Instance.Data.deviceId : string.Empty;
|
|
13
|
-
if (string.IsNullOrEmpty(deviceKey))
|
|
14
|
-
{
|
|
15
|
-
LogWarning($"GetDeviceMapping InputHandler: deviceId is not found");
|
|
16
|
-
}
|
|
17
|
-
triggerTask.SetKey(deviceKey);
|
|
18
|
-
return Task.FromResult(new ScriptResponse());
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public async Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
22
|
-
{
|
|
23
|
-
// Check if device was found
|
|
24
|
-
if (HasProperty(context.Body, "data") && HasProperty(context.Body.data, "data"))
|
|
25
|
-
{
|
|
26
|
-
var deviceData = context.Body.data.data;
|
|
27
|
-
|
|
28
|
-
return new ScriptResponse
|
|
29
|
-
{
|
|
30
|
-
Data = new
|
|
31
|
-
{
|
|
32
|
-
deviceSnapshot = deviceData,
|
|
33
|
-
deviceFound = true
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
else
|
|
38
|
-
{
|
|
39
|
-
LogInformation("GetDeviceMapping OutputHandler: Device not found");
|
|
40
|
-
|
|
41
|
-
return new ScriptResponse
|
|
42
|
-
{
|
|
43
|
-
Data = new
|
|
44
|
-
{
|
|
45
|
-
deviceFound = false,
|
|
46
|
-
message = "Device not found - OTP required"
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
using System.Threading.Tasks;
|
|
2
|
-
using System.Collections.Generic;
|
|
3
|
-
using System.Linq;
|
|
4
|
-
using BBT.Workflow.Definitions;
|
|
5
|
-
using BBT.Workflow.Scripting;
|
|
6
|
-
using BBT.Workflow.Scripting.Functions;
|
|
7
|
-
|
|
8
|
-
/// <summary>
|
|
9
|
-
/// Mapping for scope-details HTTP task
|
|
10
|
-
/// Prepares request body with scopes and allowedScopeGroups from client
|
|
11
|
-
/// Processes response to extract scope and scope-group details including auto-consent eligibility
|
|
12
|
-
/// </summary>
|
|
13
|
-
public class GetScopeMapping : ScriptBase, IMapping
|
|
14
|
-
{
|
|
15
|
-
public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
16
|
-
{
|
|
17
|
-
var httpTask = (task as HttpTask)!;
|
|
18
|
-
if (httpTask == null)
|
|
19
|
-
{
|
|
20
|
-
throw new InvalidOperationException("Task must be an HttpTask for RSA key generation");
|
|
21
|
-
}
|
|
22
|
-
var utilBaseAddress = await GetSecretAsync("vnext-secret", "workflow-secret","UtilBaseAddress");
|
|
23
|
-
if (string.IsNullOrEmpty(utilBaseAddress))
|
|
24
|
-
{
|
|
25
|
-
utilBaseAddress = "http://localhost:5288/api";
|
|
26
|
-
}
|
|
27
|
-
httpTask.Url = httpTask.Url.Replace("{UtilBaseAddress}", utilBaseAddress);
|
|
28
|
-
|
|
29
|
-
// Extract scopes from instance data
|
|
30
|
-
var scopesList = new List<string>();
|
|
31
|
-
var scopes = context.Instance?.Data?.scopes;
|
|
32
|
-
if (scopes != null)
|
|
33
|
-
{
|
|
34
|
-
foreach (var scope in scopes)
|
|
35
|
-
{
|
|
36
|
-
var scopeStr = scope?.ToString();
|
|
37
|
-
if (!string.IsNullOrEmpty(scopeStr))
|
|
38
|
-
{
|
|
39
|
-
scopesList.Add(scopeStr);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Get allowed scope groups from client snapshot
|
|
45
|
-
var allowedScopeGroups = new List<string>();
|
|
46
|
-
var clientSnapshot = context.Instance?.Data?.clientSnapshot;
|
|
47
|
-
if (clientSnapshot != null && HasProperty(clientSnapshot, "allowedScopeGroups"))
|
|
48
|
-
{
|
|
49
|
-
var groups = clientSnapshot.allowedScopeGroups;
|
|
50
|
-
if (groups != null)
|
|
51
|
-
{
|
|
52
|
-
foreach (var group in groups)
|
|
53
|
-
{
|
|
54
|
-
var groupStr = group?.ToString();
|
|
55
|
-
if (!string.IsNullOrEmpty(groupStr))
|
|
56
|
-
{
|
|
57
|
-
allowedScopeGroups.Add(groupStr);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
LogInformation($"GetScopeMapping InputHandler: scopes=[{string.Join(",", scopesList)}], allowedGroups=[{string.Join(",", allowedScopeGroups)}]");
|
|
64
|
-
|
|
65
|
-
// Set request body for scope details API
|
|
66
|
-
var requestBody = new
|
|
67
|
-
{
|
|
68
|
-
Scopes = scopesList,
|
|
69
|
-
AllowedScopeGroups = allowedScopeGroups
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
httpTask.SetBody(requestBody);
|
|
73
|
-
|
|
74
|
-
return await Task.FromResult(new ScriptResponse());
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public async Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
78
|
-
{
|
|
79
|
-
|
|
80
|
-
// Check if we got a successful response
|
|
81
|
-
if (!HasProperty(context.Body, "data"))
|
|
82
|
-
{
|
|
83
|
-
LogWarning("GetScopeMapping OutputHandler: Invalid response - missing data");
|
|
84
|
-
return new ScriptResponse
|
|
85
|
-
{
|
|
86
|
-
Data = new
|
|
87
|
-
{
|
|
88
|
-
scopeValidationFailed = true,
|
|
89
|
-
scopeError = "Invalid response from scope details service.data is missing",
|
|
90
|
-
scopeSnapshot = context.Body
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
if (!HasProperty(context.Body.data, "IsValid"))
|
|
96
|
-
{
|
|
97
|
-
LogWarning("GetScopeMapping OutputHandler: Invalid response - missing data.isValid");
|
|
98
|
-
return new ScriptResponse
|
|
99
|
-
{
|
|
100
|
-
Data = new
|
|
101
|
-
{
|
|
102
|
-
scopeValidationFailed = true,
|
|
103
|
-
scopeError = "Invalid response from scope details service.isValid is false",
|
|
104
|
-
scopeSnapshot = context.Body.data
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
var isValid = context.Body.data.IsValid;
|
|
110
|
-
|
|
111
|
-
if (isValid != true)
|
|
112
|
-
{
|
|
113
|
-
var error = HasProperty(context.Body.data, "error") ? context.Body.data.error?.ToString() : "Scope validation failed";
|
|
114
|
-
LogWarning($"GetScopeMapping OutputHandler: Validation failed - {error}");
|
|
115
|
-
|
|
116
|
-
return new ScriptResponse
|
|
117
|
-
{
|
|
118
|
-
Data = new
|
|
119
|
-
{
|
|
120
|
-
scopeValidationFailed = true,
|
|
121
|
-
scopeError = error,
|
|
122
|
-
scopeSnapshot = context.Body.data
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
LogInformation($"GetScopeMapping OutputHandler: Scope validation passed");
|
|
129
|
-
|
|
130
|
-
// Return scope details for further processing
|
|
131
|
-
return new ScriptResponse
|
|
132
|
-
{
|
|
133
|
-
Data = new
|
|
134
|
-
{
|
|
135
|
-
scopeSnapshot = context.Body.data
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
using System.Threading.Tasks;
|
|
2
|
-
using BBT.Workflow.Scripting;
|
|
3
|
-
using System.Linq;
|
|
4
|
-
using BBT.Workflow.Scripting.Functions;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
public class GrantValidationFailRule : ScriptBase, IConditionMapping
|
|
8
|
-
{
|
|
9
|
-
public async Task<bool> Handler(ScriptContext context)
|
|
10
|
-
{
|
|
11
|
-
// Get client data from previous validation
|
|
12
|
-
var clientFromDb = context.Instance?.Data?.client;
|
|
13
|
-
|
|
14
|
-
// Get grant type from input
|
|
15
|
-
var grantType = context.Instance?.Data?.grantType;
|
|
16
|
-
|
|
17
|
-
if (clientFromDb == null || string.IsNullOrEmpty(grantType?.ToString()))
|
|
18
|
-
{
|
|
19
|
-
LogWarning("Grant validation failed: Missing client or grant type data");
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Get allowed grants from client
|
|
24
|
-
var allowedGrants = clientFromDb?.data?.data?.allowedGrants;
|
|
25
|
-
|
|
26
|
-
if (allowedGrants == null)
|
|
27
|
-
{
|
|
28
|
-
LogWarning("Grant validation failed: Client has no allowed grants defined");
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Check if requested grant type is in allowed grants
|
|
33
|
-
bool isGrantAllowed = false;
|
|
34
|
-
foreach (var grant in allowedGrants)
|
|
35
|
-
{
|
|
36
|
-
if (grant?.ToString() == grantType?.ToString())
|
|
37
|
-
{
|
|
38
|
-
isGrantAllowed = true;
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
LogInformation($"Grant validation: grantType={grantType}, isAllowed={isGrantAllowed}");
|
|
44
|
-
|
|
45
|
-
return !isGrantAllowed;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
using System.Threading.Tasks;
|
|
2
|
-
using BBT.Workflow.Scripting;
|
|
3
|
-
using BBT.Workflow.Scripting.Functions;
|
|
4
|
-
|
|
5
|
-
/// <summary>
|
|
6
|
-
/// Rule: OTP verified successfully
|
|
7
|
-
/// Returns true if OTP was verified successfully
|
|
8
|
-
/// </summary>
|
|
9
|
-
public class OtpVerifiedRule : ScriptBase, IConditionMapping
|
|
10
|
-
{
|
|
11
|
-
public async Task<bool> Handler(ScriptContext context)
|
|
12
|
-
{
|
|
13
|
-
if (!HasProperty(context.Instance?.Data, "otpVerified"))
|
|
14
|
-
{
|
|
15
|
-
LogWarning("OtpVerifiedRule: otpVerified property not found");
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var otpVerified = context.Instance?.Data?.otpVerified;
|
|
20
|
-
|
|
21
|
-
if (otpVerified == true)
|
|
22
|
-
{
|
|
23
|
-
LogInformation("OtpVerifiedRule: OTP verified successfully");
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
LogWarning("OtpVerifiedRule: OTP verification failed");
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
using System.Threading.Tasks;
|
|
2
|
-
using BBT.Workflow.Scripting;
|
|
3
|
-
using BBT.Workflow.Scripting.Functions;
|
|
4
|
-
|
|
5
|
-
/// <summary>
|
|
6
|
-
/// Rule: Push notification verified successfully
|
|
7
|
-
/// Returns true if push notification was approved by user
|
|
8
|
-
/// </summary>
|
|
9
|
-
public class PushVerifiedRule : ScriptBase, IConditionMapping
|
|
10
|
-
{
|
|
11
|
-
public async Task<bool> Handler(ScriptContext context)
|
|
12
|
-
{
|
|
13
|
-
if (!HasProperty(context.Instance?.Data, "pushVerified"))
|
|
14
|
-
{
|
|
15
|
-
LogWarning("PushVerifiedRule: pushVerified property not found");
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var pushVerified = context.Instance?.Data?.pushVerified;
|
|
20
|
-
|
|
21
|
-
if (pushVerified == true)
|
|
22
|
-
{
|
|
23
|
-
LogInformation("PushVerifiedRule: Push notification verified successfully");
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
LogWarning("PushVerifiedRule: Push verification failed");
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
using System.Threading.Tasks;
|
|
2
|
-
using BBT.Workflow.Scripting;
|
|
3
|
-
|
|
4
|
-
/// <summary>
|
|
5
|
-
/// Rule for reject transition
|
|
6
|
-
/// Workflow: person-upsert
|
|
7
|
-
/// State: draft
|
|
8
|
-
/// </summary>
|
|
9
|
-
public class RejectRule : IConditionMapping
|
|
10
|
-
{
|
|
11
|
-
public async Task<bool> Handler(ScriptContext context)
|
|
12
|
-
{
|
|
13
|
-
// TODO: Implement actual rule logic
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
using System.Threading.Tasks;
|
|
2
|
-
using BBT.Workflow.Scripting;
|
|
3
|
-
using System.Linq;
|
|
4
|
-
using System.Collections.Generic;
|
|
5
|
-
using BBT.Workflow.Scripting.Functions;
|
|
6
|
-
public class ScopeValidationFailRule : ScriptBase, IConditionMapping
|
|
7
|
-
{
|
|
8
|
-
public async Task<bool> Handler(ScriptContext context)
|
|
9
|
-
{
|
|
10
|
-
// Get client data from previous validation
|
|
11
|
-
var clientFromDb = context.Instance?.Data?.client;
|
|
12
|
-
|
|
13
|
-
// Get requested scopes from input
|
|
14
|
-
var requestedScopes = context.Instance?.Data?.scopes;
|
|
15
|
-
|
|
16
|
-
if (clientFromDb == null)
|
|
17
|
-
{
|
|
18
|
-
LogWarning("Scope validation failed: Missing client data");
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (requestedScopes == null)
|
|
23
|
-
{
|
|
24
|
-
LogWarning("Scope validation failed: No scopes requested");
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Get allowed scopes from client
|
|
29
|
-
var allowedScopes = clientFromDb?.data?.data?.allowedScopeGroups;
|
|
30
|
-
|
|
31
|
-
if (allowedScopes == null)
|
|
32
|
-
{
|
|
33
|
-
LogWarning("Scope validation failed: Client has no allowed scopes defined");
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Convert to lists for easier comparison
|
|
38
|
-
List<string> requestedList = new List<string>();
|
|
39
|
-
foreach (var scope in requestedScopes)
|
|
40
|
-
{
|
|
41
|
-
requestedList.Add(scope?.ToString());
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
List<string> allowedList = new List<string>();
|
|
45
|
-
foreach (var scope in allowedScopes)
|
|
46
|
-
{
|
|
47
|
-
allowedList.Add(scope?.ToString());
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Check if all requested scopes are in allowed scopes
|
|
51
|
-
bool allScopesAllowed = true;
|
|
52
|
-
foreach (var requestedScope in requestedList)
|
|
53
|
-
{
|
|
54
|
-
if (!allowedList.Contains(requestedScope))
|
|
55
|
-
{
|
|
56
|
-
LogWarning($"Scope validation failed: Requested scope '{requestedScope}' not allowed for client");
|
|
57
|
-
allScopesAllowed = false;
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
LogInformation($"Scope validation: requestedScopes={string.Join(",", requestedList)}, allAllowed={allScopesAllowed}");
|
|
63
|
-
|
|
64
|
-
return !allScopesAllowed;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|