authz-app.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright 2016 Red Hat, Inc., and individual contributors
  4. * as indicated by the @author tags.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. module.requires.push('ui.ace');
  19. module.config(['$routeProvider', function ($routeProvider) {
  20. $routeProvider
  21. .when('/realms/:realm/authz', {
  22. templateUrl: resourceUrl + '/partials/authz/resource-server-list.html',
  23. resolve: {
  24. realm: function (RealmLoader) {
  25. return RealmLoader();
  26. }
  27. },
  28. controller: 'ResourceServerCtrl'
  29. }).when('/realms/:realm/clients/:client/authz/resource-server/create', {
  30. templateUrl: resourceUrl + '/partials/authz/resource-server-detail.html',
  31. resolve: {
  32. realm: function (RealmLoader) {
  33. return RealmLoader();
  34. },
  35. client : function(ClientLoader) {
  36. return ClientLoader();
  37. },
  38. clients: function (ClientListLoader) {
  39. return ClientListLoader();
  40. }
  41. },
  42. controller: 'ResourceServerDetailCtrl'
  43. }).when('/realms/:realm/clients/:client/authz/resource-server', {
  44. templateUrl: resourceUrl + '/partials/authz/resource-server-detail.html',
  45. resolve: {
  46. realm: function (RealmLoader) {
  47. return RealmLoader();
  48. },
  49. client : function(ClientLoader) {
  50. return ClientLoader();
  51. },
  52. clients: function (ClientListLoader) {
  53. return ClientListLoader();
  54. },
  55. serverInfo: function (ServerInfoLoader) {
  56. return ServerInfoLoader();
  57. }
  58. },
  59. controller: 'ResourceServerDetailCtrl'
  60. }).when('/realms/:realm/clients/:client/authz/resource-server/export-settings', {
  61. templateUrl: resourceUrl + '/partials/authz/resource-server-export-settings.html',
  62. resolve: {
  63. realm: function (RealmLoader) {
  64. return RealmLoader();
  65. },
  66. client : function(ClientLoader) {
  67. return ClientLoader();
  68. },
  69. clients: function (ClientListLoader) {
  70. return ClientListLoader();
  71. },
  72. serverInfo: function (ServerInfoLoader) {
  73. return ServerInfoLoader();
  74. }
  75. },
  76. controller: 'ResourceServerDetailCtrl'
  77. }).when('/realms/:realm/clients/:client/authz/resource-server/evaluate', {
  78. templateUrl: resourceUrl + '/partials/authz/policy/resource-server-policy-evaluate.html',
  79. resolve: {
  80. realm: function (RealmLoader) {
  81. return RealmLoader();
  82. },
  83. client : function(ClientLoader) {
  84. return ClientLoader();
  85. },
  86. clients: function (ClientListLoader) {
  87. return ClientListLoader();
  88. },
  89. roles: function (RoleListLoader) {
  90. return new RoleListLoader();
  91. }
  92. },
  93. controller: 'PolicyEvaluateCtrl'
  94. }).when('/realms/:realm/clients/:client/authz/resource-server/evaluate/result', {
  95. templateUrl: resourceUrl + '/partials/authz/policy/resource-server-policy-evaluate-result.html',
  96. resolve: {
  97. realm: function (RealmLoader) {
  98. return RealmLoader();
  99. },
  100. client : function(ClientLoader) {
  101. return ClientLoader();
  102. },
  103. },
  104. controller: 'PolicyEvaluateCtrl'
  105. }).when('/realms/:realm/clients/:client/authz/resource-server/resource', {
  106. templateUrl: resourceUrl + '/partials/authz/resource-server-resource-list.html',
  107. resolve: {
  108. realm: function (RealmLoader) {
  109. return RealmLoader();
  110. },
  111. client : function(ClientLoader) {
  112. return ClientLoader();
  113. }
  114. },
  115. controller: 'ResourceServerResourceCtrl'
  116. }).when('/realms/:realm/clients/:client/authz/resource-server/resource/create', {
  117. templateUrl: resourceUrl + '/partials/authz/resource-server-resource-detail.html',
  118. resolve: {
  119. realm: function (RealmLoader) {
  120. return RealmLoader();
  121. },
  122. client : function(ClientLoader) {
  123. return ClientLoader();
  124. }
  125. },
  126. controller: 'ResourceServerResourceDetailCtrl'
  127. }).when('/realms/:realm/clients/:client/authz/resource-server/resource/:rsrid', {
  128. templateUrl: resourceUrl + '/partials/authz/resource-server-resource-detail.html',
  129. resolve: {
  130. realm: function (RealmLoader) {
  131. return RealmLoader();
  132. },
  133. client : function(ClientLoader) {
  134. return ClientLoader();
  135. }
  136. },
  137. controller: 'ResourceServerResourceDetailCtrl'
  138. }).when('/realms/:realm/clients/:client/authz/resource-server/scope', {
  139. templateUrl: resourceUrl + '/partials/authz/resource-server-scope-list.html',
  140. resolve: {
  141. realm: function (RealmLoader) {
  142. return RealmLoader();
  143. },
  144. client : function(ClientLoader) {
  145. return ClientLoader();
  146. }
  147. },
  148. controller: 'ResourceServerScopeCtrl'
  149. }).when('/realms/:realm/clients/:client/authz/resource-server/scope/create', {
  150. templateUrl: resourceUrl + '/partials/authz/resource-server-scope-detail.html',
  151. resolve: {
  152. realm: function (RealmLoader) {
  153. return RealmLoader();
  154. },
  155. client : function(ClientLoader) {
  156. return ClientLoader();
  157. }
  158. },
  159. controller: 'ResourceServerScopeDetailCtrl'
  160. }).when('/realms/:realm/clients/:client/authz/resource-server/scope/:id', {
  161. templateUrl: resourceUrl + '/partials/authz/resource-server-scope-detail.html',
  162. resolve: {
  163. realm: function (RealmLoader) {
  164. return RealmLoader();
  165. },
  166. client : function(ClientLoader) {
  167. return ClientLoader();
  168. }
  169. },
  170. controller: 'ResourceServerScopeDetailCtrl'
  171. }).when('/realms/:realm/clients/:client/authz/resource-server/permission', {
  172. templateUrl: resourceUrl + '/partials/authz/permission/resource-server-permission-list.html',
  173. resolve: {
  174. realm: function (RealmLoader) {
  175. return RealmLoader();
  176. },
  177. client : function(ClientLoader) {
  178. return ClientLoader();
  179. }
  180. },
  181. controller: 'ResourceServerPermissionCtrl'
  182. }).when('/realms/:realm/clients/:client/authz/resource-server/policy', {
  183. templateUrl: resourceUrl + '/partials/authz/policy/resource-server-policy-list.html',
  184. resolve: {
  185. realm: function (RealmLoader) {
  186. return RealmLoader();
  187. },
  188. client : function(ClientLoader) {
  189. return ClientLoader();
  190. }
  191. },
  192. controller: 'ResourceServerPolicyCtrl'
  193. }).when('/realms/:realm/clients/:client/authz/resource-server/permission/resource/create', {
  194. templateUrl: resourceUrl + '/partials/authz/permission/provider/resource-server-policy-resource-detail.html',
  195. resolve: {
  196. realm: function (RealmLoader) {
  197. return RealmLoader();
  198. },
  199. client : function(ClientLoader) {
  200. return ClientLoader();
  201. }
  202. },
  203. controller: 'ResourceServerPolicyResourceDetailCtrl'
  204. }).when('/realms/:realm/clients/:client/authz/resource-server/permission/resource/:id', {
  205. templateUrl: resourceUrl + '/partials/authz/permission/provider/resource-server-policy-resource-detail.html',
  206. resolve: {
  207. realm: function (RealmLoader) {
  208. return RealmLoader();
  209. },
  210. client : function(ClientLoader) {
  211. return ClientLoader();
  212. }
  213. },
  214. controller: 'ResourceServerPolicyResourceDetailCtrl'
  215. }).when('/realms/:realm/clients/:client/authz/resource-server/permission/scope/create', {
  216. templateUrl: resourceUrl + '/partials/authz/permission/provider/resource-server-policy-scope-detail.html',
  217. resolve: {
  218. realm: function (RealmLoader) {
  219. return RealmLoader();
  220. },
  221. client : function(ClientLoader) {
  222. return ClientLoader();
  223. }
  224. },
  225. controller: 'ResourceServerPolicyScopeDetailCtrl'
  226. }).when('/realms/:realm/clients/:client/authz/resource-server/permission/scope/:id', {
  227. templateUrl: resourceUrl + '/partials/authz/permission/provider/resource-server-policy-scope-detail.html',
  228. resolve: {
  229. realm: function (RealmLoader) {
  230. return RealmLoader();
  231. },
  232. client : function(ClientLoader) {
  233. return ClientLoader();
  234. }
  235. },
  236. controller: 'ResourceServerPolicyScopeDetailCtrl'
  237. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/user/create', {
  238. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-user-detail.html',
  239. resolve: {
  240. realm: function (RealmLoader) {
  241. return RealmLoader();
  242. },
  243. client : function(ClientLoader) {
  244. return ClientLoader();
  245. }
  246. },
  247. controller: 'ResourceServerPolicyUserDetailCtrl'
  248. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/user/:id', {
  249. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-user-detail.html',
  250. resolve: {
  251. realm: function (RealmLoader) {
  252. return RealmLoader();
  253. },
  254. client : function(ClientLoader) {
  255. return ClientLoader();
  256. }
  257. },
  258. controller: 'ResourceServerPolicyUserDetailCtrl'
  259. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/client/create', {
  260. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-client-detail.html',
  261. resolve: {
  262. realm: function (RealmLoader) {
  263. return RealmLoader();
  264. },
  265. client : function(ClientLoader) {
  266. return ClientLoader();
  267. }
  268. },
  269. controller: 'ResourceServerPolicyClientDetailCtrl'
  270. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/client/:id', {
  271. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-client-detail.html',
  272. resolve: {
  273. realm: function (RealmLoader) {
  274. return RealmLoader();
  275. },
  276. client : function(ClientLoader) {
  277. return ClientLoader();
  278. }
  279. },
  280. controller: 'ResourceServerPolicyClientDetailCtrl'
  281. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/role/create', {
  282. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-role-detail.html',
  283. resolve: {
  284. realm: function (RealmLoader) {
  285. return RealmLoader();
  286. },
  287. client : function(ClientLoader) {
  288. return ClientLoader();
  289. }
  290. },
  291. controller: 'ResourceServerPolicyRoleDetailCtrl'
  292. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/role/:id', {
  293. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-role-detail.html',
  294. resolve: {
  295. realm: function (RealmLoader) {
  296. return RealmLoader();
  297. },
  298. client : function(ClientLoader) {
  299. return ClientLoader();
  300. }
  301. },
  302. controller: 'ResourceServerPolicyRoleDetailCtrl'
  303. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/group/create', {
  304. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-group-detail.html',
  305. resolve: {
  306. realm: function (RealmLoader) {
  307. return RealmLoader();
  308. },
  309. client : function(ClientLoader) {
  310. return ClientLoader();
  311. }
  312. },
  313. controller: 'ResourceServerPolicyGroupDetailCtrl'
  314. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/group/:id', {
  315. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-group-detail.html',
  316. resolve: {
  317. realm: function (RealmLoader) {
  318. return RealmLoader();
  319. },
  320. client : function(ClientLoader) {
  321. return ClientLoader();
  322. }
  323. },
  324. controller: 'ResourceServerPolicyGroupDetailCtrl'
  325. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/js/create', {
  326. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-js-detail.html',
  327. resolve: {
  328. realm: function (RealmLoader) {
  329. return RealmLoader();
  330. },
  331. client : function(ClientLoader) {
  332. return ClientLoader();
  333. },
  334. serverInfo : function(ServerInfoLoader) {
  335. return ServerInfoLoader();
  336. }
  337. },
  338. controller: 'ResourceServerPolicyJSDetailCtrl'
  339. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/js/:id', {
  340. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-js-detail.html',
  341. resolve: {
  342. realm: function (RealmLoader) {
  343. return RealmLoader();
  344. },
  345. client : function(ClientLoader) {
  346. return ClientLoader();
  347. },
  348. serverInfo : function(ServerInfoLoader) {
  349. return ServerInfoLoader();
  350. }
  351. },
  352. controller: 'ResourceServerPolicyJSDetailCtrl'
  353. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/time/create', {
  354. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-time-detail.html',
  355. resolve: {
  356. realm: function (RealmLoader) {
  357. return RealmLoader();
  358. },
  359. client : function(ClientLoader) {
  360. return ClientLoader();
  361. }
  362. },
  363. controller: 'ResourceServerPolicyTimeDetailCtrl'
  364. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/time/:id', {
  365. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-time-detail.html',
  366. resolve: {
  367. realm: function (RealmLoader) {
  368. return RealmLoader();
  369. },
  370. client : function(ClientLoader) {
  371. return ClientLoader();
  372. }
  373. },
  374. controller: 'ResourceServerPolicyTimeDetailCtrl'
  375. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/aggregate/create', {
  376. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-aggregate-detail.html',
  377. resolve: {
  378. realm: function (RealmLoader) {
  379. return RealmLoader();
  380. },
  381. client : function(ClientLoader) {
  382. return ClientLoader();
  383. }
  384. },
  385. controller: 'ResourceServerPolicyAggregateDetailCtrl'
  386. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/aggregate/:id', {
  387. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-aggregate-detail.html',
  388. resolve: {
  389. realm: function (RealmLoader) {
  390. return RealmLoader();
  391. },
  392. client : function(ClientLoader) {
  393. return ClientLoader();
  394. }
  395. },
  396. controller: 'ResourceServerPolicyAggregateDetailCtrl'
  397. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/client-scope/create', {
  398. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-client-scope-detail.html',
  399. resolve: {
  400. realm: function (RealmLoader) {
  401. return RealmLoader();
  402. },
  403. client : function(ClientLoader) {
  404. return ClientLoader();
  405. }
  406. },
  407. controller: 'ResourceServerPolicyClientScopeDetailCtrl'
  408. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/client-scope/:id', {
  409. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-client-scope-detail.html',
  410. resolve: {
  411. realm: function (RealmLoader) {
  412. return RealmLoader();
  413. },
  414. client : function(ClientLoader) {
  415. return ClientLoader();
  416. }
  417. },
  418. controller: 'ResourceServerPolicyClientScopeDetailCtrl'
  419. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/regex/create', {
  420. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-regex-detail.html',
  421. resolve: {
  422. realm: function (RealmLoader) {
  423. return RealmLoader();
  424. },
  425. client : function(ClientLoader) {
  426. return ClientLoader();
  427. }
  428. },
  429. controller: 'ResourceServerPolicyRegexDetailCtrl'
  430. }).when('/realms/:realm/clients/:client/authz/resource-server/policy/regex/:id', {
  431. templateUrl: resourceUrl + '/partials/authz/policy/provider/resource-server-policy-regex-detail.html',
  432. resolve: {
  433. realm: function (RealmLoader) {
  434. return RealmLoader();
  435. },
  436. client : function(ClientLoader) {
  437. return ClientLoader();
  438. }
  439. },
  440. controller: 'ResourceServerPolicyRegexDetailCtrl'
  441. }).when('/realms/:realm/roles/:role/permissions', {
  442. templateUrl : resourceUrl + '/partials/authz/mgmt/realm-role-permissions.html',
  443. resolve : {
  444. realm : function(RealmLoader) {
  445. return RealmLoader();
  446. },
  447. role : function(RoleLoader) {
  448. return RoleLoader();
  449. }
  450. },
  451. controller : 'RealmRolePermissionsCtrl'
  452. }).when('/realms/:realm/clients/:client/roles/:role/permissions', {
  453. templateUrl : resourceUrl + '/partials/authz/mgmt/client-role-permissions.html',
  454. resolve : {
  455. realm : function(RealmLoader) {
  456. return RealmLoader();
  457. },
  458. client : function(ClientLoader) {
  459. return ClientLoader();
  460. },
  461. role : function(RoleLoader) {
  462. return RoleLoader();
  463. }
  464. },
  465. controller : 'ClientRolePermissionsCtrl'
  466. }).when('/realms/:realm/users-permissions', {
  467. templateUrl : resourceUrl + '/partials/authz/mgmt/users-permissions.html',
  468. resolve : {
  469. realm : function(RealmLoader) {
  470. return RealmLoader();
  471. }
  472. },
  473. controller : 'UsersPermissionsCtrl'
  474. })
  475. .when('/realms/:realm/clients/:client/permissions', {
  476. templateUrl : resourceUrl + '/partials/authz/mgmt/client-permissions.html',
  477. resolve : {
  478. realm : function(RealmLoader) {
  479. return RealmLoader();
  480. },
  481. client : function(ClientLoader) {
  482. return ClientLoader();
  483. }
  484. },
  485. controller : 'ClientPermissionsCtrl'
  486. })
  487. .when('/realms/:realm/groups/:group/permissions', {
  488. templateUrl : resourceUrl + '/partials/authz/mgmt/group-permissions.html',
  489. resolve : {
  490. realm : function(RealmLoader) {
  491. return RealmLoader();
  492. },
  493. group : function(GroupLoader) {
  494. return GroupLoader();
  495. }
  496. },
  497. controller : 'GroupPermissionsCtrl'
  498. })
  499. .when('/realms/:realm/identity-provider-settings/provider/:provider_id/:alias/permissions', {
  500. templateUrl : function(params){ return resourceUrl + '/partials/authz/mgmt/broker-permissions.html'; },
  501. resolve : {
  502. realm : function(RealmLoader) {
  503. return RealmLoader();
  504. },
  505. identityProvider : function(IdentityProviderLoader) {
  506. return IdentityProviderLoader();
  507. }
  508. },
  509. controller : 'IdentityProviderPermissionCtrl'
  510. })
  511. ;
  512. }]);
  513. module.directive('kcTabsResourceServer', function () {
  514. return {
  515. scope: true,
  516. restrict: 'E',
  517. replace: true,
  518. templateUrl: resourceUrl + '/templates/authz/kc-tabs-resource-server.html'
  519. }
  520. });
  521. module.filter('unique', function () {
  522. return function (items, filterOn) {
  523. if (filterOn === false) {
  524. return items;
  525. }
  526. if ((filterOn || angular.isUndefined(filterOn)) && angular.isArray(items)) {
  527. var hashCheck = {}, newItems = [];
  528. var extractValueToCompare = function (item) {
  529. if (angular.isObject(item) && angular.isString(filterOn)) {
  530. return item[filterOn];
  531. } else {
  532. return item;
  533. }
  534. };
  535. angular.forEach(items, function (item) {
  536. var valueToCheck, isDuplicate = false;
  537. for (var i = 0; i < newItems.length; i++) {
  538. if (angular.equals(extractValueToCompare(newItems[i]), extractValueToCompare(item))) {
  539. isDuplicate = true;
  540. break;
  541. }
  542. }
  543. if (!isDuplicate) {
  544. newItems.push(item);
  545. }
  546. });
  547. items = newItems;
  548. }
  549. return items;
  550. };
  551. });
  552. module.filter('toCamelCase', function () {
  553. return function (input) {
  554. input = input || '';
  555. return input.replace(/\w\S*/g, function (txt) {
  556. return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
  557. });
  558. };
  559. })