authz-services.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. module.factory('ResourceServer', function($resource) {
  2. return $resource(authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server', {
  3. realm : '@realm',
  4. client: '@client'
  5. }, {
  6. 'update' : {method : 'PUT'},
  7. 'import' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/import', method : 'POST'},
  8. 'settings' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/settings', method : 'GET'}
  9. });
  10. });
  11. module.factory('ResourceServerResource', function($resource) {
  12. return $resource(authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/resource/:rsrid', {
  13. realm : '@realm',
  14. client: '@client',
  15. rsrid : '@rsrid'
  16. }, {
  17. 'update' : {method : 'PUT'},
  18. 'search' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/resource/search', method : 'GET'},
  19. 'scopes' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/resource/:rsrid/scopes', method : 'GET', isArray: true},
  20. 'permissions' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/resource/:rsrid/permissions', method : 'GET', isArray: true}
  21. });
  22. });
  23. module.factory('ResourceServerScope', function($resource) {
  24. return $resource(authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/scope/:id', {
  25. realm : '@realm',
  26. client: '@client',
  27. id : '@id'
  28. }, {
  29. 'update' : {method : 'PUT'},
  30. 'search' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/scope/search', method : 'GET'},
  31. 'resources' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/scope/:id/resources', method : 'GET', isArray: true},
  32. 'permissions' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/scope/:id/permissions', method : 'GET', isArray: true},
  33. });
  34. });
  35. module.factory('ResourceServerPolicy', function($resource) {
  36. return $resource(authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/policy/:type/:id', {
  37. realm : '@realm',
  38. client: '@client',
  39. id : '@id',
  40. type: '@type'
  41. }, {
  42. 'update' : {method : 'PUT'},
  43. 'search' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/policy/search', method : 'GET'},
  44. 'associatedPolicies' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/policy/:id/associatedPolicies', method : 'GET', isArray: true},
  45. 'dependentPolicies' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/policy/:id/dependentPolicies', method : 'GET', isArray: true},
  46. 'scopes' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/policy/:id/scopes', method : 'GET', isArray: true},
  47. 'resources' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/policy/:id/resources', method : 'GET', isArray: true}
  48. });
  49. });
  50. module.factory('ResourceServerPermission', function($resource) {
  51. return $resource(authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/permission/:type/:id', {
  52. realm : '@realm',
  53. client: '@client',
  54. type: '@type',
  55. id : '@id'
  56. }, {
  57. 'update' : {method : 'PUT'},
  58. 'search' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/permission/search', method : 'GET'},
  59. 'searchPolicies' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/policy', method : 'GET', isArray: true},
  60. 'associatedPolicies' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/policy/:id/associatedPolicies', method : 'GET', isArray: true},
  61. 'dependentPolicies' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/policy/:id/dependentPolicies', method : 'GET', isArray: true},
  62. 'scopes' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/permission/:id/scopes', method : 'GET', isArray: true},
  63. 'resources' : {url: authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/permission/:id/resources', method : 'GET', isArray: true}
  64. });
  65. });
  66. module.factory('PolicyProvider', function($resource) {
  67. return $resource(authUrl + '/admin/realms/:realm/clients/:client/authz/resource-server/policy/providers', {
  68. realm : '@realm',
  69. client: '@client'
  70. });
  71. });
  72. module.service('AuthzDialog', function($modal) {
  73. var dialog = {};
  74. var openDialog = function(title, message, btns, template) {
  75. var controller = function($scope, $modalInstance, $sce, title, message, btns) {
  76. $scope.title = title;
  77. $scope.message = $sce.trustAsHtml(message);
  78. $scope.btns = btns;
  79. $scope.ok = function () {
  80. $modalInstance.close();
  81. };
  82. $scope.cancel = function () {
  83. $modalInstance.dismiss('cancel');
  84. };
  85. };
  86. return $modal.open({
  87. templateUrl: resourceUrl + template,
  88. controller: controller,
  89. resolve: {
  90. title: function() {
  91. return title;
  92. },
  93. message: function() {
  94. return message;
  95. },
  96. btns: function() {
  97. return btns;
  98. }
  99. }
  100. }).result;
  101. }
  102. dialog.confirmDeleteWithMsg = function(name, type, msg, success) {
  103. var title = 'Delete ' + type;
  104. msg += 'Are you sure you want to permanently delete the ' + type + ' <strong>' + name + '</strong> ?';
  105. var btns = {
  106. ok: {
  107. label: 'Delete',
  108. cssClass: 'btn btn-danger'
  109. },
  110. cancel: {
  111. label: 'Cancel',
  112. cssClass: 'btn btn-default'
  113. }
  114. }
  115. openDialog(title, msg, btns, '/templates/authz/kc-authz-modal.html').then(success);
  116. };
  117. dialog.confirmDelete = function(name, type, success) {
  118. var title = 'Delete ' + type;
  119. var msg = 'Are you sure you want to permanently delete the ' + type + ' <strong>' + name + '</strong> ?';
  120. var btns = {
  121. ok: {
  122. label: 'Delete',
  123. cssClass: 'btn btn-danger'
  124. },
  125. cancel: {
  126. label: 'Cancel',
  127. cssClass: 'btn btn-default'
  128. }
  129. }
  130. openDialog(title, msg, btns, '/templates/authz/kc-authz-modal.html').then(success);
  131. }
  132. return dialog;
  133. });
  134. module.factory('RoleManagementPermissions', function($resource) {
  135. return $resource(authUrl + '/admin/realms/:realm/roles-by-id/:role/management/permissions', {
  136. realm : '@realm',
  137. role : '@role'
  138. }, {
  139. update: {
  140. method: 'PUT'
  141. }
  142. });
  143. });
  144. module.factory('UsersManagementPermissions', function($resource) {
  145. return $resource(authUrl + '/admin/realms/:realm/users-management-permissions', {
  146. realm : '@realm'
  147. }, {
  148. update: {
  149. method: 'PUT'
  150. }
  151. });
  152. });
  153. module.factory('ClientManagementPermissions', function($resource) {
  154. return $resource(authUrl + '/admin/realms/:realm/clients/:client/management/permissions', {
  155. realm : '@realm',
  156. client : '@client'
  157. }, {
  158. update: {
  159. method: 'PUT'
  160. }
  161. });
  162. });
  163. module.factory('IdentityProviderManagementPermissions', function($resource) {
  164. return $resource(authUrl + '/admin/realms/:realm/identity-provider/instances/:alias/management/permissions', {
  165. realm : '@realm',
  166. alias : '@alias'
  167. }, {
  168. update: {
  169. method: 'PUT'
  170. }
  171. });
  172. });
  173. module.factory('GroupManagementPermissions', function($resource) {
  174. return $resource(authUrl + '/admin/realms/:realm/groups/:group/management/permissions', {
  175. realm : '@realm',
  176. group : '@group'
  177. }, {
  178. update: {
  179. method: 'PUT'
  180. }
  181. });
  182. });
  183. module.factory('policyViewState', [function () {
  184. return {
  185. model: {
  186. state: {}
  187. }
  188. };
  189. }]);
  190. module.factory('viewState', [function () {
  191. return {
  192. model: {
  193. state: {}
  194. }
  195. };
  196. }]);