@burgan-tech/morph-idm-runtime 0.0.0

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.
Files changed (206) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +245 -0
  3. package/burgan-tech-morph-idm-runtime-0.0.0.tgz +0 -0
  4. package/morph-idm/Extensions/.gitkeep +0 -0
  5. package/morph-idm/Functions/.gitkeep +0 -0
  6. package/morph-idm/Functions/user/function-validate-user.json +31 -0
  7. package/morph-idm/Functions/user/src/ValidateUser.csx +39 -0
  8. package/morph-idm/Mappings/device-register-evaluate-get-device-request.mapper.json +319 -0
  9. package/morph-idm/Mappings/device-register-evaluate-get-device-response.mapper.json +761 -0
  10. package/morph-idm/Mappings/device-register-new-device-call-device-start-request.mapper.json +762 -0
  11. package/morph-idm/Mappings/device-register-start.mapper.json +971 -0
  12. package/morph-idm/Mappings/device-start-request.mapper.json +20 -0
  13. package/morph-idm/Mappings/device-start.mapper.json +896 -0
  14. package/morph-idm/Mappings/device-update-request.mapper.json +883 -0
  15. package/morph-idm/Mappings/token-start-request.mapper.json +436 -0
  16. package/morph-idm/Schemas/approval-matrix/approval-matrix-master-1.0.0.json +98 -0
  17. package/morph-idm/Schemas/approval-matrix/approval-matrix-update-1.0.0.json +85 -0
  18. package/morph-idm/Schemas/client/client-master-1.0.0.json +293 -0
  19. package/morph-idm/Schemas/client/client-update-master-1.0.0.json +201 -0
  20. package/morph-idm/Schemas/consent/consent-master-1.0.0.json +151 -0
  21. package/morph-idm/Schemas/device/device-master-1.0.0.json +433 -0
  22. package/morph-idm/Schemas/device/device-register-master-1.0.0.json +300 -0
  23. package/morph-idm/Schemas/device/device-register-start-1.0.0.json +270 -0
  24. package/morph-idm/Schemas/device/device-start-1.0.0.json +281 -0
  25. package/morph-idm/Schemas/device/device-update-1.0.0.json +275 -0
  26. package/morph-idm/Schemas/headers-1.0.0.json +245 -0
  27. package/morph-idm/Schemas/organization/organization-master-1.0.0.json +386 -0
  28. package/morph-idm/Schemas/organization/organization-update-1.0.0.json +60 -0
  29. package/morph-idm/Schemas/privilege/privilege-master-1.0.0.json +84 -0
  30. package/morph-idm/Schemas/privilege/privilege-update-1.0.0.json +76 -0
  31. package/morph-idm/Schemas/scope/scope-group-master-1.0.0.json +52 -0
  32. package/morph-idm/Schemas/scope/scope-master-1.0.0.json +120 -0
  33. package/morph-idm/Schemas/token/token-master-1.0.0.json +346 -0
  34. package/morph-idm/Schemas/token/token-start-1.0.0.json +50 -0
  35. package/morph-idm/Schemas/transaction-limit/transaction-limit-master-1.0.0.json +175 -0
  36. package/morph-idm/Schemas/transaction-limit/transaction-limit-update-1.0.0.json +90 -0
  37. package/morph-idm/Schemas/user/person-master-1.0.0.json +211 -0
  38. package/morph-idm/Schemas/user/user-master-1.0.0.json +121 -0
  39. package/morph-idm/Tasks/.gitkeep +0 -0
  40. package/morph-idm/Tasks/call-device-start-1.0.0.json +21 -0
  41. package/morph-idm/Tasks/call-device-update-1.0.0.json +21 -0
  42. package/morph-idm/Tasks/client/client-create-rsa.json +26 -0
  43. package/morph-idm/Tasks/client/client-password-generator.json +14 -0
  44. package/morph-idm/Tasks/client/get-client-by-task.json +18 -0
  45. package/morph-idm/Tasks/consent/get-consent-by-task.json +18 -0
  46. package/morph-idm/Tasks/consent/get-multi-consents-by-task.json +25 -0
  47. package/morph-idm/Tasks/device/get-device-by-task.json +18 -0
  48. package/morph-idm/Tasks/get-device-1.0.0.json +20 -0
  49. package/morph-idm/Tasks/scope/get-scope-by-task.json +17 -0
  50. package/morph-idm/Tasks/scope/scope-by-user-task.json +25 -0
  51. package/morph-idm/Tasks/scope/scope-details-task.json +25 -0
  52. package/morph-idm/Tasks/token/send-token-to-main.json +20 -0
  53. package/morph-idm/Tasks/token/token-create-jwt.json +27 -0
  54. package/morph-idm/Tasks/user/get-user-by-task.json +18 -0
  55. package/morph-idm/Tasks/user/send-otp-task.json +25 -0
  56. package/morph-idm/Tasks/user/send-push-task.json +22 -0
  57. package/morph-idm/Tasks/user/user-password-generator.json +26 -0
  58. package/morph-idm/Tasks/user/verify-otp-task.json +22 -0
  59. package/morph-idm/Tasks/user/verify-push-task.json +22 -0
  60. package/morph-idm/Views/.gitkeep +0 -0
  61. package/morph-idm/Workflows/.gitkeep +0 -0
  62. package/morph-idm/Workflows/approval-matrix/approval-1.0.0.json +452 -0
  63. package/morph-idm/Workflows/approval-matrix/approval-matrix-1.0.0.json +184 -0
  64. package/morph-idm/Workflows/client/client-1.0.0.json +257 -0
  65. package/morph-idm/Workflows/client/client-update-1.0.0.json +202 -0
  66. package/morph-idm/Workflows/client/execute/client.http +377 -0
  67. package/morph-idm/Workflows/client/src/ClientCreateRsa.csx +198 -0
  68. package/morph-idm/Workflows/client/src/ClientCreateRsaByScript.csx +118 -0
  69. package/morph-idm/Workflows/client/src/CreateRsaByHttpCallMapping.csx +223 -0
  70. package/morph-idm/Workflows/client/src/PasswordGeneratorMapping.csx +26 -0
  71. package/morph-idm/Workflows/client/src/RsaExistsRule.csx +44 -0
  72. package/morph-idm/Workflows/client-manager/client-manager-1.0.0.json +217 -0
  73. package/morph-idm/Workflows/client-manager/execute/client-manager.http +214 -0
  74. package/morph-idm/Workflows/client-manager/src/ClientCreatedRule.csx +28 -0
  75. package/morph-idm/Workflows/client-manager/src/ClientExistsRule.csx +25 -0
  76. package/morph-idm/Workflows/client-manager/src/CreateClientSubFlowMapping.csx +63 -0
  77. package/morph-idm/Workflows/client-manager/src/GetClientForManagerMapping.csx +59 -0
  78. package/morph-idm/Workflows/consent/consent-1.0.0.json +424 -0
  79. package/morph-idm/Workflows/consent/execute/README.md +167 -0
  80. package/morph-idm/Workflows/consent/execute/consent-invitation-flow.http +283 -0
  81. package/morph-idm/Workflows/consent/execute/create-consent.http +780 -0
  82. package/morph-idm/Workflows/consent/src/AutoConsentRule.csx +29 -0
  83. package/morph-idm/Workflows/consent/src/ConsentTimeoutTimer.csx +14 -0
  84. package/morph-idm/Workflows/consent-selection/consent-selection-1.0.0.json +331 -0
  85. package/morph-idm/Workflows/consent-selection/src/AutoConsentCreatedRule.csx +28 -0
  86. package/morph-idm/Workflows/consent-selection/src/ConsentFetchMapping.csx +82 -0
  87. package/morph-idm/Workflows/consent-selection/src/ConsentSelectedMapping.csx +70 -0
  88. package/morph-idm/Workflows/consent-selection/src/CreateAutoConsentMapping.csx +150 -0
  89. package/morph-idm/Workflows/consent-selection/src/MultipleConsentsRule.csx +31 -0
  90. package/morph-idm/Workflows/consent-selection/src/NoConsentEligibleRule.csx +44 -0
  91. package/morph-idm/Workflows/consent-selection/src/SingleConsentRule.csx +45 -0
  92. package/morph-idm/Workflows/device/device-1.0.0.json +261 -0
  93. package/morph-idm/Workflows/device/device-migration-1.0.0.json +213 -0
  94. package/morph-idm/Workflows/device/device-register-1.0.0-documentation.md +646 -0
  95. package/morph-idm/Workflows/device/device-register-1.0.0-documentation.svg +36 -0
  96. package/morph-idm/Workflows/device/device-register-1.0.0.json +185 -0
  97. package/morph-idm/Workflows/device/execute/device-android.http +260 -0
  98. package/morph-idm/Workflows/device/execute/device-huawei.http +219 -0
  99. package/morph-idm/Workflows/device/execute/device-ios.http +325 -0
  100. package/morph-idm/Workflows/device/execute/device-web.http +284 -0
  101. package/morph-idm/Workflows/device/src/DeviceCreatedRule.csx +32 -0
  102. package/morph-idm/Workflows/device/src/DeviceFoundRule.csx +32 -0
  103. package/morph-idm/Workflows/device/src/DeviceNotFoundRule.csx +28 -0
  104. package/morph-idm/Workflows/device/src/DeviceUpdatedRule.csx +26 -0
  105. package/morph-idm/Workflows/device/src/NoUpdateRule.csx +19 -0
  106. package/morph-idm/Workflows/device/src/ReInstallRule.csx +19 -0
  107. package/morph-idm/Workflows/document-validation/_FF_document-validation.json +423 -0
  108. package/morph-idm/Workflows/document-validation/src/ApproveRule.csx +16 -0
  109. package/morph-idm/Workflows/document-validation/src/ClassifyRule.csx +16 -0
  110. package/morph-idm/Workflows/document-validation/src/ExtractRule.csx +16 -0
  111. package/morph-idm/Workflows/document-validation/src/HitlRule.csx +16 -0
  112. package/morph-idm/Workflows/document-validation/src/RejectRule.csx +16 -0
  113. package/morph-idm/Workflows/document-validation/src/RunOcrRule.csx +16 -0
  114. package/morph-idm/Workflows/document-validation/src/StartRule.csx +16 -0
  115. package/morph-idm/Workflows/document-validation/src/ToAggregateRule.csx +16 -0
  116. package/morph-idm/Workflows/document-validation/src/ToFraudRule.csx +16 -0
  117. package/morph-idm/Workflows/document-validation/src/ToReferentialRule.csx +16 -0
  118. package/morph-idm/Workflows/document-validation/src/ToSemanticRule.csx +16 -0
  119. package/morph-idm/Workflows/document-validation/src/ToStructuralRule.csx +16 -0
  120. package/morph-idm/Workflows/organization/execute/create-organization.http +280 -0
  121. package/morph-idm/Workflows/organization/organization-1.0.0-documentation.md +616 -0
  122. package/morph-idm/Workflows/organization/organization-1.0.0.json +181 -0
  123. package/morph-idm/Workflows/privilege/privilege-1.0.0.json +185 -0
  124. package/morph-idm/Workflows/scope/execute/scope-24-7-access.http +131 -0
  125. package/morph-idm/Workflows/scope/execute/scope-business-hours.http +138 -0
  126. package/morph-idm/Workflows/scope/execute/scope-corporate.http +165 -0
  127. package/morph-idm/Workflows/scope/execute/scope-individual.http +133 -0
  128. package/morph-idm/Workflows/scope/execute/scope-lifecycle-test.http +133 -0
  129. package/morph-idm/Workflows/scope/execute/scope-multi-systems.http +159 -0
  130. package/morph-idm/Workflows/scope/execute/scope-restricted.http +143 -0
  131. package/morph-idm/Workflows/scope/scope-1.0.0.json +142 -0
  132. package/morph-idm/Workflows/scope/scope-group-1.0.0.json +144 -0
  133. package/morph-idm/Workflows/scope-group/execute/create-scope-group.http +222 -0
  134. package/morph-idm/Workflows/token/execute/README.md +450 -0
  135. package/morph-idm/Workflows/token/execute/token.http +236 -0
  136. package/morph-idm/Workflows/token/oauth-authentication-workflow.json +406 -0
  137. package/morph-idm/Workflows/token/password-subflow.json +173 -0
  138. package/morph-idm/Workflows/token/scope-cdc-worker.1.0.0.json +46 -0
  139. package/morph-idm/Workflows/token/src/CreateRsaJwtMapping.csx +208 -0
  140. package/morph-idm/Workflows/token/src/ExpireTokenTimer.csx +14 -0
  141. package/morph-idm/Workflows/token/src/PrepareAuthorizationCodeRule.csx +16 -0
  142. package/morph-idm/Workflows/token/src/RequestInappropriateRule.csx +16 -0
  143. package/morph-idm/Workflows/token/src/SendJwtToMainMapping.csx +167 -0
  144. package/morph-idm/Workflows/token/token-1.0.0.json +356 -0
  145. package/morph-idm/Workflows/token/token-1.0.0.openapi.json.md +707 -0
  146. package/morph-idm/Workflows/token/token-exchange.1.0.0.json +45 -0
  147. package/morph-idm/Workflows/transaction-limit/transaction-limit-1.0.0.json +244 -0
  148. package/morph-idm/Workflows/transaction-limit/transaction-limit-authorization.json +502 -0
  149. package/morph-idm/Workflows/transaction-limit/transaction-limit-capture.json +142 -0
  150. package/morph-idm/Workflows/user/execute/README-LOGIN.md +535 -0
  151. package/morph-idm/Workflows/user/execute/create-user-1234567890.http +116 -0
  152. package/morph-idm/Workflows/user/execute/create-user-minimal.http +22 -0
  153. package/morph-idm/Workflows/user/execute/create-user-person-password.http +130 -0
  154. package/morph-idm/Workflows/user/execute/create-user-person.http +249 -0
  155. package/morph-idm/Workflows/user/execute/create-user-system.http +16 -0
  156. package/morph-idm/Workflows/user/execute/user-login.http +583 -0
  157. package/morph-idm/Workflows/user/execute/user-requests.http +51 -0
  158. package/morph-idm/Workflows/user/person-1.0.0.json +140 -0
  159. package/morph-idm/Workflows/user/person-cdc-worker.1.0.0.json +46 -0
  160. package/morph-idm/Workflows/user/person-upsert-1.0.0.json +129 -0
  161. package/morph-idm/Workflows/user/src/ApproveRule.csx +16 -0
  162. package/morph-idm/Workflows/user/src/AutoConsentCreatedRule.csx +20 -0
  163. package/morph-idm/Workflows/user/src/AutoConsentRequiredRule.csx +77 -0
  164. package/morph-idm/Workflows/user/src/CheckDeviceByUserReferenceMapping.csx +66 -0
  165. package/morph-idm/Workflows/user/src/ClientValidationFailRule.csx +28 -0
  166. package/morph-idm/Workflows/user/src/ClientValidationRule.csx +25 -0
  167. package/morph-idm/Workflows/user/src/ConsentSelectedRule.csx +24 -0
  168. package/morph-idm/Workflows/user/src/ConsentValidationRule.csx +36 -0
  169. package/morph-idm/Workflows/user/src/CreateAutoConsentMapping.csx +171 -0
  170. package/morph-idm/Workflows/user/src/DeviceFoundForLoginRule.csx +32 -0
  171. package/morph-idm/Workflows/user/src/DeviceNotFoundForLoginRule.csx +31 -0
  172. package/morph-idm/Workflows/user/src/GetClientMapping.csx +45 -0
  173. package/morph-idm/Workflows/user/src/GetConsentMapping.csx +27 -0
  174. package/morph-idm/Workflows/user/src/GetDeviceMapping.csx +52 -0
  175. package/morph-idm/Workflows/user/src/GetScopeMapping.csx +139 -0
  176. package/morph-idm/Workflows/user/src/GetScopesByUserMapping.csx +137 -0
  177. package/morph-idm/Workflows/user/src/GetUserMapping.csx +39 -0
  178. package/morph-idm/Workflows/user/src/GrantValidationFailRule.csx +48 -0
  179. package/morph-idm/Workflows/user/src/GrantValidationRule.csx +45 -0
  180. package/morph-idm/Workflows/user/src/IsIbWebClientWithDeviceRule.csx +42 -0
  181. package/morph-idm/Workflows/user/src/NonIbWebClientWithDeviceRule.csx +42 -0
  182. package/morph-idm/Workflows/user/src/OtpSentRule.csx +31 -0
  183. package/morph-idm/Workflows/user/src/OtpVerifiedRule.csx +31 -0
  184. package/morph-idm/Workflows/user/src/PushSentRule.csx +31 -0
  185. package/morph-idm/Workflows/user/src/PushVerifiedRule.csx +31 -0
  186. package/morph-idm/Workflows/user/src/RejectRule.csx +16 -0
  187. package/morph-idm/Workflows/user/src/ScopeFetchedRule.csx +35 -0
  188. package/morph-idm/Workflows/user/src/ScopeValidationFailRule.csx +67 -0
  189. package/morph-idm/Workflows/user/src/ScopeValidationRule.csx +67 -0
  190. package/morph-idm/Workflows/user/src/SendOtpMapping.csx +94 -0
  191. package/morph-idm/Workflows/user/src/SendPushMapping.csx +90 -0
  192. package/morph-idm/Workflows/user/src/TokenGenerationSuccessRule.csx +28 -0
  193. package/morph-idm/Workflows/user/src/TriggerConsentSelectionAsSubFlowMapping.csx +63 -0
  194. package/morph-idm/Workflows/user/src/TriggerTokenWorkflowAsSubFlowMapping.csx +42 -0
  195. package/morph-idm/Workflows/user/src/UserPasswordGeneratorMapping.csx +190 -0
  196. package/morph-idm/Workflows/user/src/UserValidationFailRule.csx +36 -0
  197. package/morph-idm/Workflows/user/src/UserValidationRule.csx +38 -0
  198. package/morph-idm/Workflows/user/src/VerifyOtpMapping.csx +65 -0
  199. package/morph-idm/Workflows/user/src/VerifyPushMapping.csx +65 -0
  200. package/morph-idm/Workflows/user/user-1.0.0.json +400 -0
  201. package/morph-idm/Workflows/user/user-force-update.1.0.0.json +46 -0
  202. package/morph-idm/Workflows/user/user-login-certificate.1.0.0.json +46 -0
  203. package/morph-idm/Workflows/user/user-login.1.0.0.json +1144 -0
  204. package/morph-idm/Workflows/user/user-password-reset.1.0.0.json +45 -0
  205. package/package.json +21 -0
  206. package/vnext.config.json +58 -0
@@ -0,0 +1,450 @@
1
+ # Token Workflow - OAuth2 Token Management
2
+
3
+ Bu klasör, OAuth2 Token workflow'u için HTTP test dosyaları ve örnek payload'ları içerir.
4
+
5
+ ## 📁 Dosyalar
6
+
7
+ ### OAuth2 Grant Type Örnekleri
8
+
9
+ #### **token-authorization-code-example.json**
10
+ Authorization Code Flow için örnek payload (Web/Mobile apps için)
11
+
12
+ #### **token-client-credentials-example.json**
13
+ Client Credentials Flow için örnek payload (Service-to-service için)
14
+
15
+ #### **token-refresh-example.json**
16
+ Refresh Token Flow için örnek payload
17
+
18
+ #### **token.http**
19
+ Tüm OAuth2 akışları için HTTP test dosyası
20
+
21
+ ---
22
+
23
+ ## 🔄 OAuth2 Token Workflow Akışı
24
+
25
+ ```
26
+ start
27
+ ↓
28
+ evaluated (Initial validation)
29
+ ├─► prepare-authorization-code (rule) → waiting-redeem
30
+ └─► request-inappropriate (rule) → not-applicable ✗
31
+
32
+ waiting-redeem (Authorization code issued)
33
+ ├─► redeem (manual) → active ✓
34
+ └─► code-timeout (timer) → code-expired ✗
35
+
36
+ active (Token is valid and usable)
37
+ ├─► refresh (manual) → active (new tokens)
38
+ ├─► revoke (admin) → token-revoked ✗
39
+ ├─► revoke-by-user (user) → token-revoked ✗
40
+ ├─► fraud-suspicious (system) → token-revoked-by-fraud ✗
41
+ └─► expire-token (timer) → token-expired ✗
42
+ ```
43
+
44
+ ---
45
+
46
+ ## 🎯 OAuth2 Grant Types
47
+
48
+ ### 1. Authorization Code Flow
49
+ **Kullanım:** Web ve mobil uygulamalar için en güvenli flow
50
+
51
+ **Akış:**
52
+ 1. User authorization → Authorization code üretilir
53
+ 2. `waiting-redeem` state (code kullanılmayı bekler)
54
+ 3. Code exchange → `redeem` transition → Access + Refresh token
55
+ 4. `active` state (token kullanılabilir)
56
+
57
+ **Test:**
58
+ ```http
59
+ POST /api/v1/idm/workflows/token/instances/start
60
+ ```
61
+
62
+ **Payload:**
63
+ ```json
64
+ {
65
+ "key": "unique-token-key",
66
+ "attributes": {
67
+ "client": "web18",
68
+ "user": "user-john-doe",
69
+ "consent": "consent-john-doe-...",
70
+ "scope": "openid profile accounts.read"
71
+ }
72
+ }
73
+ ```
74
+
75
+ **Additional OAuth2 Parameters:**
76
+ PKCE and other OAuth2 parameters are handled by the workflow internally or via HTTP headers/query params. The start schema only requires the core fact keys.
77
+
78
+ ---
79
+
80
+ ### 2. Client Credentials Flow
81
+ **Kullanım:** Service-to-service authentication (kullanıcı yok)
82
+
83
+ **Akış:**
84
+ 1. Client credentials → Direct token generation
85
+ 2. `active` state (no authorization code needed)
86
+
87
+ **Test:**
88
+ ```http
89
+ POST /api/v1/idm/workflows/token/instances/start
90
+ ```
91
+
92
+ **Payload:**
93
+ ```json
94
+ {
95
+ "key": "unique-token-key",
96
+ "attributes": {
97
+ "client": "backend-service-client",
98
+ "user": "system-service-user",
99
+ "consent": "system-service-consent",
100
+ "scope": "api.read api.write"
101
+ }
102
+ }
103
+ ```
104
+ **Note:** Schema requires user and consent even for client_credentials flow.
105
+
106
+ **Not:** User ve consent gerekmez, sadece client authentication.
107
+
108
+ ---
109
+
110
+ ### 3. Refresh Token Flow
111
+ **Kullanım:** Expired access token'ı yenilemek için
112
+
113
+ **Akış:**
114
+ 1. Valid refresh token → New access token + refresh token
115
+ 2. `active` state remains (token rotation)
116
+
117
+ **Test:**
118
+ ```http
119
+ POST /api/v1/idm/workflows/token/instances/{id}/transitions/refresh
120
+ ```
121
+
122
+ **Payload:**
123
+ ```json
124
+ {
125
+ "attributes": {
126
+ "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
127
+ }
128
+ }
129
+ ```
130
+
131
+ ---
132
+
133
+ ## 🔒 Security Features
134
+
135
+ ### Token Expiration
136
+ ```json
137
+ {
138
+ "accessToken": "...",
139
+ "expiresIn": 3600, // 1 hour
140
+ "refreshToken": "...",
141
+ "refreshExpiresIn": 2592000 // 30 days
142
+ }
143
+ ```
144
+
145
+ ### Token Revocation
146
+ **User-initiated:**
147
+ ```http
148
+ POST .../transitions/revoke-by-user
149
+ ```
150
+
151
+ **Admin-initiated:**
152
+ ```http
153
+ POST .../transitions/revoke
154
+ ```
155
+
156
+ **Fraud detection:**
157
+ ```http
158
+ POST .../transitions/fraud-suspicious
159
+ ```
160
+
161
+ ---
162
+
163
+ ## 📊 State Machine
164
+
165
+ ### States
166
+
167
+ #### **evaluated** (stateType: 1 - Start)
168
+ - Initial state
169
+ - Validates client, user, consent
170
+ - Checks scopes
171
+ - **Transitions:**
172
+ - ✅ `prepare-authorization-code` (auto) → waiting-redeem
173
+ - ❌ `request-inappropriate` (auto) → not-applicable
174
+
175
+ #### **waiting-redeem** (stateType: 2 - Normal)
176
+ - Authorization code issued
177
+ - Waiting for code exchange
178
+ - **Transitions:**
179
+ - ✅ `redeem` (manual) → active
180
+ - ❌ `code-timeout` (timer) → code-expired
181
+
182
+ #### **active** (stateType: 2 - Normal)
183
+ - Token active and usable
184
+ - Access token + Refresh token available
185
+ - **Transitions:**
186
+ - 🔄 `refresh` (manual) → active
187
+ - 🚫 `revoke` (manual) → token-revoked
188
+ - 🚫 `revoke-by-user` (manual) → token-revoked
189
+ - 🚫 `fraud-suspicious` (manual) → token-revoked-by-fraud
190
+ - ⏰ `expire-token` (timer) → token-expired
191
+
192
+ #### **not-applicable** (stateType: 3 - Finish)
193
+ - Request invalid or inappropriate
194
+ - Client/consent/scope validation failed
195
+
196
+ #### **code-expired** (stateType: 3 - Finish)
197
+ - Authorization code expired without being redeemed
198
+
199
+ #### **token-revoked** (stateType: 3 - Finish)
200
+ - Token revoked by user or admin
201
+
202
+ #### **token-revoked-by-fraud** (stateType: 3 - Finish)
203
+ - Token revoked due to fraud detection
204
+
205
+ #### **token-expired** (stateType: 3 - Finish)
206
+ - Access token expired
207
+ - Refresh token can be used to get new tokens
208
+
209
+ ---
210
+
211
+ ## 🧪 Test Senaryoları
212
+
213
+ ### Senaryo 1: Başarılı Authorization Code Flow
214
+ ```json
215
+ {
216
+ "attributes": {
217
+ "client": "web18", // ✓ Valid client (fact key)
218
+ "user": "user-john-doe", // ✓ Valid user (fact key)
219
+ "consent": "consent-john-doe-...", // ✓ Valid consent (fact key)
220
+ "scope": "openid profile accounts.read" // ✓ Allowed scopes (space-separated)
221
+ }
222
+ }
223
+ ```
224
+ **Result:** `waiting-redeem` → `redeem` → `active` ✅
225
+
226
+ ### Senaryo 2: Invalid Client
227
+ ```json
228
+ {
229
+ "attributes": {
230
+ "client": "non-existent-client", // ✗ Invalid (fact key)
231
+ "user": "user-john-doe",
232
+ "consent": "consent-john-doe-...",
233
+ "scope": "openid profile"
234
+ }
235
+ }
236
+ ```
237
+ **Result:** `not-applicable` ❌
238
+
239
+ ### Senaryo 3: Invalid Consent
240
+ ```json
241
+ {
242
+ "attributes": {
243
+ "client": "web18",
244
+ "user": "user-john-doe",
245
+ "consent": "non-existent-consent", // ✗ Invalid (fact key)
246
+ "scope": "openid profile"
247
+ }
248
+ }
249
+ ```
250
+ **Result:** `not-applicable` ❌
251
+
252
+ ### Senaryo 4: Client Credentials (Success)
253
+ ```json
254
+ {
255
+ "attributes": {
256
+ "client": "backend-service-client", // ✓ Valid (fact key)
257
+ "user": "system-service-user", // ✓ Required by schema
258
+ "consent": "system-service-consent", // ✓ Required by schema
259
+ "scope": "api.read api.write" // ✓ Allowed (space-separated)
260
+ }
261
+ }
262
+ ```
263
+ **Result:** `active` ✅
264
+
265
+ ### Senaryo 5: Token Refresh
266
+ **Note:** Refresh transition is not part of start schema, it's a state transition.
267
+ ```http
268
+ POST /instances/{id}/transitions/refresh
269
+ {
270
+ "attributes": {
271
+ "refreshToken": "valid-refresh-token-xyz..."
272
+ }
273
+ }
274
+ ```
275
+ **Result:** `active` (new tokens) ✅
276
+
277
+ ### Senaryo 6: Token Revocation
278
+ ```json
279
+ {
280
+ "reason": "User logged out"
281
+ }
282
+ ```
283
+ **Result:** `token-revoked` 🚫
284
+
285
+ ---
286
+
287
+ ## 📋 Required Payload Fields
288
+
289
+ ### Authorization Code Flow
290
+ ```json
291
+ {
292
+ "key": "unique-token-key",
293
+ "tags": ["oauth2", "authorization-code"],
294
+ "attributes": {
295
+ "client": "web18", // Required (string - fact key)
296
+ "user": "user-john-doe", // Required (string - fact key)
297
+ "consent": "consent-john-doe-...", // Required (string - fact key)
298
+ "scope": "openid profile accounts.read" // Required (space-separated string)
299
+ }
300
+ }
301
+ ```
302
+
303
+ **Schema Definition:** `token-start-1.0.0.json`
304
+ - All fields are **strings** (fact keys)
305
+ - `scope` is space-separated string (not array)
306
+ - No additional properties allowed (additionalProperties: false)
307
+
308
+ ### Client Credentials Flow
309
+ ```json
310
+ {
311
+ "key": "unique-token-key",
312
+ "tags": ["oauth2", "client-credentials"],
313
+ "attributes": {
314
+ "client": "backend-service-client", // Required (string - fact key)
315
+ "user": "system-service-user", // Required (string - fact key)
316
+ "consent": "system-service-consent", // Required (string - fact key)
317
+ "scope": "api.read api.write" // Required (space-separated string)
318
+ }
319
+ }
320
+ ```
321
+
322
+ **Note:** Per schema definition, user and consent are required even for client_credentials flow.
323
+
324
+ ### Refresh Token Flow (Transition)
325
+ ```http
326
+ POST /instances/{id}/transitions/refresh
327
+ Content-Type: application/json
328
+
329
+ {
330
+ "attributes": {
331
+ "refreshToken": "eyJ..." // Required
332
+ }
333
+ }
334
+ ```
335
+ **Note:** Refresh is not a start transition, it's called on existing token instance.
336
+
337
+ ---
338
+
339
+ ## 🚀 Hızlı Test
340
+
341
+ ### 1. API'yi Başlat
342
+ ```bash
343
+ http://localhost:4201
344
+ ```
345
+
346
+ ### 2. Önkoşulları Hazırla
347
+ Aşağıdaki instance'lar mevcut ve active olmalı:
348
+ - Client: `web18` veya `backend-service-client`
349
+ - User: `user-john-doe`
350
+ - Consent: `consent-john-doe-mobile-banking-customer-123`
351
+
352
+ ### 3. Authorization Code Flow Test
353
+ ```http
354
+ # 1. Start workflow
355
+ POST /api/v1/idm/workflows/token/instances/start
356
+
357
+ # 2. Check state (should be waiting-redeem)
358
+ GET /api/v1/idm/workflows/token/instances/{id}/functions/state
359
+
360
+ # 3. Redeem code
361
+ POST /api/v1/idm/workflows/token/instances/{id}/transitions/redeem
362
+
363
+ # 4. Verify active (should have access + refresh token)
364
+ GET /api/v1/idm/workflows/token/instances/{id}/functions/data
365
+ ```
366
+
367
+ ### 4. Client Credentials Flow Test
368
+ ```http
369
+ # 1. Start workflow (goes directly to active)
370
+ POST /api/v1/idm/workflows/token/instances/start
371
+
372
+ # 2. Verify active
373
+ GET /api/v1/idm/workflows/token/instances/{id}/functions/data
374
+ ```
375
+
376
+ ---
377
+
378
+ ## 🔗 İlgili Workflow'lar
379
+ - **User Login** (`user-login-1.0.0.json`) - User authentication (calls token workflow)
380
+ - **Client Workflow** (`client-1.0.0.json`) - OAuth2 client management
381
+ - **User Workflow** (`user-1.0.0.json`) - User management
382
+ - **Consent Workflow** (`consent-1.0.0.json`) - User-Client-Scope consent
383
+
384
+ ---
385
+
386
+ ## 🔐 OAuth2 Token Response Format
387
+
388
+ ### Successful Token Response
389
+ ```json
390
+ {
391
+ "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
392
+ "tokenType": "Bearer",
393
+ "expiresIn": 3600,
394
+ "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
395
+ "refreshExpiresIn": 2592000,
396
+ "scope": "openid profile accounts.read",
397
+ "idToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." // OIDC only
398
+ }
399
+ ```
400
+
401
+ ### Usage
402
+ ```http
403
+ GET /api/protected-resource
404
+ Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
405
+ ```
406
+
407
+ ---
408
+
409
+ ## ⚠️ Önemli Notlar
410
+
411
+ 1. **Authorization Code:** Tek kullanımlık ve kısa ömürlü (genelde 10 dakika)
412
+ 2. **Access Token:** Kısa ömürlü (1-24 saat arası, default 1 saat)
413
+ 3. **Refresh Token:** Uzun ömürlü (7-30 gün arası, default 30 gün)
414
+ 4. **Fact Key References:** Client, user, consent are fact keys (string references)
415
+ 5. **Scope Format:** Space-separated string (not array)
416
+ 6. **Schema Validation:** token-start-1.0.0.json enforces structure
417
+
418
+ ---
419
+
420
+ ## 📚 OAuth2 Spec Compliance
421
+
422
+ - ✅ RFC 6749: OAuth 2.0 Authorization Framework
423
+ - ✅ RFC 6750: Bearer Token Usage
424
+ - ✅ RFC 7009: Token Revocation
425
+ - ✅ OpenID Connect Core 1.0 (when using `openid` scope)
426
+
427
+ ## 📋 Schema Reference
428
+
429
+ **Schema:** `token-start-1.0.0.json`
430
+
431
+ **Structure:**
432
+ ```json
433
+ {
434
+ "key": "unique-key",
435
+ "tags": ["optional", "tags"],
436
+ "attributes": {
437
+ "client": "string (fact key)", // Required
438
+ "user": "string (fact key)", // Required
439
+ "consent": "string (fact key)", // Required
440
+ "scope": "string (space-separated)" // Required
441
+ }
442
+ }
443
+ ```
444
+
445
+ **Important Notes:**
446
+ - All attributes are **strings** (fact keys to workflow instances)
447
+ - `scope` is **space-separated string**, not array
448
+ - Schema has `additionalProperties: false` - no extra fields allowed
449
+ - Required fields: `["client", "user", "consent", "scope"]`
450
+
@@ -0,0 +1,236 @@
1
+ ### Variables
2
+ @workflow = token
3
+
4
+ ### 1. Start Token Workflow - Authorization Code Flow
5
+ # @name startAuthCode
6
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/start?sync=true
7
+ Accept-Language: tr-TR
8
+ X-Request-Id: {{$guid}}
9
+ X-Device-Id: device-iphone-12-john
10
+ X-Token-Id: {{$guid}}
11
+ X-Device-Info: Mobile Banking App iOS/2.0
12
+ X-Forwarded-For: 192.168.1.100
13
+ user_reference: 12345678900
14
+ Content-Type: application/json
15
+
16
+ {
17
+ "key": "token-{{$timestamp}}-{{$randomInt 1000 9999}}",
18
+ "tags": [
19
+ "test",
20
+ "oauth2",
21
+ "authorization-code"
22
+ ],
23
+ "attributes": {
24
+ "client": "web18",
25
+ "user": "user-john-doe",
26
+ "consent": "consent-john-doe-mobile-banking-customer-123",
27
+ "scope": "openid profile accounts.read transactions.read"
28
+ }
29
+ }
30
+
31
+ ###
32
+ @tokenInstanceId = {{startAuthCode.response.body.id}}
33
+ @tokenKey = {{startAuthCode.response.body.key}}
34
+ @authorizationCode = {{startAuthCode.response.body.attributes.authorizationCode}}
35
+
36
+ ### 2. Get Token Instance State
37
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{tokenInstanceId}}/functions/state
38
+ Accept-Language: tr-TR
39
+ X-Request-Id: {{$guid}}
40
+ X-Device-Id: {{$guid}}
41
+ X-Token-Id: {{$guid}}
42
+ user_reference: 12345678900
43
+
44
+ ### 3. Get Token Instance Data
45
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{tokenInstanceId}}/functions/data
46
+ Accept-Language: tr-TR
47
+ X-Request-Id: {{$guid}}
48
+ X-Device-Id: {{$guid}}
49
+ X-Token-Id: {{$guid}}
50
+ user_reference: 12345678900
51
+
52
+ ### 4. Redeem Authorization Code (Exchange for tokens)
53
+ # Should be in waiting-redeem state
54
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{tokenInstanceId}}/transitions/redeem?sync=true
55
+ Accept-Language: tr-TR
56
+ X-Request-Id: {{$guid}}
57
+ X-Device-Id: device-iphone-12-john
58
+ X-Token-Id: {{$guid}}
59
+ X-Device-Info: Mobile Banking App iOS/2.0
60
+ X-Forwarded-For: 192.168.1.100
61
+ user_reference: 12345678900
62
+ Content-Type: application/json
63
+
64
+ {
65
+ "attributes": {
66
+ "authorizationCode": "{{authorizationCode}}",
67
+ "codeVerifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
68
+ "redirectUri": "https://app.example.com/callback"
69
+ }
70
+ }
71
+
72
+ ###
73
+ @accessToken = {{startAuthCode.response.body.attributes.accessToken}}
74
+ @refreshToken = {{startAuthCode.response.body.attributes.refreshToken}}
75
+
76
+ ### 5. Refresh Token Flow
77
+ # @name refreshTokenFlow
78
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{tokenInstanceId}}/transitions/refresh?sync=true
79
+ Accept-Language: tr-TR
80
+ X-Request-Id: {{$guid}}
81
+ X-Device-Id: device-iphone-12-john
82
+ X-Token-Id: {{$guid}}
83
+ X-Device-Info: Mobile Banking App iOS/2.0
84
+ X-Forwarded-For: 192.168.1.100
85
+ user_reference: 12345678900
86
+ Content-Type: application/json
87
+
88
+ {
89
+ "attributes": {
90
+ "refreshToken": "{{refreshToken}}"
91
+ }
92
+ }
93
+
94
+ ### 6. Revoke Token (User initiated)
95
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{tokenInstanceId}}/transitions/revoke-by-user?sync=true
96
+ Accept-Language: tr-TR
97
+ X-Request-Id: {{$guid}}
98
+ X-Device-Id: device-iphone-12-john
99
+ X-Token-Id: {{$guid}}
100
+ X-Device-Info: Mobile Banking App iOS/2.0
101
+ X-Forwarded-For: 192.168.1.100
102
+ user_reference: 12345678900
103
+ Content-Type: application/json
104
+
105
+ {
106
+ "attributes": {
107
+ "reason": "User logged out",
108
+ "revokedAt": "{{$datetime iso8601}}"
109
+ }
110
+ }
111
+
112
+ ### 7. Revoke Token (Admin/System initiated)
113
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{tokenInstanceId}}/transitions/revoke?sync=true
114
+ Accept-Language: tr-TR
115
+ X-Request-Id: {{$guid}}
116
+ X-Device-Id: {{$guid}}
117
+ X-Token-Id: {{$guid}}
118
+ user_reference: admin-001
119
+ Content-Type: application/json
120
+
121
+ {
122
+ "attributes": {
123
+ "reason": "Security policy violation",
124
+ "revokedBy": "admin-001",
125
+ "revokedAt": "{{$datetime iso8601}}"
126
+ }
127
+ }
128
+
129
+ ### 8. Fraud Detection - Revoke Token
130
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{tokenInstanceId}}/transitions/fraud-suspicious?sync=true
131
+ Accept-Language: tr-TR
132
+ X-Request-Id: {{$guid}}
133
+ X-Device-Id: {{$guid}}
134
+ X-Token-Id: {{$guid}}
135
+ user_reference: fraud-detection-system
136
+ Content-Type: application/json
137
+
138
+ {
139
+ "attributes": {
140
+ "fraudType": "suspicious-location",
141
+ "fraudScore": 95,
142
+ "fraudReason": "Login from unusual location",
143
+ "detectedAt": "{{$datetime iso8601}}",
144
+ "metadata": {
145
+ "ipAddress": "203.0.113.50",
146
+ "location": "Unknown Country",
147
+ "riskLevel": "high"
148
+ }
149
+ }
150
+ }
151
+
152
+ ### Test Scenario 1: Client Credentials Flow (Service-to-Service)
153
+ # @name clientCredentials
154
+ # Note: Schema requires user and consent even for client_credentials flow
155
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/start?sync=true
156
+ Accept-Language: en-US
157
+ X-Request-Id: {{$guid}}
158
+ X-Device-Id: backend-service-001
159
+ X-Token-Id: {{$guid}}
160
+ X-Device-Info: Backend Service/1.0
161
+ X-Forwarded-For: 10.0.0.50
162
+ user_reference: system
163
+ Content-Type: application/json
164
+
165
+ {
166
+ "key": "token-client-creds-{{$timestamp}}",
167
+ "tags": ["test", "oauth2", "client-credentials"],
168
+ "attributes": {
169
+ "client": "backend-service-client",
170
+ "user": "system-service-user",
171
+ "consent": "system-service-consent",
172
+ "scope": "api.read api.write"
173
+ }
174
+ }
175
+
176
+ ### Test Scenario 2: Invalid Client (should go to not-applicable)
177
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/start?sync=true
178
+ Accept-Language: en-US
179
+ X-Request-Id: {{$guid}}
180
+ X-Device-Id: unknown-device
181
+ X-Token-Id: {{$guid}}
182
+ X-Device-Info: Unknown/1.0
183
+ X-Forwarded-For: 192.168.1.200
184
+ user_reference: 12345678900
185
+ Content-Type: application/json
186
+
187
+ {
188
+ "key": "token-invalid-client-{{$timestamp}}",
189
+ "tags": ["test", "fail-path"],
190
+ "attributes": {
191
+ "client": "non-existent-client",
192
+ "user": "user-john-doe",
193
+ "consent": "consent-john-doe-mobile-banking-customer-123",
194
+ "scope": "openid profile"
195
+ }
196
+ }
197
+
198
+ ### Test Scenario 3: Invalid Consent (should go to not-applicable)
199
+ POST {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/start?sync=true
200
+ Accept-Language: en-US
201
+ X-Request-Id: {{$guid}}
202
+ X-Device-Id: device-test
203
+ X-Token-Id: {{$guid}}
204
+ X-Device-Info: Test Client/1.0
205
+ X-Forwarded-For: 192.168.1.150
206
+ user_reference: 12345678900
207
+ Content-Type: application/json
208
+
209
+ {
210
+ "key": "token-invalid-consent-{{$timestamp}}",
211
+ "tags": ["test", "fail-path"],
212
+ "attributes": {
213
+ "client": "web18",
214
+ "user": "user-john-doe",
215
+ "consent": "non-existent-consent",
216
+ "scope": "openid profile"
217
+ }
218
+ }
219
+
220
+ ### Get All Token Instances (Optional - for debugging)
221
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances
222
+ Accept-Language: tr-TR
223
+ X-Request-Id: {{$guid}}
224
+ X-Device-Id: {{$guid}}
225
+ X-Token-Id: {{$guid}}
226
+ user_reference: 12345678900
227
+
228
+ ### Get Specific Token by Key
229
+ GET {{baseUrl}}/api/{{apiVersion}}/{{domain}}/workflows/{{workflow}}/instances/{{tokenKey}}/functions/data
230
+ Accept-Language: tr-TR
231
+ X-Request-Id: {{$guid}}
232
+ X-Device-Id: {{$guid}}
233
+ X-Token-Id: {{$guid}}
234
+ user_reference: 12345678900
235
+
236
+