loaders.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. 'use strict';
  2. var module = angular.module('keycloak.loaders', [ 'keycloak.services', 'ngResource' ]);
  3. module.factory('Loader', function($q) {
  4. var loader = {};
  5. loader.get = function(service, id) {
  6. return function() {
  7. var i = id && id();
  8. var delay = $q.defer();
  9. service.get(i, function(entry) {
  10. delay.resolve(entry);
  11. }, function() {
  12. delay.reject('Unable to fetch ' + i);
  13. });
  14. return delay.promise;
  15. };
  16. };
  17. loader.query = function(service, id) {
  18. return function() {
  19. var i = id && id();
  20. var delay = $q.defer();
  21. service.query(i, function(entry) {
  22. delay.resolve(entry);
  23. }, function() {
  24. delay.reject('Unable to fetch ' + i);
  25. });
  26. return delay.promise;
  27. };
  28. };
  29. return loader;
  30. });
  31. module.factory('RealmListLoader', function(Loader, Realm, $q) {
  32. return Loader.get(Realm);
  33. });
  34. module.factory('ServerInfoLoader', function(Loader, ServerInfo) {
  35. return function() {
  36. return ServerInfo.promise;
  37. };
  38. });
  39. module.factory('RealmLoader', function(Loader, Realm, $route, $q) {
  40. return Loader.get(Realm, function() {
  41. return {
  42. id : $route.current.params.realm
  43. }
  44. });
  45. });
  46. module.factory('RealmKeysLoader', function(Loader, RealmKeys, $route, $q) {
  47. return Loader.get(RealmKeys, function() {
  48. return {
  49. id : $route.current.params.realm
  50. }
  51. });
  52. });
  53. module.factory('RealmSpecificLocalesLoader', function(Loader, RealmSpecificLocales, $route, $q) {
  54. return Loader.get(RealmSpecificLocales, function() {
  55. return {
  56. id : $route.current.params.realm
  57. }
  58. });
  59. });
  60. module.factory('RealmSpecificlocalizationTextLoader', function(Loader, RealmSpecificLocalizationText, $route, $q) {
  61. return Loader.get(RealmSpecificLocalizationText, function() {
  62. return {
  63. realm : $route.current.params.realm,
  64. locale : $route.current.params.locale,
  65. key: $route.current.params.key
  66. }
  67. });
  68. });
  69. module.factory('RealmEventsConfigLoader', function(Loader, RealmEventsConfig, $route, $q) {
  70. return Loader.get(RealmEventsConfig, function() {
  71. return {
  72. id : $route.current.params.realm
  73. }
  74. });
  75. });
  76. module.factory('UserListLoader', function(Loader, User, $route, $q) {
  77. return Loader.query(User, function() {
  78. return {
  79. realm : $route.current.params.realm
  80. }
  81. });
  82. });
  83. module.factory('RequiredActionsListLoader', function(Loader, RequiredActions, $route, $q) {
  84. return Loader.query(RequiredActions, function() {
  85. return {
  86. realm : $route.current.params.realm
  87. }
  88. });
  89. });
  90. module.factory('UnregisteredRequiredActionsListLoader', function(Loader, UnregisteredRequiredActions, $route, $q) {
  91. return Loader.query(UnregisteredRequiredActions, function() {
  92. return {
  93. realm : $route.current.params.realm
  94. }
  95. });
  96. });
  97. module.factory('RealmSessionStatsLoader', function(Loader, RealmSessionStats, $route, $q) {
  98. return Loader.get(RealmSessionStats, function() {
  99. return {
  100. realm : $route.current.params.realm
  101. }
  102. });
  103. });
  104. module.factory('RealmClientSessionStatsLoader', function(Loader, RealmClientSessionStats, $route, $q) {
  105. return Loader.query(RealmClientSessionStats, function() {
  106. return {
  107. realm : $route.current.params.realm
  108. }
  109. });
  110. });
  111. module.factory('ClientProtocolMapperLoader', function(Loader, ClientProtocolMapper, $route, $q) {
  112. return Loader.get(ClientProtocolMapper, function() {
  113. return {
  114. realm : $route.current.params.realm,
  115. client : $route.current.params.client,
  116. id: $route.current.params.id
  117. }
  118. });
  119. });
  120. module.factory('ClientScopeProtocolMapperLoader', function(Loader, ClientScopeProtocolMapper, $route, $q) {
  121. return Loader.get(ClientScopeProtocolMapper, function() {
  122. return {
  123. realm : $route.current.params.realm,
  124. clientScope : $route.current.params.clientScope,
  125. id: $route.current.params.id
  126. }
  127. });
  128. });
  129. module.factory('UserLoader', function(Loader, User, $route, $q) {
  130. return Loader.get(User, function() {
  131. return {
  132. realm : $route.current.params.realm,
  133. userId : $route.current.params.user
  134. }
  135. });
  136. });
  137. module.factory('ComponentLoader', function(Loader, Components, $route, $q) {
  138. return Loader.get(Components, function() {
  139. return {
  140. realm : $route.current.params.realm,
  141. componentId: $route.current.params.componentId
  142. }
  143. });
  144. });
  145. module.factory('LDAPMapperLoader', function(Loader, Components, $route, $q) {
  146. return Loader.get(Components, function() {
  147. return {
  148. realm : $route.current.params.realm,
  149. componentId: $route.current.params.mapperId
  150. }
  151. });
  152. });
  153. module.factory('ComponentsLoader', function(Loader, Components, $route, $q) {
  154. var componentsLoader = {};
  155. componentsLoader.loadComponents = function(parent, componentType) {
  156. return Loader.query(Components, function() {
  157. return {
  158. realm : $route.current.params.realm,
  159. parent : parent,
  160. type: componentType
  161. }
  162. })();
  163. };
  164. return componentsLoader;
  165. });
  166. module.factory('SubComponentTypesLoader', function(Loader, SubComponentTypes, $route, $q) {
  167. var componentsLoader = {};
  168. componentsLoader.loadComponents = function(parent, componentType) {
  169. return Loader.query(SubComponentTypes, function() {
  170. return {
  171. realm : $route.current.params.realm,
  172. componentId : parent,
  173. type: componentType
  174. }
  175. })();
  176. };
  177. return componentsLoader;
  178. });
  179. module.factory('UserSessionStatsLoader', function(Loader, UserSessionStats, $route, $q) {
  180. return Loader.get(UserSessionStats, function() {
  181. return {
  182. realm : $route.current.params.realm,
  183. user : $route.current.params.user
  184. }
  185. });
  186. });
  187. module.factory('UserSessionsLoader', function(Loader, UserSessions, $route, $q) {
  188. return Loader.query(UserSessions, function() {
  189. return {
  190. realm : $route.current.params.realm,
  191. user : $route.current.params.user
  192. }
  193. });
  194. });
  195. module.factory('UserOfflineSessionsLoader', function(Loader, UserOfflineSessions, $route, $q) {
  196. return Loader.query(UserOfflineSessions, function() {
  197. return {
  198. realm : $route.current.params.realm,
  199. user : $route.current.params.user,
  200. client : $route.current.params.client
  201. }
  202. });
  203. });
  204. module.factory('UserFederatedIdentityLoader', function(Loader, UserFederatedIdentities, $route, $q) {
  205. return Loader.query(UserFederatedIdentities, function() {
  206. return {
  207. realm : $route.current.params.realm,
  208. user : $route.current.params.user
  209. }
  210. });
  211. });
  212. module.factory('UserConsentsLoader', function(Loader, UserConsents, $route, $q) {
  213. return Loader.query(UserConsents, function() {
  214. return {
  215. realm : $route.current.params.realm,
  216. user : $route.current.params.user
  217. }
  218. });
  219. });
  220. module.factory('RoleLoader', function(Loader, RoleById, $route, $q) {
  221. return Loader.get(RoleById, function() {
  222. return {
  223. realm : $route.current.params.realm,
  224. role : $route.current.params.role
  225. }
  226. });
  227. });
  228. module.factory('RoleListLoader', function(Loader, Role, $route, $q) {
  229. return Loader.query(Role, function() {
  230. return {
  231. realm : $route.current.params.realm
  232. }
  233. });
  234. });
  235. module.factory('ClientRoleLoader', function(Loader, RoleById, $route, $q) {
  236. return Loader.get(RoleById, function() {
  237. return {
  238. realm : $route.current.params.realm,
  239. client : $route.current.params.client,
  240. role : $route.current.params.role
  241. }
  242. });
  243. });
  244. module.factory('ClientSessionStatsLoader', function(Loader, ClientSessionStats, $route, $q) {
  245. return Loader.get(ClientSessionStats, function() {
  246. return {
  247. realm : $route.current.params.realm,
  248. client : $route.current.params.client
  249. }
  250. });
  251. });
  252. module.factory('ClientSessionCountLoader', function(Loader, ClientSessionCount, $route, $q) {
  253. return Loader.get(ClientSessionCount, function() {
  254. return {
  255. realm : $route.current.params.realm,
  256. client : $route.current.params.client
  257. }
  258. });
  259. });
  260. module.factory('ClientOfflineSessionCountLoader', function(Loader, ClientOfflineSessionCount, $route, $q) {
  261. return Loader.get(ClientOfflineSessionCount, function() {
  262. return {
  263. realm : $route.current.params.realm,
  264. client : $route.current.params.client
  265. }
  266. });
  267. });
  268. module.factory('ClientDefaultClientScopesLoader', function(Loader, ClientDefaultClientScopes, $route, $q) {
  269. return Loader.query(ClientDefaultClientScopes, function() {
  270. return {
  271. realm : $route.current.params.realm,
  272. client : $route.current.params.client
  273. }
  274. });
  275. });
  276. module.factory('ClientOptionalClientScopesLoader', function(Loader, ClientOptionalClientScopes, $route, $q) {
  277. return Loader.query(ClientOptionalClientScopes, function() {
  278. return {
  279. realm : $route.current.params.realm,
  280. client : $route.current.params.client
  281. }
  282. });
  283. });
  284. module.factory('ClientLoader', function(Loader, Client, $route, $q) {
  285. return Loader.get(Client, function() {
  286. return {
  287. realm : $route.current.params.realm,
  288. client : $route.current.params.client
  289. }
  290. });
  291. });
  292. module.factory('ClientListLoader', function(Loader, Client, $route, $q) {
  293. return Loader.query(Client, function() {
  294. return {
  295. realm : $route.current.params.realm,
  296. first: 0,
  297. max: 20
  298. }
  299. });
  300. });
  301. module.factory('ClientScopeLoader', function(Loader, ClientScope, $route, $q) {
  302. return Loader.get(ClientScope, function() {
  303. return {
  304. realm : $route.current.params.realm,
  305. clientScope : $route.current.params.clientScope
  306. }
  307. });
  308. });
  309. module.factory('ClientScopeListLoader', function(Loader, ClientScope, $route, $q) {
  310. return Loader.query(ClientScope, function() {
  311. return {
  312. realm : $route.current.params.realm
  313. }
  314. });
  315. });
  316. module.factory('RealmDefaultClientScopesLoader', function(Loader, RealmDefaultClientScopes, $route, $q) {
  317. return Loader.query(RealmDefaultClientScopes, function() {
  318. return {
  319. realm : $route.current.params.realm
  320. }
  321. });
  322. });
  323. module.factory('RealmOptionalClientScopesLoader', function(Loader, RealmOptionalClientScopes, $route, $q) {
  324. return Loader.query(RealmOptionalClientScopes, function() {
  325. return {
  326. realm : $route.current.params.realm
  327. }
  328. });
  329. });
  330. module.factory('ClientServiceAccountUserLoader', function(Loader, ClientServiceAccountUser, $route, $q) {
  331. return Loader.get(ClientServiceAccountUser, function() {
  332. return {
  333. realm : $route.current.params.realm,
  334. client : $route.current.params.client
  335. }
  336. });
  337. });
  338. module.factory('RoleMappingLoader', function(Loader, RoleMapping, $route, $q) {
  339. var realm = $route.current.params.realm || $route.current.params.client;
  340. return Loader.query(RoleMapping, function() {
  341. return {
  342. realm : realm,
  343. role : $route.current.params.role
  344. }
  345. });
  346. });
  347. module.factory('IdentityProviderLoader', function(Loader, IdentityProvider, $route, $q) {
  348. return Loader.get(IdentityProvider, function () {
  349. return {
  350. realm: $route.current.params.realm,
  351. alias: $route.current.params.alias
  352. }
  353. });
  354. });
  355. module.factory('IdentityProviderFactoryLoader', function(Loader, IdentityProviderFactory, $route, $q) {
  356. return Loader.get(IdentityProviderFactory, function () {
  357. return {
  358. realm: $route.current.params.realm,
  359. provider_id: $route.current.params.provider_id
  360. }
  361. });
  362. });
  363. module.factory('IdentityProviderMapperTypesLoader', function(Loader, IdentityProviderMapperTypes, $route, $q) {
  364. return Loader.get(IdentityProviderMapperTypes, function () {
  365. return {
  366. realm: $route.current.params.realm,
  367. alias: $route.current.params.alias
  368. }
  369. });
  370. });
  371. module.factory('IdentityProviderMappersLoader', function(Loader, IdentityProviderMappers, $route, $q) {
  372. return Loader.query(IdentityProviderMappers, function () {
  373. return {
  374. realm: $route.current.params.realm,
  375. alias: $route.current.params.alias
  376. }
  377. });
  378. });
  379. module.factory('IdentityProviderMapperLoader', function(Loader, IdentityProviderMapper, $route, $q) {
  380. return Loader.get(IdentityProviderMapper, function () {
  381. return {
  382. realm: $route.current.params.realm,
  383. alias: $route.current.params.alias,
  384. mapperId: $route.current.params.mapperId
  385. }
  386. });
  387. });
  388. module.factory('AuthenticationFlowsLoader', function(Loader, AuthenticationFlows, $route, $q) {
  389. return Loader.query(AuthenticationFlows, function() {
  390. return {
  391. realm : $route.current.params.realm,
  392. flow: ''
  393. }
  394. });
  395. });
  396. module.factory('AuthenticationFormProvidersLoader', function(Loader, AuthenticationFormProviders, $route, $q) {
  397. return Loader.query(AuthenticationFormProviders, function() {
  398. return {
  399. realm : $route.current.params.realm
  400. }
  401. });
  402. });
  403. module.factory('AuthenticationFormActionProvidersLoader', function(Loader, AuthenticationFormActionProviders, $route, $q) {
  404. return Loader.query(AuthenticationFormActionProviders, function() {
  405. return {
  406. realm : $route.current.params.realm
  407. }
  408. });
  409. });
  410. module.factory('AuthenticatorProvidersLoader', function(Loader, AuthenticatorProviders, $route, $q) {
  411. return Loader.query(AuthenticatorProviders, function() {
  412. return {
  413. realm : $route.current.params.realm
  414. }
  415. });
  416. });
  417. module.factory('ClientAuthenticatorProvidersLoader', function(Loader, ClientAuthenticatorProviders, $route, $q) {
  418. return Loader.query(ClientAuthenticatorProviders, function() {
  419. return {
  420. realm : $route.current.params.realm
  421. }
  422. });
  423. });
  424. module.factory('AuthenticationFlowLoader', function(Loader, AuthenticationFlows, $route, $q) {
  425. return Loader.get(AuthenticationFlows, function() {
  426. return {
  427. realm : $route.current.params.realm,
  428. flow: $route.current.params.flow
  429. }
  430. });
  431. });
  432. module.factory('AuthenticationConfigDescriptionLoader', function(Loader, AuthenticationConfigDescription, $route, $q) {
  433. return Loader.get(AuthenticationConfigDescription, function () {
  434. return {
  435. realm: $route.current.params.realm,
  436. provider: $route.current.params.provider
  437. }
  438. });
  439. });
  440. module.factory('PerClientAuthenticationConfigDescriptionLoader', function(Loader, PerClientAuthenticationConfigDescription, $route, $q) {
  441. return Loader.get(PerClientAuthenticationConfigDescription, function () {
  442. return {
  443. realm: $route.current.params.realm
  444. }
  445. });
  446. });
  447. module.factory('ExecutionIdLoader', function($route) {
  448. return function() { return $route.current.params.executionId; };
  449. });
  450. module.factory('AuthenticationConfigLoader', function(Loader, AuthenticationConfig, $route, $q) {
  451. return Loader.get(AuthenticationConfig, function () {
  452. return {
  453. realm: $route.current.params.realm,
  454. config: $route.current.params.config
  455. }
  456. });
  457. });
  458. module.factory('GroupListLoader', function(Loader, Groups, $route, $q) {
  459. return Loader.query(Groups, function() {
  460. return {
  461. realm : $route.current.params.realm
  462. }
  463. });
  464. });
  465. module.factory('GroupCountLoader', function(Loader, GroupsCount, $route, $q) {
  466. return Loader.query(GroupsCount, function() {
  467. return {
  468. realm : $route.current.params.realm,
  469. top : true
  470. }
  471. });
  472. });
  473. module.factory('GroupLoader', function(Loader, Group, $route, $q) {
  474. return Loader.get(Group, function() {
  475. return {
  476. realm : $route.current.params.realm,
  477. groupId : $route.current.params.group
  478. }
  479. });
  480. });
  481. module.factory('ClientInitialAccessLoader', function(Loader, ClientInitialAccess, $route) {
  482. return Loader.query(ClientInitialAccess, function() {
  483. return {
  484. realm: $route.current.params.realm
  485. }
  486. });
  487. });
  488. module.factory('ClientRegistrationPolicyProvidersLoader', function(Loader, ClientRegistrationPolicyProviders, $route) {
  489. return Loader.query(ClientRegistrationPolicyProviders, function() {
  490. return {
  491. realm: $route.current.params.realm
  492. }
  493. });
  494. });
  495. module.factory('ClientPoliciesProfilesLoader', function(Loader, ClientPoliciesProfiles, $route , $q) {
  496. var clientPoliciesLoader = {};
  497. clientPoliciesLoader.loadClientProfiles = function(includeGlobalProfiles) {
  498. return Loader.get(ClientPoliciesProfiles, function() {
  499. return {
  500. realm : $route.current.params.realm,
  501. includeGlobalProfiles : includeGlobalProfiles
  502. }
  503. })();
  504. };
  505. return clientPoliciesLoader;
  506. });
  507. module.factory('ClientPoliciesLoader', function(Loader, ClientPolicies, $route) {
  508. return Loader.get(ClientPolicies, function() {
  509. return {
  510. realm: $route.current.params.realm
  511. }
  512. });
  513. });