@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Cellbang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # Cell - Security Component
package/cell.yml ADDED
@@ -0,0 +1,36 @@
1
+ cell:
2
+ security:
3
+ enabled: true
4
+ loginRequired: true
5
+ openNewWindow: false
6
+ usernameKey: username
7
+ passwordKey: password
8
+ loginPage: ${ '/login' | onTarget('backend') || '/login?${cell.security.targetUrlParameter}={redirect}'}
9
+ loginUrl: /login
10
+ loginMethod: POST
11
+ loginSuccessUrl: /
12
+ logoutUrl: /logout
13
+ logoutMethod: POST
14
+ logoutSuccessUrl: ${cell.security.loginPage}
15
+ alwaysUseDefaultTargetUrl: false
16
+ useReferer: false
17
+ targetUrlParameter: redirect
18
+ base64StringKeyLength: ${ 32 | onTarget('backend')}
19
+ contextKey: cell:securityContext
20
+ username: ${ 'admin' | onTarget('backend')}
21
+ password: ${ 'MzQ0NTg4ZTk2NzQyYWI1ODA1MDFlNDBjMzZhZDY4OWQ1Zjc5ZDYxYzc2MjQ1NWZk' | onTarget('backend')} # raw password 123456
22
+ passwordEncoder:
23
+ encodeHashAsBase64: ${ true | onTarget('backend')}
24
+ basic:
25
+ enabled: false
26
+ realm: realm
27
+ userInfoEndpoint:
28
+ url: /userinfo
29
+ method: POST
30
+ userMapperRule:
31
+ github:
32
+ avatar: avatar_url
33
+ email: email
34
+ login: login
35
+ nickname: login
36
+
@@ -0,0 +1,2 @@
1
+ export * from './user';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,18 @@
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"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB"}
@@ -0,0 +1,4 @@
1
+ import './index';
2
+ declare const _default: import("inversify/lib/interfaces/interfaces").interfaces.ContainerModule;
3
+ export default _default;
4
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/browser/module.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAC;;AAGjB,wBAA0B"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("./index");
4
+ const core_1 = require("@celljs/core");
5
+ exports.default = (0, core_1.autoBind)();
6
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/browser/module.ts"],"names":[],"mappings":";;AAAA,mBAAiB;AACjB,uCAAwC;AAExC,kBAAe,IAAA,eAAQ,GAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './user-manager';
2
+ export * from './user-protocol';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/browser/user/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,19 @@
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-manager"), exports);
18
+ __exportStar(require("./user-protocol"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/browser/user/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,kDAAgC"}
@@ -0,0 +1,23 @@
1
+ import { UserManager } from './user-protocol';
2
+ import { RestOperations, HttpMethod } from '@celljs/http';
3
+ import { PathResolver } from '@celljs/web';
4
+ import { BehaviorSubject } from 'rxjs';
5
+ import { User } from '../../common';
6
+ export declare class UserManagerImpl implements UserManager {
7
+ protected readonly loginUserInfoStorageKey = "cell:loginUserInfo";
8
+ protected readonly loginPage: string;
9
+ protected readonly openNewWindow: boolean;
10
+ protected readonly logoutUrl: string;
11
+ protected readonly logoutSuccessUrl: string;
12
+ protected readonly logoutMethod: HttpMethod;
13
+ protected readonly userInfoEndpoint: any;
14
+ protected readonly loginRequired: boolean;
15
+ protected restOperations: RestOperations;
16
+ protected readonly pathResolver: PathResolver;
17
+ userInfoSubject: BehaviorSubject<User | undefined>;
18
+ protected init(): void;
19
+ openLoginPage(newWindow?: boolean): Promise<void>;
20
+ logout(): Promise<void>;
21
+ getUserInfo(): Promise<User | undefined>;
22
+ }
23
+ //# sourceMappingURL=user-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-manager.d.ts","sourceRoot":"","sources":["../../../src/browser/user/user-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,UAAU,EAA2B,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,qBACa,eAAgB,YAAW,WAAW;IAE/C,SAAS,CAAC,QAAQ,CAAC,uBAAuB,wBAAwB;IAGlE,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAGrC,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAG1C,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAGrC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAG5C,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC;IAG5C,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC;IAGzC,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAG1C,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;IAGzC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAE9C,eAAe,EAAE,eAAe,CAAC,IAAI,GAAG,SAAS,CAAC,CAAoD;IAGtG,SAAS,CAAC,IAAI;IAgCR,aAAa,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAajD,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAOvB,WAAW,IAAI,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;CAOjD"}
@@ -0,0 +1,125 @@
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.UserManagerImpl = void 0;
13
+ const user_protocol_1 = require("./user-protocol");
14
+ const core_1 = require("@celljs/core");
15
+ const http_1 = require("@celljs/http");
16
+ const web_1 = require("@celljs/web");
17
+ const rxjs_1 = require("rxjs");
18
+ let UserManagerImpl = class UserManagerImpl {
19
+ constructor() {
20
+ this.loginUserInfoStorageKey = 'cell:loginUserInfo';
21
+ this.userInfoSubject = new rxjs_1.BehaviorSubject(undefined);
22
+ }
23
+ init() {
24
+ this.restOperations.interceptors.response.use(response => response, error => {
25
+ if (error.response) {
26
+ if (error.response.status === http_1.HttpStatus.UNAUTHORIZED && !error.response.headers[http_1.HttpHeaders.WWW_AUTHENTICATE.toLowerCase()]) {
27
+ this.openLoginPage();
28
+ return;
29
+ }
30
+ }
31
+ return Promise.reject(error);
32
+ });
33
+ this.userInfoSubject.subscribe(user => {
34
+ if (user) {
35
+ localStorage.setItem(this.loginUserInfoStorageKey, JSON.stringify(user));
36
+ }
37
+ else {
38
+ localStorage.removeItem(this.loginUserInfoStorageKey);
39
+ }
40
+ });
41
+ const userStr = localStorage.getItem(this.loginUserInfoStorageKey);
42
+ if (userStr) {
43
+ this.userInfoSubject.next(JSON.parse(userStr));
44
+ }
45
+ else {
46
+ this.getUserInfo().then(() => {
47
+ if (this.loginRequired) {
48
+ this.openLoginPage();
49
+ }
50
+ });
51
+ }
52
+ }
53
+ async openLoginPage(newWindow) {
54
+ if (newWindow === undefined) {
55
+ newWindow = this.openNewWindow;
56
+ }
57
+ this.userInfoSubject.next(undefined);
58
+ const url = await this.pathResolver.resolve(this.loginPage.replace(/{redirect}/g, encodeURI(window.location.href)));
59
+ if (newWindow) {
60
+ window.open(url);
61
+ }
62
+ else {
63
+ window.location.href = url;
64
+ }
65
+ }
66
+ async logout() {
67
+ this.userInfoSubject.next(undefined);
68
+ const method = (this.logoutMethod || http_1.HttpMethod.POST);
69
+ await this.restOperations.request({ url: this.logoutUrl, method });
70
+ window.location.href = await this.pathResolver.resolve(this.logoutSuccessUrl.replace(/{redirect}/g, encodeURI(window.location.href)));
71
+ }
72
+ async getUserInfo() {
73
+ const { url, method } = this.userInfoEndpoint;
74
+ const { data } = await this.restOperations.request({ url: await this.pathResolver.resolve(url), method });
75
+ this.userInfoSubject.next(data);
76
+ return data;
77
+ }
78
+ };
79
+ __decorate([
80
+ (0, core_1.Value)('cell.security.loginPage'),
81
+ __metadata("design:type", String)
82
+ ], UserManagerImpl.prototype, "loginPage", void 0);
83
+ __decorate([
84
+ (0, core_1.Value)('cell.security.openNewWindow'),
85
+ __metadata("design:type", Boolean)
86
+ ], UserManagerImpl.prototype, "openNewWindow", void 0);
87
+ __decorate([
88
+ (0, core_1.Value)('cell.security.logoutUrl'),
89
+ __metadata("design:type", String)
90
+ ], UserManagerImpl.prototype, "logoutUrl", void 0);
91
+ __decorate([
92
+ (0, core_1.Value)('cell.security.logoutSuccessUrl'),
93
+ __metadata("design:type", String)
94
+ ], UserManagerImpl.prototype, "logoutSuccessUrl", void 0);
95
+ __decorate([
96
+ (0, core_1.Value)('cell.security.logoutMethod'),
97
+ __metadata("design:type", String)
98
+ ], UserManagerImpl.prototype, "logoutMethod", void 0);
99
+ __decorate([
100
+ (0, core_1.Value)('cell.security.userInfoEndpoint'),
101
+ __metadata("design:type", Object)
102
+ ], UserManagerImpl.prototype, "userInfoEndpoint", void 0);
103
+ __decorate([
104
+ (0, core_1.Value)('cell.security.loginRequired'),
105
+ __metadata("design:type", Boolean)
106
+ ], UserManagerImpl.prototype, "loginRequired", void 0);
107
+ __decorate([
108
+ (0, core_1.Autowired)(http_1.RestOperations),
109
+ __metadata("design:type", Function)
110
+ ], UserManagerImpl.prototype, "restOperations", void 0);
111
+ __decorate([
112
+ (0, core_1.Autowired)(web_1.PathResolver),
113
+ __metadata("design:type", Object)
114
+ ], UserManagerImpl.prototype, "pathResolver", void 0);
115
+ __decorate([
116
+ (0, core_1.PostConstruct)(),
117
+ __metadata("design:type", Function),
118
+ __metadata("design:paramtypes", []),
119
+ __metadata("design:returntype", void 0)
120
+ ], UserManagerImpl.prototype, "init", null);
121
+ UserManagerImpl = __decorate([
122
+ (0, core_1.Component)(user_protocol_1.UserManager)
123
+ ], UserManagerImpl);
124
+ exports.UserManagerImpl = UserManagerImpl;
125
+ //# sourceMappingURL=user-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-manager.js","sourceRoot":"","sources":["../../../src/browser/user/user-manager.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,10 @@
1
+ import { User } from '../../common';
2
+ import { BehaviorSubject } from 'rxjs';
3
+ export declare const UserManager: unique symbol;
4
+ export interface UserManager {
5
+ openLoginPage(newWindow?: boolean): Promise<void>;
6
+ logout(): Promise<void>;
7
+ getUserInfo(): Promise<User | undefined>;
8
+ userInfoSubject: BehaviorSubject<User | undefined>;
9
+ }
10
+ //# sourceMappingURL=user-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-protocol.d.ts","sourceRoot":"","sources":["../../../src/browser/user/user-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,eAAO,MAAM,WAAW,eAAwB,CAAC;AAEjD,MAAM,WAAW,WAAW;IACxB,aAAa,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,WAAW,IAAI,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;IACzC,eAAe,EAAE,eAAe,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;CACtD"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserManager = void 0;
4
+ exports.UserManager = Symbol('UserManager');
5
+ //# sourceMappingURL=user-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-protocol.js","sourceRoot":"","sources":["../../../src/browser/user/user-protocol.ts"],"names":[],"mappings":";;;AAGa,QAAA,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './security-protocol';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,18 @@
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("./security-protocol"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC"}
@@ -0,0 +1,60 @@
1
+ export declare enum AuthorizeType {
2
+ Pre = "Pre",
3
+ Post = "Post"
4
+ }
5
+ export declare enum PolicyType {
6
+ el = "el",
7
+ acl = "Acl"
8
+ }
9
+ export interface Policy {
10
+ type: PolicyType | string;
11
+ authorizeType: AuthorizeType;
12
+ [key: string]: any;
13
+ }
14
+ export interface ElPolicy extends Policy {
15
+ context: any;
16
+ el: string;
17
+ }
18
+ export declare enum Effect {
19
+ Allow = "Allow",
20
+ Deny = "Deny"
21
+ }
22
+ export interface Statement {
23
+ effect: Effect;
24
+ action: string | string[];
25
+ resource: string | string[];
26
+ condition: {
27
+ [key: string]: any;
28
+ };
29
+ }
30
+ export interface AclPolicy extends Policy {
31
+ version?: string;
32
+ statement: Statement[];
33
+ }
34
+ export declare enum UserType {
35
+ Memery = "memory",
36
+ Database = "database"
37
+ }
38
+ export interface User {
39
+ type: string;
40
+ username: string;
41
+ password: string;
42
+ policies: Policy[];
43
+ accountNonExpired: boolean;
44
+ accountNonLocked: boolean;
45
+ credentialsNonExpired: boolean;
46
+ enabled: boolean;
47
+ claims?: {
48
+ [key: string]: any;
49
+ };
50
+ [key: string]: any;
51
+ }
52
+ export declare namespace User {
53
+ function is(user: Object | undefined): user is User;
54
+ }
55
+ export interface UserMapperRule {
56
+ avatar: string;
57
+ nickname: string;
58
+ [key: string]: any;
59
+ }
60
+ //# sourceMappingURL=security-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-protocol.d.ts","sourceRoot":"","sources":["../../src/common/security-protocol.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACrB,GAAG,QAAO;IAAE,IAAI,SAAQ;CAC3B;AAED,oBAAY,UAAU;IAClB,EAAE,OAAM;IAAE,GAAG,QAAO;CACvB;AAED,MAAM,WAAW,MAAM;IACnB,IAAI,EAAE,UAAU,GAAG,MAAM,CAAA;IACzB,aAAa,EAAE,aAAa,CAAC;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,MAAM,WAAW,QAAS,SAAQ,MAAM;IACpC,OAAO,EAAE,GAAG,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACd;AAED,oBAAY,MAAM;IACd,KAAK,UAAS;IAAE,IAAI,SAAQ;CAC/B;AAED,MAAM,WAAW,SAAS;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,SAAS,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACrC;AAED,MAAM,WAAW,SAAU,SAAQ,MAAM;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,SAAS,EAAE,CAAC;CAC1B;AAED,oBAAY,QAAQ;IAChB,MAAM,WAAW;IAAE,QAAQ,aAAa;CAC3C;AAED,MAAM,WAAW,IAAI;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,CAAC;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,yBAAiB,IAAI,CAAC;IAClB,SAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,IAAI,IAAI,CAIzD;CACJ;AAED,MAAM,WAAW,cAAc;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.User = exports.UserType = exports.Effect = exports.PolicyType = exports.AuthorizeType = void 0;
4
+ var AuthorizeType;
5
+ (function (AuthorizeType) {
6
+ AuthorizeType["Pre"] = "Pre";
7
+ AuthorizeType["Post"] = "Post";
8
+ })(AuthorizeType = exports.AuthorizeType || (exports.AuthorizeType = {}));
9
+ var PolicyType;
10
+ (function (PolicyType) {
11
+ PolicyType["el"] = "el";
12
+ PolicyType["acl"] = "Acl";
13
+ })(PolicyType = exports.PolicyType || (exports.PolicyType = {}));
14
+ var Effect;
15
+ (function (Effect) {
16
+ Effect["Allow"] = "Allow";
17
+ Effect["Deny"] = "Deny";
18
+ })(Effect = exports.Effect || (exports.Effect = {}));
19
+ var UserType;
20
+ (function (UserType) {
21
+ UserType["Memery"] = "memory";
22
+ UserType["Database"] = "database";
23
+ })(UserType = exports.UserType || (exports.UserType = {}));
24
+ var User;
25
+ (function (User) {
26
+ function is(user) {
27
+ return !!user && 'type' in user && 'username' in user && 'password' in user &&
28
+ 'policies' in user && 'accountNonExpired' in user && 'accountNonLocked' in user &&
29
+ 'credentialsNonExpired' in user && 'enabled' in user;
30
+ }
31
+ User.is = is;
32
+ })(User = exports.User || (exports.User = {}));
33
+ //# sourceMappingURL=security-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-protocol.js","sourceRoot":"","sources":["../../src/common/security-protocol.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAEX;AAFD,WAAY,aAAa;IACrB,4BAAU,CAAA;IAAE,8BAAY,CAAA;AAC5B,CAAC,EAFW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAExB;AAED,IAAY,UAEX;AAFD,WAAY,UAAU;IAClB,uBAAQ,CAAA;IAAE,yBAAU,CAAA;AACxB,CAAC,EAFW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAErB;AAaD,IAAY,MAEX;AAFD,WAAY,MAAM;IACd,yBAAc,CAAA;IAAE,uBAAY,CAAA;AAChC,CAAC,EAFW,MAAM,GAAN,cAAM,KAAN,cAAM,QAEjB;AAcD,IAAY,QAEX;AAFD,WAAY,QAAQ;IAChB,6BAAiB,CAAA;IAAE,iCAAqB,CAAA;AAC5C,CAAC,EAFW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAEnB;AAeD,IAAiB,IAAI,CAMpB;AAND,WAAiB,IAAI;IACjB,SAAgB,EAAE,CAAC,IAAwB;QACvC,OAAO,CAAC,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,UAAU,IAAI,IAAI,IAAI,UAAU,IAAI,IAAI;YACvE,UAAU,IAAI,IAAI,IAAI,mBAAmB,IAAI,IAAI,IAAI,kBAAkB,IAAI,IAAI;YAC/E,uBAAuB,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,CAAC;IAC7D,CAAC;IAJe,OAAE,KAIjB,CAAA;AACL,CAAC,EANgB,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAMpB"}
@@ -0,0 +1,9 @@
1
+ import { AccessDecisionManager, SecurityMetadata, AccessDecisionVoter } from './access-protocol';
2
+ export declare class AccessDecisionManagerImpl implements AccessDecisionManager {
3
+ protected readonly accessDecisionVoters: AccessDecisionVoter[];
4
+ protected prioritized: AccessDecisionVoter[];
5
+ constructor(accessDecisionVoters: AccessDecisionVoter[]);
6
+ decide(securityMetadata: SecurityMetadata): Promise<void>;
7
+ protected handleError(): void;
8
+ }
9
+ //# sourceMappingURL=access-decision-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-decision-manager.d.ts","sourceRoot":"","sources":["../../../src/node/access/access-decision-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,mBAAmB,EAAiC,MAAM,mBAAmB,CAAC;AAMhI,qBACa,yBAA0B,YAAW,qBAAqB;IAM/D,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,EAAE;IAJlE,SAAS,CAAC,WAAW,EAAE,mBAAmB,EAAE,CAAC;gBAItB,oBAAoB,EAAE,mBAAmB,EAAE;IAK5D,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB/D,SAAS,CAAC,WAAW;CAOxB"}
@@ -0,0 +1,56 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AccessDecisionManagerImpl = void 0;
16
+ const access_protocol_1 = require("./access-protocol");
17
+ const core_1 = require("@celljs/core");
18
+ const error_1 = require("../error");
19
+ const context_1 = require("../context");
20
+ const http_1 = require("@celljs/http");
21
+ let AccessDecisionManagerImpl = class AccessDecisionManagerImpl {
22
+ constructor(accessDecisionVoters) {
23
+ this.accessDecisionVoters = accessDecisionVoters;
24
+ this.prioritized = core_1.Prioritizeable.prioritizeAllSync(this.accessDecisionVoters).map(c => c.value);
25
+ }
26
+ async decide(securityMetadata) {
27
+ let grant = 0;
28
+ for (const voter of this.prioritized) {
29
+ if (await voter.support(securityMetadata)) {
30
+ const result = await voter.vote(securityMetadata);
31
+ if (result === access_protocol_1.ACCESS_DENIED) {
32
+ this.handleError();
33
+ }
34
+ else if (result === access_protocol_1.ACCESS_GRANTED) {
35
+ grant++;
36
+ }
37
+ }
38
+ }
39
+ if (grant <= 0) {
40
+ this.handleError();
41
+ }
42
+ }
43
+ handleError() {
44
+ if (context_1.SecurityContext.getAuthentication().authenticated) {
45
+ throw new error_1.AccessDeniedError(http_1.HttpStatus.FORBIDDEN_REASON_PHRASE);
46
+ }
47
+ throw new error_1.AuthenticationError(http_1.HttpStatus.UNAUTHORIZED_REASON_PHRASE);
48
+ }
49
+ };
50
+ AccessDecisionManagerImpl = __decorate([
51
+ (0, core_1.Component)(access_protocol_1.AccessDecisionManager),
52
+ __param(0, (0, core_1.Autowired)(access_protocol_1.AccessDecisionVoter)),
53
+ __metadata("design:paramtypes", [Array])
54
+ ], AccessDecisionManagerImpl);
55
+ exports.AccessDecisionManagerImpl = AccessDecisionManagerImpl;
56
+ //# sourceMappingURL=access-decision-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-decision-manager.js","sourceRoot":"","sources":["../../../src/node/access/access-decision-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAgI;AAChI,uCAAoE;AACpE,oCAAkE;AAClE,wCAA6C;AAC7C,uCAA0C;AAGnC,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAIlC,YAEuB,oBAA2C;QAA3C,yBAAoB,GAApB,oBAAoB,CAAuB;QAE9D,IAAI,CAAC,WAAW,GAAG,qBAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACrG,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,gBAAkC;QAC3C,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE;YAClC,IAAI,MAAM,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;gBACvC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;gBAClD,IAAI,MAAM,KAAK,+BAAa,EAAE;oBAC1B,IAAI,CAAC,WAAW,EAAE,CAAC;iBACtB;qBAAM,IAAI,MAAM,KAAK,gCAAc,EAAE;oBAClC,KAAK,EAAE,CAAC;iBACX;aACJ;SACJ;QACD,IAAI,KAAK,IAAI,CAAC,EAAE;YACZ,IAAI,CAAC,WAAW,EAAE,CAAC;SACtB;IACL,CAAC;IAES,WAAW;QACjB,IAAI,yBAAe,CAAC,iBAAiB,EAAE,CAAC,aAAa,EAAE;YACnD,MAAM,IAAI,yBAAiB,CAAC,iBAAU,CAAC,uBAAuB,CAAC,CAAC;SACnE;QACD,MAAM,IAAI,2BAAmB,CAAC,iBAAU,CAAC,0BAA0B,CAAC,CAAC;IACzE,CAAC;CAEJ,CAAA;AAnCY,yBAAyB;IADrC,IAAA,gBAAS,EAAC,uCAAqB,CAAC;IAMxB,WAAA,IAAA,gBAAS,EAAC,qCAAmB,CAAC,CAAA;;GAL1B,yBAAyB,CAmCrC;AAnCY,8DAAyB"}
@@ -0,0 +1,5 @@
1
+ import { Policy } from '../../common';
2
+ export declare namespace AccessDecisionUtils {
3
+ function decide(resource: string, action: string, policies?: Policy[], principal?: any): Promise<void>;
4
+ }
5
+ //# sourceMappingURL=access-decision-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-decision-utils.d.ts","sourceRoot":"","sources":["../../../src/node/access/access-decision-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,MAAM,EAAE,MAAM,cAAc,CAAC;AAIrD,yBAAiB,mBAAmB,CAAC;IACjC,SAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,EAAO,EAAE,SAAS,CAAC,EAAE,GAAG,iBAUhG;CACJ"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccessDecisionUtils = void 0;
4
+ const core_1 = require("@celljs/core");
5
+ const common_1 = require("../../common");
6
+ const context_1 = require("../context");
7
+ const access_protocol_1 = require("./access-protocol");
8
+ var AccessDecisionUtils;
9
+ (function (AccessDecisionUtils) {
10
+ function decide(resource, action, policies = [], principal) {
11
+ const accessDecisionManager = core_1.ContainerUtil.get(access_protocol_1.AccessDecisionManager);
12
+ return accessDecisionManager.decide({
13
+ authorizeType: common_1.AuthorizeType.Pre,
14
+ action,
15
+ resource,
16
+ principal: principal || context_1.SecurityContext.getAuthentication().principal,
17
+ policies,
18
+ grant: 0
19
+ });
20
+ }
21
+ AccessDecisionUtils.decide = decide;
22
+ })(AccessDecisionUtils = exports.AccessDecisionUtils || (exports.AccessDecisionUtils = {}));
23
+ //# sourceMappingURL=access-decision-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-decision-utils.js","sourceRoot":"","sources":["../../../src/node/access/access-decision-utils.ts"],"names":[],"mappings":";;;AAAA,uCAA6C;AAC7C,yCAAqD;AACrD,wCAA6C;AAC7C,uDAA0D;AAE1D,IAAiB,mBAAmB,CAYnC;AAZD,WAAiB,mBAAmB;IAChC,SAAgB,MAAM,CAAC,QAAgB,EAAE,MAAc,EAAE,WAAqB,EAAE,EAAE,SAAe;QAC7F,MAAM,qBAAqB,GAAG,oBAAa,CAAC,GAAG,CAAwB,uCAAqB,CAAC,CAAC;QAC9F,OAAO,qBAAqB,CAAC,MAAM,CAAC;YAChC,aAAa,EAAE,sBAAa,CAAC,GAAG;YAChC,MAAM;YACN,QAAQ;YACR,SAAS,EAAE,SAAS,IAAI,yBAAe,CAAC,iBAAiB,EAAE,CAAC,SAAS;YACrE,QAAQ;YACR,KAAK,EAAE,CAAC;SACX,CAAC,CAAC;IACP,CAAC;IAVe,0BAAM,SAUrB,CAAA;AACL,CAAC,EAZgB,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAYnC"}
@@ -0,0 +1,14 @@
1
+ import { SecurityMetadata, AccessDecisionVoter, PolicyResolver, PolicyProvider } from './access-protocol';
2
+ export declare class PolicyBasedVoter implements AccessDecisionVoter {
3
+ readonly priority: number;
4
+ protected readonly policyResolvers: PolicyResolver[];
5
+ protected readonly policyProviders: PolicyProvider[];
6
+ vote(securityMetadata: SecurityMetadata): Promise<number>;
7
+ support(securityMetadata: SecurityMetadata): Promise<boolean>;
8
+ }
9
+ export declare class TenantVoter implements AccessDecisionVoter {
10
+ readonly priority = 2000;
11
+ vote(securityMetadata: SecurityMetadata): Promise<number>;
12
+ support(securityMetadata: SecurityMetadata): Promise<boolean>;
13
+ }
14
+ //# sourceMappingURL=access-decision-voter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-decision-voter.d.ts","sourceRoot":"","sources":["../../../src/node/access/access-decision-voter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EACb,cAAc,EAAE,cAAc,EAAyB,MAAM,mBAAmB,CAAC;AAKlH,qBACa,gBAAiB,YAAW,mBAAmB;IAExD,QAAQ,CAAC,QAAQ,SAA+B;IAGhD,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,cAAc,EAAE,CAAC;IAGrD,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,cAAc,EAAE,CAAC;IAE/C,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAiCzD,OAAO,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;CAItE;AAED,qBACa,WAAY,YAAW,mBAAmB;IAEnD,QAAQ,CAAC,QAAQ,QAAyB;IAEpC,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAOzD,OAAO,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;CAItE"}