@celljs/security 3.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 (344) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/cell.yml +36 -0
  4. package/lib/browser/index.d.ts +2 -0
  5. package/lib/browser/index.d.ts.map +1 -0
  6. package/lib/browser/index.js +18 -0
  7. package/lib/browser/index.js.map +1 -0
  8. package/lib/browser/module.d.ts +4 -0
  9. package/lib/browser/module.d.ts.map +1 -0
  10. package/lib/browser/module.js +6 -0
  11. package/lib/browser/module.js.map +1 -0
  12. package/lib/browser/user/index.d.ts +3 -0
  13. package/lib/browser/user/index.d.ts.map +1 -0
  14. package/lib/browser/user/index.js +19 -0
  15. package/lib/browser/user/index.js.map +1 -0
  16. package/lib/browser/user/user-manager.d.ts +23 -0
  17. package/lib/browser/user/user-manager.d.ts.map +1 -0
  18. package/lib/browser/user/user-manager.js +125 -0
  19. package/lib/browser/user/user-manager.js.map +1 -0
  20. package/lib/browser/user/user-protocol.d.ts +10 -0
  21. package/lib/browser/user/user-protocol.d.ts.map +1 -0
  22. package/lib/browser/user/user-protocol.js +5 -0
  23. package/lib/browser/user/user-protocol.js.map +1 -0
  24. package/lib/common/index.d.ts +2 -0
  25. package/lib/common/index.d.ts.map +1 -0
  26. package/lib/common/index.js +18 -0
  27. package/lib/common/index.js.map +1 -0
  28. package/lib/common/security-protocol.d.ts +60 -0
  29. package/lib/common/security-protocol.d.ts.map +1 -0
  30. package/lib/common/security-protocol.js +33 -0
  31. package/lib/common/security-protocol.js.map +1 -0
  32. package/lib/node/access/access-decision-manager.d.ts +9 -0
  33. package/lib/node/access/access-decision-manager.d.ts.map +1 -0
  34. package/lib/node/access/access-decision-manager.js +56 -0
  35. package/lib/node/access/access-decision-manager.js.map +1 -0
  36. package/lib/node/access/access-decision-utils.d.ts +5 -0
  37. package/lib/node/access/access-decision-utils.d.ts.map +1 -0
  38. package/lib/node/access/access-decision-utils.js +23 -0
  39. package/lib/node/access/access-decision-utils.js.map +1 -0
  40. package/lib/node/access/access-decision-voter.d.ts +14 -0
  41. package/lib/node/access/access-decision-voter.d.ts.map +1 -0
  42. package/lib/node/access/access-decision-voter.js +86 -0
  43. package/lib/node/access/access-decision-voter.js.map +1 -0
  44. package/lib/node/access/access-protocol.d.ts +75 -0
  45. package/lib/node/access/access-protocol.d.ts.map +1 -0
  46. package/lib/node/access/access-protocol.js +20 -0
  47. package/lib/node/access/access-protocol.js.map +1 -0
  48. package/lib/node/access/action-name-resolver.d.ts +5 -0
  49. package/lib/node/access/action-name-resolver.d.ts.map +1 -0
  50. package/lib/node/access/action-name-resolver.js +30 -0
  51. package/lib/node/access/action-name-resolver.js.map +1 -0
  52. package/lib/node/access/index.d.ts +12 -0
  53. package/lib/node/access/index.d.ts.map +1 -0
  54. package/lib/node/access/index.js +28 -0
  55. package/lib/node/access/index.js.map +1 -0
  56. package/lib/node/access/jexl-engine-provider.d.ts +6 -0
  57. package/lib/node/access/jexl-engine-provider.d.ts.map +1 -0
  58. package/lib/node/access/jexl-engine-provider.js +25 -0
  59. package/lib/node/access/jexl-engine-provider.js.map +1 -0
  60. package/lib/node/access/method-advice.d.ts +17 -0
  61. package/lib/node/access/method-advice.d.ts.map +1 -0
  62. package/lib/node/access/method-advice.js +81 -0
  63. package/lib/node/access/method-advice.js.map +1 -0
  64. package/lib/node/access/policy-provider.d.ts +17 -0
  65. package/lib/node/access/policy-provider.d.ts.map +1 -0
  66. package/lib/node/access/policy-provider.js +84 -0
  67. package/lib/node/access/policy-provider.js.map +1 -0
  68. package/lib/node/access/policy-resolver.d.ts +15 -0
  69. package/lib/node/access/policy-resolver.d.ts.map +1 -0
  70. package/lib/node/access/policy-resolver.js +91 -0
  71. package/lib/node/access/policy-resolver.js.map +1 -0
  72. package/lib/node/access/resource-name-resolver.d.ts +7 -0
  73. package/lib/node/access/resource-name-resolver.d.ts.map +1 -0
  74. package/lib/node/access/resource-name-resolver.js +57 -0
  75. package/lib/node/access/resource-name-resolver.js.map +1 -0
  76. package/lib/node/access/security-metadata-source.d.ts +7 -0
  77. package/lib/node/access/security-metadata-source.d.ts.map +1 -0
  78. package/lib/node/access/security-metadata-source.js +58 -0
  79. package/lib/node/access/security-metadata-source.js.map +1 -0
  80. package/lib/node/annotation/action.d.ts +2 -0
  81. package/lib/node/annotation/action.d.ts.map +1 -0
  82. package/lib/node/annotation/action.js +11 -0
  83. package/lib/node/annotation/action.js.map +1 -0
  84. package/lib/node/annotation/anonymous.d.ts +2 -0
  85. package/lib/node/annotation/anonymous.d.ts.map +1 -0
  86. package/lib/node/annotation/anonymous.js +10 -0
  87. package/lib/node/annotation/anonymous.js.map +1 -0
  88. package/lib/node/annotation/authenticated.d.ts +2 -0
  89. package/lib/node/annotation/authenticated.d.ts.map +1 -0
  90. package/lib/node/annotation/authenticated.js +10 -0
  91. package/lib/node/annotation/authenticated.js.map +1 -0
  92. package/lib/node/annotation/authorize.d.ts +11 -0
  93. package/lib/node/annotation/authorize.d.ts.map +1 -0
  94. package/lib/node/annotation/authorize.js +40 -0
  95. package/lib/node/annotation/authorize.js.map +1 -0
  96. package/lib/node/annotation/index.d.ts +8 -0
  97. package/lib/node/annotation/index.d.ts.map +1 -0
  98. package/lib/node/annotation/index.js +24 -0
  99. package/lib/node/annotation/index.js.map +1 -0
  100. package/lib/node/annotation/post-authorize.d.ts +2 -0
  101. package/lib/node/annotation/post-authorize.d.ts.map +1 -0
  102. package/lib/node/annotation/post-authorize.js +10 -0
  103. package/lib/node/annotation/post-authorize.js.map +1 -0
  104. package/lib/node/annotation/pre-authorize.d.ts +2 -0
  105. package/lib/node/annotation/pre-authorize.d.ts.map +1 -0
  106. package/lib/node/annotation/pre-authorize.js +10 -0
  107. package/lib/node/annotation/pre-authorize.js.map +1 -0
  108. package/lib/node/annotation/resource.d.ts +2 -0
  109. package/lib/node/annotation/resource.d.ts.map +1 -0
  110. package/lib/node/annotation/resource.js +16 -0
  111. package/lib/node/annotation/resource.js.map +1 -0
  112. package/lib/node/authentication/authentication-manager.d.ts +10 -0
  113. package/lib/node/authentication/authentication-manager.d.ts.map +1 -0
  114. package/lib/node/authentication/authentication-manager.js +81 -0
  115. package/lib/node/authentication/authentication-manager.js.map +1 -0
  116. package/lib/node/authentication/authentication-middleware.d.ts +8 -0
  117. package/lib/node/authentication/authentication-middleware.d.ts.map +1 -0
  118. package/lib/node/authentication/authentication-middleware.js +36 -0
  119. package/lib/node/authentication/authentication-middleware.js.map +1 -0
  120. package/lib/node/authentication/authentication-protocol.d.ts +30 -0
  121. package/lib/node/authentication/authentication-protocol.d.ts.map +1 -0
  122. package/lib/node/authentication/authentication-protocol.js +12 -0
  123. package/lib/node/authentication/authentication-protocol.js.map +1 -0
  124. package/lib/node/authentication/authentication-provider.d.ts +33 -0
  125. package/lib/node/authentication/authentication-provider.d.ts.map +1 -0
  126. package/lib/node/authentication/authentication-provider.js +174 -0
  127. package/lib/node/authentication/authentication-provider.js.map +1 -0
  128. package/lib/node/authentication/authentication-success-handler.d.ts +16 -0
  129. package/lib/node/authentication/authentication-success-handler.d.ts.map +1 -0
  130. package/lib/node/authentication/authentication-success-handler.js +97 -0
  131. package/lib/node/authentication/authentication-success-handler.js.map +1 -0
  132. package/lib/node/authentication/index.d.ts +6 -0
  133. package/lib/node/authentication/index.d.ts.map +1 -0
  134. package/lib/node/authentication/index.js +22 -0
  135. package/lib/node/authentication/index.js.map +1 -0
  136. package/lib/node/cache/cache-protocol.d.ts +16 -0
  137. package/lib/node/cache/cache-protocol.d.ts.map +1 -0
  138. package/lib/node/cache/cache-protocol.js +6 -0
  139. package/lib/node/cache/cache-protocol.js.map +1 -0
  140. package/lib/node/cache/index.d.ts +3 -0
  141. package/lib/node/cache/index.d.ts.map +1 -0
  142. package/lib/node/cache/index.js +19 -0
  143. package/lib/node/cache/index.js.map +1 -0
  144. package/lib/node/cache/request-cache.d.ts +10 -0
  145. package/lib/node/cache/request-cache.d.ts.map +1 -0
  146. package/lib/node/cache/request-cache.js +52 -0
  147. package/lib/node/cache/request-cache.js.map +1 -0
  148. package/lib/node/constants.d.ts +6 -0
  149. package/lib/node/constants.d.ts.map +1 -0
  150. package/lib/node/constants.js +9 -0
  151. package/lib/node/constants.js.map +1 -0
  152. package/lib/node/context/context-protocol.d.ts +22 -0
  153. package/lib/node/context/context-protocol.d.ts.map +1 -0
  154. package/lib/node/context/context-protocol.js +30 -0
  155. package/lib/node/context/context-protocol.js.map +1 -0
  156. package/lib/node/context/index.d.ts +5 -0
  157. package/lib/node/context/index.d.ts.map +1 -0
  158. package/lib/node/context/index.js +21 -0
  159. package/lib/node/context/index.js.map +1 -0
  160. package/lib/node/context/security-context-middleware.d.ts +9 -0
  161. package/lib/node/context/security-context-middleware.d.ts.map +1 -0
  162. package/lib/node/context/security-context-middleware.js +44 -0
  163. package/lib/node/context/security-context-middleware.js.map +1 -0
  164. package/lib/node/context/security-context-store.d.ts +8 -0
  165. package/lib/node/context/security-context-store.d.ts.map +1 -0
  166. package/lib/node/context/security-context-store.js +40 -0
  167. package/lib/node/context/security-context-store.js.map +1 -0
  168. package/lib/node/context/security-context-strategy.d.ts +9 -0
  169. package/lib/node/context/security-context-strategy.d.ts.map +1 -0
  170. package/lib/node/context/security-context-strategy.js +32 -0
  171. package/lib/node/context/security-context-strategy.js.map +1 -0
  172. package/lib/node/crypto/index.d.ts +3 -0
  173. package/lib/node/crypto/index.d.ts.map +1 -0
  174. package/lib/node/crypto/index.js +19 -0
  175. package/lib/node/crypto/index.js.map +1 -0
  176. package/lib/node/crypto/keygen/base64-string-key-generator.d.ts +6 -0
  177. package/lib/node/crypto/keygen/base64-string-key-generator.d.ts.map +1 -0
  178. package/lib/node/crypto/keygen/base64-string-key-generator.js +30 -0
  179. package/lib/node/crypto/keygen/base64-string-key-generator.js.map +1 -0
  180. package/lib/node/crypto/keygen/index.d.ts +3 -0
  181. package/lib/node/crypto/keygen/index.d.ts.map +1 -0
  182. package/lib/node/crypto/keygen/index.js +19 -0
  183. package/lib/node/crypto/keygen/index.js.map +1 -0
  184. package/lib/node/crypto/keygen/keygen-protocol.d.ts +5 -0
  185. package/lib/node/crypto/keygen/keygen-protocol.d.ts.map +1 -0
  186. package/lib/node/crypto/keygen/keygen-protocol.js +5 -0
  187. package/lib/node/crypto/keygen/keygen-protocol.js.map +1 -0
  188. package/lib/node/crypto/password/index.d.ts +3 -0
  189. package/lib/node/crypto/password/index.d.ts.map +1 -0
  190. package/lib/node/crypto/password/index.js +19 -0
  191. package/lib/node/crypto/password/index.js.map +1 -0
  192. package/lib/node/crypto/password/password-encoder.d.ts +9 -0
  193. package/lib/node/crypto/password/password-encoder.d.ts.map +1 -0
  194. package/lib/node/crypto/password/password-encoder.js +51 -0
  195. package/lib/node/crypto/password/password-encoder.js.map +1 -0
  196. package/lib/node/crypto/password/password-protocol.d.ts +6 -0
  197. package/lib/node/crypto/password/password-protocol.d.ts.map +1 -0
  198. package/lib/node/crypto/password/password-protocol.js +5 -0
  199. package/lib/node/crypto/password/password-protocol.js.map +1 -0
  200. package/lib/node/error/error-handler.d.ts +19 -0
  201. package/lib/node/error/error-handler.d.ts.map +1 -0
  202. package/lib/node/error/error-handler.js +81 -0
  203. package/lib/node/error/error-handler.js.map +1 -0
  204. package/lib/node/error/error-protocol.d.ts +3 -0
  205. package/lib/node/error/error-protocol.d.ts.map +1 -0
  206. package/lib/node/error/error-protocol.js +7 -0
  207. package/lib/node/error/error-protocol.js.map +1 -0
  208. package/lib/node/error/error.d.ts +21 -0
  209. package/lib/node/error/error.d.ts.map +1 -0
  210. package/lib/node/error/error.js +35 -0
  211. package/lib/node/error/error.js.map +1 -0
  212. package/lib/node/error/index.d.ts +4 -0
  213. package/lib/node/error/index.d.ts.map +1 -0
  214. package/lib/node/error/index.js +20 -0
  215. package/lib/node/error/index.js.map +1 -0
  216. package/lib/node/index.d.ts +11 -0
  217. package/lib/node/index.d.ts.map +1 -0
  218. package/lib/node/index.js +27 -0
  219. package/lib/node/index.js.map +1 -0
  220. package/lib/node/logout/index.d.ts +5 -0
  221. package/lib/node/logout/index.d.ts.map +1 -0
  222. package/lib/node/logout/index.js +21 -0
  223. package/lib/node/logout/index.js.map +1 -0
  224. package/lib/node/logout/logout-handler.d.ts +5 -0
  225. package/lib/node/logout/logout-handler.d.ts.map +1 -0
  226. package/lib/node/logout/logout-handler.js +22 -0
  227. package/lib/node/logout/logout-handler.js.map +1 -0
  228. package/lib/node/logout/logout-middleware.d.ts +16 -0
  229. package/lib/node/logout/logout-middleware.d.ts.map +1 -0
  230. package/lib/node/logout/logout-middleware.js +66 -0
  231. package/lib/node/logout/logout-middleware.js.map +1 -0
  232. package/lib/node/logout/logout-protocol.d.ts +12 -0
  233. package/lib/node/logout/logout-protocol.d.ts.map +1 -0
  234. package/lib/node/logout/logout-protocol.js +9 -0
  235. package/lib/node/logout/logout-protocol.js.map +1 -0
  236. package/lib/node/logout/logout-success-handler-provider.d.ts +8 -0
  237. package/lib/node/logout/logout-success-handler-provider.d.ts.map +1 -0
  238. package/lib/node/logout/logout-success-handler-provider.js +35 -0
  239. package/lib/node/logout/logout-success-handler-provider.js.map +1 -0
  240. package/lib/node/logout/logout-success-handler.d.ts +9 -0
  241. package/lib/node/logout/logout-success-handler.d.ts.map +1 -0
  242. package/lib/node/logout/logout-success-handler.js +39 -0
  243. package/lib/node/logout/logout-success-handler.js.map +1 -0
  244. package/lib/node/module.d.ts +5 -0
  245. package/lib/node/module.d.ts.map +1 -0
  246. package/lib/node/module.js +7 -0
  247. package/lib/node/module.js.map +1 -0
  248. package/lib/node/user/index.d.ts +6 -0
  249. package/lib/node/user/index.d.ts.map +1 -0
  250. package/lib/node/user/index.js +22 -0
  251. package/lib/node/user/index.js.map +1 -0
  252. package/lib/node/user/user-checker.d.ts +8 -0
  253. package/lib/node/user/user-checker.d.ts.map +1 -0
  254. package/lib/node/user/user-checker.js +44 -0
  255. package/lib/node/user/user-checker.js.map +1 -0
  256. package/lib/node/user/user-mapper.d.ts +9 -0
  257. package/lib/node/user/user-mapper.d.ts.map +1 -0
  258. package/lib/node/user/user-mapper.js +40 -0
  259. package/lib/node/user/user-mapper.js.map +1 -0
  260. package/lib/node/user/user-middleware.d.ts +11 -0
  261. package/lib/node/user/user-middleware.d.ts.map +1 -0
  262. package/lib/node/user/user-middleware.js +55 -0
  263. package/lib/node/user/user-middleware.js.map +1 -0
  264. package/lib/node/user/user-protocol.d.ts +15 -0
  265. package/lib/node/user/user-protocol.d.ts.map +1 -0
  266. package/lib/node/user/user-protocol.js +9 -0
  267. package/lib/node/user/user-protocol.js.map +1 -0
  268. package/lib/node/user/user-service.d.ts +7 -0
  269. package/lib/node/user/user-service.d.ts.map +1 -0
  270. package/lib/node/user/user-service.js +42 -0
  271. package/lib/node/user/user-service.js.map +1 -0
  272. package/lib/package.spec.d.ts +1 -0
  273. package/lib/package.spec.d.ts.map +1 -0
  274. package/lib/package.spec.js +4 -0
  275. package/lib/package.spec.js.map +1 -0
  276. package/package.json +53 -0
  277. package/src/browser/index.ts +1 -0
  278. package/src/browser/module.ts +4 -0
  279. package/src/browser/user/index.ts +2 -0
  280. package/src/browser/user/user-manager.ts +103 -0
  281. package/src/browser/user/user-protocol.ts +11 -0
  282. package/src/common/index.ts +1 -0
  283. package/src/common/security-protocol.ts +65 -0
  284. package/src/node/access/access-decision-manager.ts +43 -0
  285. package/src/node/access/access-decision-utils.ts +18 -0
  286. package/src/node/access/access-decision-voter.ts +73 -0
  287. package/src/node/access/access-protocol.ts +93 -0
  288. package/src/node/access/action-name-resolver.ts +19 -0
  289. package/src/node/access/index.ts +11 -0
  290. package/src/node/access/jexl-engine-provider.ts +18 -0
  291. package/src/node/access/method-advice.ts +64 -0
  292. package/src/node/access/policy-provider.ts +64 -0
  293. package/src/node/access/policy-resolver.ts +79 -0
  294. package/src/node/access/resource-name-resolver.ts +41 -0
  295. package/src/node/access/security-metadata-source.ts +47 -0
  296. package/src/node/annotation/action.ts +8 -0
  297. package/src/node/annotation/anonymous.ts +6 -0
  298. package/src/node/annotation/authenticated.ts +6 -0
  299. package/src/node/annotation/authorize.ts +39 -0
  300. package/src/node/annotation/index.ts +7 -0
  301. package/src/node/annotation/post-authorize.ts +6 -0
  302. package/src/node/annotation/pre-authorize.ts +6 -0
  303. package/src/node/annotation/resource.ts +12 -0
  304. package/src/node/authentication/authentication-manager.ts +61 -0
  305. package/src/node/authentication/authentication-middleware.ts +21 -0
  306. package/src/node/authentication/authentication-protocol.ts +37 -0
  307. package/src/node/authentication/authentication-provider.ts +155 -0
  308. package/src/node/authentication/authentication-success-handler.ts +83 -0
  309. package/src/node/authentication/index.ts +5 -0
  310. package/src/node/cache/cache-protocol.ts +17 -0
  311. package/src/node/cache/index.ts +2 -0
  312. package/src/node/cache/request-cache.ts +38 -0
  313. package/src/node/constants.ts +5 -0
  314. package/src/node/context/context-protocol.ts +43 -0
  315. package/src/node/context/index.ts +4 -0
  316. package/src/node/context/security-context-middleware.ts +28 -0
  317. package/src/node/context/security-context-store.ts +25 -0
  318. package/src/node/context/security-context-strategy.ts +24 -0
  319. package/src/node/crypto/index.ts +2 -0
  320. package/src/node/crypto/keygen/base64-string-key-generator.ts +15 -0
  321. package/src/node/crypto/keygen/index.ts +2 -0
  322. package/src/node/crypto/keygen/keygen-protocol.ts +7 -0
  323. package/src/node/crypto/password/index.ts +2 -0
  324. package/src/node/crypto/password/password-encoder.ts +39 -0
  325. package/src/node/crypto/password/password-protocol.ts +6 -0
  326. package/src/node/error/error-handler.ts +58 -0
  327. package/src/node/error/error-protocol.ts +5 -0
  328. package/src/node/error/error.ts +41 -0
  329. package/src/node/error/index.ts +3 -0
  330. package/src/node/index.ts +10 -0
  331. package/src/node/logout/index.ts +4 -0
  332. package/src/node/logout/logout-handler.ts +12 -0
  333. package/src/node/logout/logout-middleware.ts +49 -0
  334. package/src/node/logout/logout-protocol.ts +17 -0
  335. package/src/node/logout/logout-success-handler-provider.ts +21 -0
  336. package/src/node/logout/logout-success-handler.ts +22 -0
  337. package/src/node/module.ts +5 -0
  338. package/src/node/user/index.ts +6 -0
  339. package/src/node/user/user-checker.ts +37 -0
  340. package/src/node/user/user-mapper.ts +26 -0
  341. package/src/node/user/user-middleware.ts +40 -0
  342. package/src/node/user/user-protocol.ts +20 -0
  343. package/src/node/user/user-service.ts +28 -0
  344. package/src/package.spec.ts +4 -0
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./user-protocol"), exports);
18
+ __exportStar(require("./user-service"), exports);
19
+ __exportStar(require("./user-checker"), exports);
20
+ __exportStar(require("./user-mapper"), exports);
21
+ __exportStar(require("./user-middleware"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/user/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,iDAA+B;AAC/B,iDAA+B;AAC/B,gDAA8B;AAC9B,oDAAkC"}
@@ -0,0 +1,8 @@
1
+ import { UserChecker } from './user-protocol';
2
+ import { Logger } from '@celljs/core';
3
+ import { User } from '../../common';
4
+ export declare class UserCheckerImpl implements UserChecker {
5
+ protected readonly logger: Logger;
6
+ check(user: User): Promise<void>;
7
+ }
8
+ //# sourceMappingURL=user-checker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-checker.d.ts","sourceRoot":"","sources":["../../../src/node/user/user-checker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAwB,MAAM,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,qBACa,eAAgB,YAAW,WAAW;IAE/C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAE5B,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CA0BzC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UserCheckerImpl = void 0;
13
+ const user_protocol_1 = require("./user-protocol");
14
+ const core_1 = require("@celljs/core");
15
+ const error_1 = require("../error");
16
+ let UserCheckerImpl = class UserCheckerImpl {
17
+ async check(user) {
18
+ if (!user.accountNonLocked) {
19
+ this.logger.info('User account is locked');
20
+ throw new error_1.LockedError('User account is locked');
21
+ }
22
+ if (!user.enabled) {
23
+ this.logger.info('User account is disabled');
24
+ throw new error_1.DisabledError('User is disabled');
25
+ }
26
+ if (!user.accountNonExpired) {
27
+ this.logger.info('User account is expired');
28
+ throw new error_1.AccountExpiredError('User account has expired');
29
+ }
30
+ if (!user.credentialsNonExpired) {
31
+ this.logger.info('User account is expired');
32
+ throw new error_1.CredentialsExpiredError('User credentials have expired');
33
+ }
34
+ }
35
+ };
36
+ __decorate([
37
+ (0, core_1.Autowired)(core_1.Logger),
38
+ __metadata("design:type", Object)
39
+ ], UserCheckerImpl.prototype, "logger", void 0);
40
+ UserCheckerImpl = __decorate([
41
+ (0, core_1.Component)(user_protocol_1.UserChecker)
42
+ ], UserCheckerImpl);
43
+ exports.UserCheckerImpl = UserCheckerImpl;
44
+ //# sourceMappingURL=user-checker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-checker.js","sourceRoot":"","sources":["../../../src/node/user/user-checker.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAA8C;AAC9C,uCAA4D;AAC5D,oCAAoG;AAI7F,IAAM,eAAe,GAArB,MAAM,eAAe;IAIxB,KAAK,CAAC,KAAK,CAAC,IAAU;QAClB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YAE3C,MAAM,IAAI,mBAAW,CAAC,wBAAwB,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACf,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YAE7C,MAAM,IAAI,qBAAa,CAAC,kBAAkB,CAAC,CAAC;SAC/C;QAED,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YACzB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;YAE5C,MAAM,IAAI,2BAAmB,CAAC,0BAA0B,CAAC,CAAC;SAC7D;QAED,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE;YAC7B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;YAE5C,MAAM,IAAI,+BAAuB,CAAC,+BAA+B,CAAC,CAAC;SACtE;IACL,CAAC;CAEJ,CAAA;AA7BG;IAAC,IAAA,gBAAS,EAAC,aAAM,CAAC;;+CACgB;AAFzB,eAAe;IAD3B,IAAA,gBAAS,EAAC,2BAAW,CAAC;GACV,eAAe,CA8B3B;AA9BY,0CAAe"}
@@ -0,0 +1,9 @@
1
+ import { UserMapper } from './user-protocol';
2
+ import { User, UserMapperRule } from '../../common';
3
+ export declare class UserMapperImpl implements UserMapper {
4
+ protected rules: {
5
+ [id: string]: UserMapperRule;
6
+ };
7
+ map(user: User): Promise<void>;
8
+ }
9
+ //# sourceMappingURL=user-mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-mapper.d.ts","sourceRoot":"","sources":["../../../src/node/user/user-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEpD,qBACa,cAAe,YAAW,UAAU;IAG7C,SAAS,CAAC,KAAK,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE,CAAC;IAE5C,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAevC"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UserMapperImpl = void 0;
13
+ const user_protocol_1 = require("./user-protocol");
14
+ const core_1 = require("@celljs/core");
15
+ let UserMapperImpl = class UserMapperImpl {
16
+ async map(user) {
17
+ if (user.type && user.claims) {
18
+ const rule = this.rules[user.type];
19
+ if (rule) {
20
+ for (const prop in rule) {
21
+ if (Object.prototype.hasOwnProperty.call(rule, prop)) {
22
+ const value = rule[prop];
23
+ if (value) {
24
+ user[prop] = user.claims[value];
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
31
+ };
32
+ __decorate([
33
+ (0, core_1.Value)('cell.security.userMapperRule'),
34
+ __metadata("design:type", Object)
35
+ ], UserMapperImpl.prototype, "rules", void 0);
36
+ UserMapperImpl = __decorate([
37
+ (0, core_1.Component)(user_protocol_1.UserMapper)
38
+ ], UserMapperImpl);
39
+ exports.UserMapperImpl = UserMapperImpl;
40
+ //# sourceMappingURL=user-mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-mapper.js","sourceRoot":"","sources":["../../../src/node/user/user-mapper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAA6C;AAC7C,uCAAgD;AAIzC,IAAM,cAAc,GAApB,MAAM,cAAc;IAKvB,KAAK,CAAC,GAAG,CAAC,IAAU;QAChB,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE;YAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,IAAI,EAAE;gBACN,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;oBACrB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE;wBAClD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;wBACzB,IAAI,KAAK,EAAE;4BACP,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;yBACnC;qBACJ;iBACJ;aACJ;SACJ;IACL,CAAC;CACJ,CAAA;AAlBG;IAAC,IAAA,YAAK,EAAC,8BAA8B,CAAC;;6CACY;AAHzC,cAAc;IAD1B,IAAA,gBAAS,EAAC,0BAAU,CAAC;GACT,cAAc,CAoB1B;AApBY,wCAAc"}
@@ -0,0 +1,11 @@
1
+ import { RequestMatcher, Middleware, Context } from '@celljs/web/lib/node';
2
+ import { PathResolver } from '@celljs/web';
3
+ export declare class UserMiddleware implements Middleware {
4
+ protected readonly userInfoEndpoint: any;
5
+ protected readonly pathResolver: PathResolver;
6
+ protected readonly requestMatcher: RequestMatcher;
7
+ handle(ctx: Context, next: () => Promise<void>): Promise<void>;
8
+ canHandle(): Promise<boolean>;
9
+ readonly priority: number;
10
+ }
11
+ //# sourceMappingURL=user-middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-middleware.d.ts","sourceRoot":"","sources":["../../../src/node/user/user-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG3E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,qBACa,cAAe,YAAW,UAAU;IAG7C,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC;IAGzC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAG9C,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAE5C,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAa9D,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAKnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAA4B;CAExD"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UserMiddleware = void 0;
13
+ const node_1 = require("@celljs/web/lib/node");
14
+ const core_1 = require("@celljs/core");
15
+ const http_1 = require("@celljs/http");
16
+ const web_1 = require("@celljs/web");
17
+ const user_protocol_1 = require("./user-protocol");
18
+ const context_protocol_1 = require("../context/context-protocol");
19
+ let UserMiddleware = class UserMiddleware {
20
+ constructor() {
21
+ this.priority = user_protocol_1.USER_MIDDLEWARE_PRIORITY;
22
+ }
23
+ async handle(ctx, next) {
24
+ if (await this.canHandle()) {
25
+ const auth = context_protocol_1.SecurityContext.getAuthentication();
26
+ if (auth.authenticated) {
27
+ ctx.response.setHeader(http_1.HttpHeaders.CONTENT_TYPE, http_1.MediaType.APPLICATION_JSON_UTF8);
28
+ ctx.response.body = JSON.stringify(auth.principal);
29
+ }
30
+ return;
31
+ }
32
+ await next();
33
+ }
34
+ async canHandle() {
35
+ const { url, method } = this.userInfoEndpoint;
36
+ return !!await this.requestMatcher.match(await this.pathResolver.resolve(url), method);
37
+ }
38
+ };
39
+ __decorate([
40
+ (0, core_1.Value)('cell.security.userInfoEndpoint'),
41
+ __metadata("design:type", Object)
42
+ ], UserMiddleware.prototype, "userInfoEndpoint", void 0);
43
+ __decorate([
44
+ (0, core_1.Autowired)(web_1.PathResolver),
45
+ __metadata("design:type", Object)
46
+ ], UserMiddleware.prototype, "pathResolver", void 0);
47
+ __decorate([
48
+ (0, core_1.Autowired)(node_1.RequestMatcher),
49
+ __metadata("design:type", Object)
50
+ ], UserMiddleware.prototype, "requestMatcher", void 0);
51
+ UserMiddleware = __decorate([
52
+ (0, core_1.Component)(node_1.Middleware)
53
+ ], UserMiddleware);
54
+ exports.UserMiddleware = UserMiddleware;
55
+ //# sourceMappingURL=user-middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-middleware.js","sourceRoot":"","sources":["../../../src/node/user/user-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA2E;AAC3E,uCAA2D;AAC3D,uCAAsD;AACtD,qCAA2C;AAC3C,mDAA2D;AAC3D,kEAA8D;AAGvD,IAAM,cAAc,GAApB,MAAM,cAAc;IAApB;QA6BM,aAAQ,GAAW,wCAAwB,CAAC;IAEzD,CAAC;IApBG,KAAK,CAAC,MAAM,CAAC,GAAY,EAAE,IAAyB;QAChD,IAAI,MAAM,IAAI,CAAC,SAAS,EAAE,EAAE;YACxB,MAAM,IAAI,GAAG,kCAAe,CAAC,iBAAiB,EAAE,CAAC;YACjD,IAAI,IAAI,CAAC,aAAa,EAAE;gBACpB,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,kBAAW,CAAC,YAAY,EAAE,gBAAS,CAAC,qBAAqB,CAAC,CAAC;gBAClF,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACtD;YACD,OAAO;SACV;QACD,MAAM,IAAI,EAAE,CAAC;IAEjB,CAAC;IAED,KAAK,CAAC,SAAS;QACX,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC9C,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3F,CAAC;CAIJ,CAAA;AA7BG;IAAC,IAAA,YAAK,EAAC,gCAAgC,CAAC;;wDACC;AAEzC;IAAC,IAAA,gBAAS,EAAC,kBAAY,CAAC;;oDACsB;AAE9C;IAAC,IAAA,gBAAS,EAAC,qBAAc,CAAC;;sDACwB;AATzC,cAAc;IAD1B,IAAA,gBAAS,EAAC,iBAAU,CAAC;GACT,cAAc,CA+B1B;AA/BY,wCAAc"}
@@ -0,0 +1,15 @@
1
+ import { User } from '../../common';
2
+ export declare const UserService: unique symbol;
3
+ export declare const UserChecker: unique symbol;
4
+ export declare const UserMapper: unique symbol;
5
+ export declare const USER_MIDDLEWARE_PRIORITY: number;
6
+ export interface UserService<R, U extends User> {
7
+ load(userRequest: R): Promise<U>;
8
+ }
9
+ export interface UserChecker {
10
+ check(user: User): Promise<void>;
11
+ }
12
+ export interface UserMapper {
13
+ map(user: User): Promise<void>;
14
+ }
15
+ //# sourceMappingURL=user-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-protocol.d.ts","sourceRoot":"","sources":["../../../src/node/user/user-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,eAAwB,CAAC;AACjD,eAAO,MAAM,UAAU,eAAuB,CAAC;AAE/C,eAAO,MAAM,wBAAwB,QAA6C,CAAC;AAEnF,MAAM,WAAW,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,IAAI;IAC1C,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IACxB,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,UAAU;IACvB,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.USER_MIDDLEWARE_PRIORITY = exports.UserMapper = exports.UserChecker = exports.UserService = void 0;
4
+ const context_protocol_1 = require("../context/context-protocol");
5
+ exports.UserService = Symbol('UserService');
6
+ exports.UserChecker = Symbol('UserChecker');
7
+ exports.UserMapper = Symbol('UserMapper');
8
+ exports.USER_MIDDLEWARE_PRIORITY = context_protocol_1.SECURITY_CONTEXT_MIDDLEWARE_PRIORITY - 100;
9
+ //# sourceMappingURL=user-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-protocol.js","sourceRoot":"","sources":["../../../src/node/user/user-protocol.ts"],"names":[],"mappings":";;;AACA,kEAAmF;AAEtE,QAAA,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AACpC,QAAA,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AACpC,QAAA,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAElC,QAAA,wBAAwB,GAAG,uDAAoC,GAAG,GAAG,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { UserService } from './user-protocol';
2
+ import { User } from '../../common';
3
+ export declare class UserServiceImpl implements UserService<string, User> {
4
+ protected readonly options: any;
5
+ load(username: string): Promise<User>;
6
+ }
7
+ //# sourceMappingURL=user-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-service.d.ts","sourceRoot":"","sources":["../../../src/node/user/user-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAE,IAAI,EAAY,MAAM,cAAc,CAAC;AAE9C,qBACa,eAAgB,YAAW,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC;IAG7D,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IAE1B,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAgB9C"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UserServiceImpl = void 0;
13
+ const user_protocol_1 = require("./user-protocol");
14
+ const core_1 = require("@celljs/core");
15
+ const error_1 = require("../error");
16
+ const common_1 = require("../../common");
17
+ let UserServiceImpl = class UserServiceImpl {
18
+ async load(username) {
19
+ if (this.options.username === username) {
20
+ return {
21
+ type: common_1.UserType.Memery,
22
+ username,
23
+ password: this.options.password,
24
+ accountNonExpired: true,
25
+ accountNonLocked: true,
26
+ credentialsNonExpired: true,
27
+ enabled: true,
28
+ policies: []
29
+ };
30
+ }
31
+ throw new error_1.UsernameNotFoundError(`Could not find: ${username}`);
32
+ }
33
+ };
34
+ __decorate([
35
+ (0, core_1.Value)('cell.security'),
36
+ __metadata("design:type", Object)
37
+ ], UserServiceImpl.prototype, "options", void 0);
38
+ UserServiceImpl = __decorate([
39
+ (0, core_1.Component)(user_protocol_1.UserService)
40
+ ], UserServiceImpl);
41
+ exports.UserServiceImpl = UserServiceImpl;
42
+ //# sourceMappingURL=user-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-service.js","sourceRoot":"","sources":["../../../src/node/user/user-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAA8C;AAC9C,uCAAgD;AAChD,oCAAiD;AACjD,yCAA8C;AAGvC,IAAM,eAAe,GAArB,MAAM,eAAe;IAKxB,KAAK,CAAC,IAAI,CAAC,QAAgB;QACvB,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE;YACpC,OAAO;gBACH,IAAI,EAAE,iBAAQ,CAAC,MAAM;gBACrB,QAAQ;gBACR,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;gBAC/B,iBAAiB,EAAE,IAAI;gBACvB,gBAAgB,EAAE,IAAI;gBACtB,qBAAqB,EAAE,IAAI;gBAC3B,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,EAAE;aACf,CAAC;SACL;QAED,MAAM,IAAI,6BAAqB,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC;IACnE,CAAC;CACJ,CAAA;AAnBG;IAAC,IAAA,YAAK,EAAC,eAAe,CAAC;;gDACS;AAHvB,eAAe;IAD3B,IAAA,gBAAS,EAAC,2BAAW,CAAC;GACV,eAAe,CAqB3B;AArBY,0CAAe"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=package.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ describe('security package', () => {
2
+ it('support code coverage statistics', () => { });
3
+ });
4
+ //# sourceMappingURL=package.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAE9B,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@celljs/security",
3
+ "version": "3.0.0",
4
+ "description": "",
5
+ "main": "lib/common/index.js",
6
+ "typings": "lib/common/index.d.ts",
7
+ "dependencies": {
8
+ "@celljs/core": "3.0.0",
9
+ "@celljs/http": "3.0.0",
10
+ "@celljs/web": "3.0.0",
11
+ "axios": "^0.26.1",
12
+ "crypto-js": "^4.0.0",
13
+ "jexl": "^2.2.0",
14
+ "micromatch": "^4.0.2",
15
+ "qs": "^6.9.4",
16
+ "reflect-metadata": "^0.1.13",
17
+ "rxjs": "^6.6.0"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "keywords": [
23
+ "cell-component"
24
+ ],
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/cellbang/cell.git"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/cellbang/cell/issues"
32
+ },
33
+ "homepage": "https://github.com/cellbang/cell",
34
+ "files": [
35
+ "lib",
36
+ "src",
37
+ "cell.yml"
38
+ ],
39
+ "scripts": {
40
+ "lint": "cell-component lint",
41
+ "build": "cell-component build",
42
+ "watch": "cell-component watch",
43
+ "clean": "cell-component clean",
44
+ "test": "cell-component test:js"
45
+ },
46
+ "devDependencies": {
47
+ "@celljs/component": "3.0.0",
48
+ "@types/crypto-js": "^3.1.47",
49
+ "@types/jexl": "^2.2.0",
50
+ "@types/micromatch": "^4.0.1"
51
+ },
52
+ "gitHead": "c0ef8d269e33a795406bcbb240cac4b845c6c24c"
53
+ }
@@ -0,0 +1 @@
1
+ export * from './user';
@@ -0,0 +1,4 @@
1
+ import './index';
2
+ import { autoBind } from '@celljs/core';
3
+
4
+ export default autoBind();
@@ -0,0 +1,2 @@
1
+ export * from './user-manager';
2
+ export * from './user-protocol';
@@ -0,0 +1,103 @@
1
+ import { UserManager } from './user-protocol';
2
+ import { Autowired, Component, Value, PostConstruct } from '@celljs/core';
3
+ import { RestOperations, HttpMethod, HttpStatus, HttpHeaders } from '@celljs/http';
4
+ import { PathResolver } from '@celljs/web';
5
+ import { Method } from 'axios';
6
+ import { BehaviorSubject } from 'rxjs';
7
+ import { User } from '../../common';
8
+
9
+ @Component(UserManager)
10
+ export class UserManagerImpl implements UserManager {
11
+
12
+ protected readonly loginUserInfoStorageKey = 'cell:loginUserInfo';
13
+
14
+ @Value('cell.security.loginPage')
15
+ protected readonly loginPage: string;
16
+
17
+ @Value('cell.security.openNewWindow')
18
+ protected readonly openNewWindow: boolean;
19
+
20
+ @Value('cell.security.logoutUrl')
21
+ protected readonly logoutUrl: string;
22
+
23
+ @Value('cell.security.logoutSuccessUrl')
24
+ protected readonly logoutSuccessUrl: string;
25
+
26
+ @Value('cell.security.logoutMethod')
27
+ protected readonly logoutMethod: HttpMethod;
28
+
29
+ @Value('cell.security.userInfoEndpoint')
30
+ protected readonly userInfoEndpoint: any;
31
+
32
+ @Value('cell.security.loginRequired')
33
+ protected readonly loginRequired: boolean;
34
+
35
+ @Autowired(RestOperations)
36
+ protected restOperations: RestOperations;
37
+
38
+ @Autowired(PathResolver)
39
+ protected readonly pathResolver: PathResolver;
40
+
41
+ userInfoSubject: BehaviorSubject<User | undefined> = new BehaviorSubject<User | undefined>(undefined);
42
+
43
+ @PostConstruct()
44
+ protected init() {
45
+
46
+ this.restOperations.interceptors.response.use(response => response, error => {
47
+ if (error.response) {
48
+ if (error.response.status === HttpStatus.UNAUTHORIZED && !error.response.headers[HttpHeaders.WWW_AUTHENTICATE.toLowerCase()]) {
49
+ this.openLoginPage();
50
+ return;
51
+ }
52
+ }
53
+ return Promise.reject(error);
54
+ });
55
+
56
+ this.userInfoSubject.subscribe(user => {
57
+ if (user) {
58
+ localStorage.setItem(this.loginUserInfoStorageKey, JSON.stringify(user));
59
+ } else {
60
+ localStorage.removeItem(this.loginUserInfoStorageKey);
61
+ }
62
+ });
63
+
64
+ const userStr = localStorage.getItem(this.loginUserInfoStorageKey);
65
+ if (userStr) {
66
+ this.userInfoSubject.next(JSON.parse(userStr));
67
+ } else {
68
+ this.getUserInfo().then(() => {
69
+ if (this.loginRequired) {
70
+ this.openLoginPage();
71
+ }
72
+ });
73
+ }
74
+ }
75
+
76
+ async openLoginPage(newWindow?: boolean): Promise<void> {
77
+ if (newWindow === undefined) {
78
+ newWindow = this.openNewWindow;
79
+ }
80
+ this.userInfoSubject.next(undefined);
81
+ const url = await this.pathResolver.resolve(this.loginPage.replace(/{redirect}/g, encodeURI(window.location.href)));
82
+ if (newWindow) {
83
+ window.open(url);
84
+ } else {
85
+ window.location.href = url;
86
+ }
87
+ }
88
+
89
+ async logout(): Promise<void> {
90
+ this.userInfoSubject.next(undefined);
91
+ const method = (this.logoutMethod || HttpMethod.POST) as Method;
92
+ await this.restOperations.request({ url: this.logoutUrl, method });
93
+ window.location.href = await this.pathResolver.resolve(this.logoutSuccessUrl.replace(/{redirect}/g, encodeURI(window.location.href)));
94
+ }
95
+
96
+ async getUserInfo(): Promise<User | undefined> {
97
+ const { url, method } = this.userInfoEndpoint;
98
+ const { data } = await this.restOperations.request({ url: await this.pathResolver.resolve(url), method });
99
+ this.userInfoSubject.next(data);
100
+ return data;
101
+ }
102
+
103
+ }
@@ -0,0 +1,11 @@
1
+ import { User } from '../../common';
2
+ import { BehaviorSubject } from 'rxjs';
3
+
4
+ export const UserManager = Symbol('UserManager');
5
+
6
+ export interface UserManager {
7
+ openLoginPage(newWindow?: boolean): Promise<void>;
8
+ logout(): Promise<void>;
9
+ getUserInfo(): Promise<User | undefined>;
10
+ userInfoSubject: BehaviorSubject<User | undefined>;
11
+ }
@@ -0,0 +1 @@
1
+ export * from './security-protocol';
@@ -0,0 +1,65 @@
1
+ export enum AuthorizeType {
2
+ Pre= 'Pre', Post= 'Post'
3
+ }
4
+
5
+ export enum PolicyType {
6
+ el= 'el', acl= 'Acl'
7
+ }
8
+
9
+ export interface Policy {
10
+ type: PolicyType | string
11
+ authorizeType: AuthorizeType;
12
+ [key: string]: any;
13
+ }
14
+
15
+ export interface ElPolicy extends Policy {
16
+ context: any;
17
+ el: string;
18
+ }
19
+
20
+ export enum Effect {
21
+ Allow= 'Allow', Deny= 'Deny'
22
+ }
23
+
24
+ export interface Statement {
25
+ effect: Effect;
26
+ action: string | string[];
27
+ resource: string | string[];
28
+ condition: { [key: string]: any };
29
+ }
30
+
31
+ export interface AclPolicy extends Policy {
32
+ version?: string;
33
+ statement: Statement[];
34
+ }
35
+
36
+ export enum UserType {
37
+ Memery = 'memory', Database = 'database'
38
+ }
39
+
40
+ export interface User {
41
+ type: string;
42
+ username: string;
43
+ password: string;
44
+ policies: Policy[];
45
+ accountNonExpired: boolean;
46
+ accountNonLocked: boolean;
47
+ credentialsNonExpired: boolean;
48
+ enabled: boolean;
49
+ claims?: { [key: string]: any};
50
+ [key: string]: any;
51
+ }
52
+
53
+ export namespace User {
54
+ export function is(user: Object | undefined): user is User {
55
+ return !!user && 'type' in user && 'username' in user && 'password' in user &&
56
+ 'policies' in user && 'accountNonExpired' in user && 'accountNonLocked' in user &&
57
+ 'credentialsNonExpired' in user && 'enabled' in user;
58
+ }
59
+ }
60
+
61
+ export interface UserMapperRule {
62
+ avatar: string;
63
+ nickname: string;
64
+ [key: string]: any;
65
+ }
@@ -0,0 +1,43 @@
1
+ import { AccessDecisionManager, SecurityMetadata, AccessDecisionVoter, ACCESS_DENIED, ACCESS_GRANTED } from './access-protocol';
2
+ import { Component, Prioritizeable, Autowired } from '@celljs/core';
3
+ import { AccessDeniedError, AuthenticationError } from '../error';
4
+ import { SecurityContext } from '../context';
5
+ import { HttpStatus } from '@celljs/http';
6
+
7
+ @Component(AccessDecisionManager)
8
+ export class AccessDecisionManagerImpl implements AccessDecisionManager {
9
+
10
+ protected prioritized: AccessDecisionVoter[];
11
+
12
+ constructor(
13
+ @Autowired(AccessDecisionVoter)
14
+ protected readonly accessDecisionVoters: AccessDecisionVoter[]
15
+ ) {
16
+ this.prioritized = Prioritizeable.prioritizeAllSync(this.accessDecisionVoters).map(c => c.value);
17
+ }
18
+
19
+ async decide(securityMetadata: SecurityMetadata): Promise<void> {
20
+ let grant = 0;
21
+ for (const voter of this.prioritized) {
22
+ if (await voter.support(securityMetadata)) {
23
+ const result = await voter.vote(securityMetadata);
24
+ if (result === ACCESS_DENIED) {
25
+ this.handleError();
26
+ } else if (result === ACCESS_GRANTED) {
27
+ grant++;
28
+ }
29
+ }
30
+ }
31
+ if (grant <= 0) {
32
+ this.handleError();
33
+ }
34
+ }
35
+
36
+ protected handleError() {
37
+ if (SecurityContext.getAuthentication().authenticated) {
38
+ throw new AccessDeniedError(HttpStatus.FORBIDDEN_REASON_PHRASE);
39
+ }
40
+ throw new AuthenticationError(HttpStatus.UNAUTHORIZED_REASON_PHRASE);
41
+ }
42
+
43
+ }