123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256 |
- 'use strict';
- var module = angular.module('keycloak.services', [ 'ngResource', 'ngRoute' ]);
- module.service('Dialog', function($modal, $translate) {
- var dialog = {};
- var openDialog = function(title, message, btns, template) {
- var controller = function($scope, $modalInstance, title, message, btns) {
- $scope.title = title;
- $scope.message = message;
- $scope.btns = btns;
- $scope.ok = function () {
- $modalInstance.close();
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- };
- return $modal.open({
- templateUrl: resourceUrl + template,
- controller: controller,
- resolve: {
- title: function() {
- return title;
- },
- message: function() {
- return message;
- },
- btns: function() {
- return btns;
- }
- }
- }).result;
- }
- var escapeHtml = function(str) {
- var div = document.createElement('div');
- div.appendChild(document.createTextNode(str));
- return div.innerHTML;
- };
- dialog.confirmDelete = function(name, type, success) {
- var title = $translate.instant('dialogs.delete.title', {type: escapeHtml(type.charAt(0).toUpperCase() + type.slice(1))});
- var msg = $translate.instant('dialogs.delete.message', {type: type, name: name});
- var confirm = $translate.instant('dialogs.delete.confirm');
- dialog.confirmWithButtonText(title, msg, confirm, success);
- }
- dialog.confirmGenerateKeys = function(name, type, success) {
- var title = 'Generate new keys for realm';
- var msg = 'Are you sure you want to permanently generate new keys for ' + name + '?';
- var btns = {
- ok: {
- label: 'Generate Keys',
- cssClass: 'btn btn-danger'
- },
- cancel: {
- label: 'Cancel',
- cssClass: 'btn btn-default'
- }
- }
- openDialog(title, msg, btns, '/templates/kc-modal.html').then(success);
- }
- dialog.confirm = function(title, message, success, cancel) {
- dialog.confirmWithButtonText(title, message, title, success, cancel);
- }
- dialog.confirmWithButtonText = function(title, message, confirm, success, cancel) {
- var btns = {
- ok: {
- label: confirm,
- cssClass: 'btn btn-danger'
- },
- cancel: {
- label: $translate.instant('dialogs.cancel'),
- cssClass: 'btn btn-default'
- }
- }
- openDialog(title, message, btns, '/templates/kc-modal.html').then(success, cancel);
- }
- dialog.message = function(title, message, success, cancel) {
- var btns = {
- ok: {
- label: $translate.instant('dialogs.ok'),
- cssClass: 'btn btn-default'
- }
- }
- openDialog(title, message, btns, '/templates/kc-modal-message.html').then(success, cancel);
- }
- dialog.open = function(title, message, btns, success, cancel) {
- openDialog(title, message, btns, '/templates/kc-modal.html').then(success, cancel);
- }
- return dialog
- });
- module.service('CopyDialog', function($modal) {
- var dialog = {};
- dialog.open = function (title, suggested, success) {
- var controller = function($scope, $modalInstance, title) {
- $scope.title = title;
- $scope.name = { value: 'Copy of ' + suggested };
- $scope.ok = function () {
- console.log('ok with name: ' + $scope.name);
- $modalInstance.close();
- success($scope.name.value);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- }
- $modal.open({
- templateUrl: resourceUrl + '/templates/kc-copy.html',
- controller: controller,
- resolve: {
- title: function() {
- return title;
- }
- }
- });
- };
- return dialog;
- });
- module.service('UpdateDialog', function($modal) {
- var dialog = {};
- dialog.open = function (title, name, desc, success) {
- var controller = function($scope, $modalInstance, title) {
- $scope.title = title;
- $scope.name = { value: name };
- $scope.description = { value: desc };
- $scope.ok = function () {
- console.log('ok with name: ' + $scope.name + 'and description: ' + $scope.description);
- $modalInstance.close();
- success($scope.name.value, $scope.description.value);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- }
- $modal.open({
- templateUrl: resourceUrl + '/templates/kc-edit.html',
- controller: controller,
- resolve: {
- title: function() {
- return title;
- }
- }
- });
- };
- return dialog;
- });
- module.factory('Notifications', function($rootScope, $timeout, $translate) {
- // time (in ms) the notifications are shown
- var delay = 5000;
- var notifications = {};
- notifications.current = { display: false };
- notifications.current.remove = function() {
- if (notifications.scheduled) {
- $timeout.cancel(notifications.scheduled);
- delete notifications.scheduled;
- }
- delete notifications.current.type;
- delete notifications.current.header;
- delete notifications.current.message;
- notifications.current.display = false;
- console.debug("Remove message");
- }
- $rootScope.notification = notifications.current;
- notifications.message = function(type, header, message) {
- notifications.current.remove();
- notifications.current.type = type;
- notifications.current.header = header;
- notifications.current.message = message;
- notifications.current.display = true;
- notifications.scheduled = $timeout(function() {
- notifications.current.remove();
- }, delay);
- console.debug("Added message");
- }
- notifications.info = function(message) {
- notifications.message("info", $translate.instant('notifications.info.header'), message);
- };
- notifications.success = function(message) {
- notifications.message("success", $translate.instant('notifications.success.header'), message);
- };
- notifications.error = function(message) {
- notifications.message("danger", $translate.instant('notifications.error.header'), message);
- };
- notifications.warn = function(message) {
- notifications.message("warning", $translate.instant('notifications.warn.header'), message);
- };
- return notifications;
- });
- module.factory('ComponentUtils', function() {
- function sortGroups(prop, arr) {
- // sort current elements
- arr.sort(function (a, b) {
- if (a[prop] < b[prop]) { return -1; }
- if (a[prop] > b[prop]) { return 1; }
- return 0;
- });
- // check sub groups
- arr.forEach(function (item, index) {
- if (!!item.subGroups) {
- sortGroups(prop, item.subGroups);
- }
- });
- return arr;
- };
- var utils = {};
- utils.sortGroups = sortGroups;
- utils.findIndexById = function(array, id) {
- for (var i = 0; i < array.length; i++) {
- if (array[i].id === id) return i;
- }
- return -1;
- }
- utils.convertAllMultivaluedStringValuesToList = function(properties, config) {
- if (!properties) {
- return;
- }
- for (var i=0 ; i<properties.length ; i++) {
- var prop = properties[i];
- if (prop.type === 'MultivaluedString') {
- var configProperty = config[prop.name];
- if (configProperty == null) {
- configProperty = [];
- config[prop.name] = configProperty;
- }
- if (typeof configProperty === "string") {
- configProperty = configProperty.split("##");
- config[prop.name] = configProperty;
- }
- }
- }
- }
- utils.convertAllListValuesToMultivaluedString = function(properties, config) {
- if (!properties) {
- return;
- }
- for (var i=0 ; i<properties.length ; i++) {
- var prop = properties[i];
- if (prop.type === 'MultivaluedString') {
- var configVal = config[prop.name];
- if (configVal != null) {
- if (configVal.length > 0) {
- var lastVal = configVal[configVal.length - 1];
- if (lastVal === '') {
- console.log('Remove empty value from config property: ' + prop.name);
- configVal.splice(configVal.length - 1, 1);
- }
- }
- var attrVals = configVal.join("##");
- config[prop.name] = attrVals;
- }
- }
- }
- }
- utils.addLastEmptyValueToMultivaluedLists = function(properties, config) {
- if (!properties) {
- return;
- }
- for (var i=0 ; i<properties.length ; i++) {
- var prop = properties[i];
- if (prop.type === 'MultivaluedString') {
- var configProperty = config[prop.name];
- if (configProperty == null) {
- configProperty = [];
- config[prop.name] = configProperty;
- }
- if (configProperty.length == 0 || configProperty[configProperty.length - 1].length > 0) {
- configProperty.push('');
- }
- }
- }
- }
- utils.removeLastEmptyValue = function(componentConfig) {
- for (var configPropertyName in componentConfig) {
- var configVal = componentConfig[configPropertyName];
- if (configVal && configVal.length > 0) {
- var lastVal = configVal[configVal.length - 1];
- if (lastVal === '') {
- console.log('Remove empty value from config property: ' + configPropertyName);
- configVal.splice(configVal.length - 1, 1);
- }
- }
- }
- }
- // Allows you to use ui-select2 with <input> tag.
- // In HTML you will then use property.mvOptions like this:
- // <input ui-select2="prop.mvOptions" ng-model="...
- utils.addMvOptionsToMultivaluedLists = function(properties) {
- if (!properties) return;
- for (var i=0 ; i<properties.length ; i++) {
- var prop = properties[i];
- if (prop.type !== 'MultivaluedList') continue;
- prop.mvOptions = {
- 'multiple' : true,
- 'simple_tags' : true,
- 'tags' : angular.copy(prop.options)
- }
- }
- }
- return utils;
- });
- module.factory('Realm', function($resource) {
- return $resource(authUrl + '/admin/realms/:id', {
- id : '@realm'
- }, {
- update : {
- method : 'PUT'
- },
- create : {
- method : 'POST',
- params : { id : ''}
- }
- });
- });
- module.factory('RealmKeys', function($resource) {
- return $resource(authUrl + '/admin/realms/:id/keys', {
- id : '@realm'
- });
- });
- module.factory('RealmSpecificLocales', function($resource) {
- return $resource(authUrl + '/admin/realms/:id/localization', {
- id : '@realm'
- },{'get': {method:'GET', isArray:true}});
- });
- module.factory('RealmSpecificLocalizationTexts', function($resource) {
- return $resource(authUrl + '/admin/realms/:id/localization/:locale', {
- id : '@realm',
- locale : '@locale'
- });
- });
- module.factory('RealmSpecificLocalizationText', function ($resource) {
- return $resource(authUrl + '/admin/realms/:realm/localization/:locale/:key', {
- realm: '@realm',
- locale: '@locale',
- key: '@key'
- }, {
- // wrap plain text response as AngularJS $resource will convert it into a char array otherwise.
- get: {
- method: 'GET',
- transformResponse: function (data) {
- return {content: data};
- }
- },
- save: {
- method: 'PUT',
- headers: {
- 'Content-Type': 'text/plain;charset=utf-8'
- }
- }
- });
- });
- module.factory('RealmEventsConfig', function($resource) {
- return $resource(authUrl + '/admin/realms/:id/events/config', {
- id : '@realm'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('RealmEvents', function($resource) {
- return $resource(authUrl + '/admin/realms/:id/events', {
- id : '@realm'
- });
- });
- module.factory('RealmAdminEvents', function($resource) {
- return $resource(authUrl + '/admin/realms/:id/admin-events', {
- id : '@realm'
- });
- });
- module.factory('BruteForce', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/attack-detection/brute-force/users', {
- realm : '@realm'
- });
- });
- module.factory('BruteForceUser', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/attack-detection/brute-force/users/:userId', {
- realm : '@realm',
- userId : '@userId'
- });
- });
- module.factory('RequiredActions', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/required-actions/:alias', {
- realm : '@realm',
- alias : '@alias'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('RequiredActionRaisePriority', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/required-actions/:alias/raise-priority', {
- realm : '@realm',
- alias : '@alias'
- });
- });
- module.factory('RequiredActionLowerPriority', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/required-actions/:alias/lower-priority', {
- realm : '@realm',
- alias : '@alias'
- });
- });
- module.factory('UnregisteredRequiredActions', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/unregistered-required-actions', {
- realm : '@realm'
- });
- });
- module.factory('RegisterRequiredAction', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/register-required-action', {
- realm : '@realm'
- });
- });
- module.factory('RealmLDAPConnectionTester', function($resource, $httpParamSerializer) {
- return $resource(authUrl + '/admin/realms/:realm/testLDAPConnection', {
- realm : '@realm'
- });
- });
- module.factory('RealmSMTPConnectionTester', function($resource, $httpParamSerializer) {
- return $resource(authUrl + '/admin/realms/:realm/testSMTPConnection', {
- realm : '@realm'
- });
- });
- module.service('ServerInfo', function($resource, $q, $http) {
- var info = {};
- var delay = $q.defer();
- function copyInfo(data, info) {
- angular.copy(data, info);
- info.listProviderIds = function(spi) {
- var providers = info.providers[spi].providers;
- var ids = Object.keys(providers);
- ids.sort(function(a, b) {
- var s1;
- var s2;
- if (providers[a].order != providers[b].order) {
- s1 = providers[b].order;
- s2 = providers[a].order;
- } else {
- s1 = a;
- s2 = b;
- }
- if (s1 < s2) {
- return -1;
- } else if (s1 > s2) {
- return 1;
- } else {
- return 0;
- }
- });
- return ids;
- }
- info.featureEnabled = function(provider) {
- return info.profileInfo.disabledFeatures.indexOf(provider) == -1;
- }
- }
- $http.get(authUrl + '/admin/serverinfo').then(function(response) {
- copyInfo(response.data, info);
- delay.resolve(info);
- });
- return {
- get: function() {
- return info;
- },
- reload: function() {
- $http.get(authUrl + '/admin/serverinfo').then(function(response) {
- copyInfo(response.data, info);
- });
- },
- promise: delay.promise
- }
- });
- module.factory('ClientInitialAccess', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients-initial-access/:id', {
- realm : '@realm',
- id : '@id'
- });
- });
- module.factory('ClientProtocolMapper', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/protocol-mappers/models/:id', {
- realm : '@realm',
- client: '@client',
- id : "@id"
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('ClientScopeProtocolMapper', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-scopes/:clientScope/protocol-mappers/models/:id', {
- realm : '@realm',
- clientScope: '@clientScope',
- id : "@id"
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('User', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:userId', {
- realm : '@realm',
- userId : '@userId'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.service('UserSearchState', function() {
- this.isFirstSearch = true;
- this.query = {
- max : 20,
- first : 0
- };
- });
- module.service('ClientListSearchState', function() {
- this.isFirstSearch = true;
- this.query = {
- max : 20,
- first : 0,
- search: true
- };
- });
- // Service tracks the last flow selected in Authentication-->Flows tab
- module.service('LastFlowSelected', function() {
- this.alias = null;
- });
- module.service('RealmRoleRemover', function() {
- this.remove = function (role, realm, Dialog, $location, Notifications) {
- Dialog.confirmDelete(role.name, 'role', function () {
- role.$remove({
- realm: realm.realm,
- role: role.id
- }, function () {
- $location.url("/realms/" + realm.realm + "/roles");
- Notifications.success("The role has been deleted.");
- });
- });
- };
- });
- module.factory('UserSessionStats', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:user/session-stats', {
- realm : '@realm',
- user : '@user'
- });
- });
- module.factory('UserSessions', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:user/sessions', {
- realm : '@realm',
- user : '@user'
- });
- });
- module.factory('UserOfflineSessions', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:user/offline-sessions/:client', {
- realm : '@realm',
- user : '@user',
- client : '@client'
- });
- });
- module.factory('UserSessionLogout', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/sessions/:session', {
- realm : '@realm',
- session : '@session'
- });
- });
- module.factory('UserLogout', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:user/logout', {
- realm : '@realm',
- user : '@user'
- });
- });
- module.factory('UserFederatedIdentities', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:user/federated-identity', {
- realm : '@realm',
- user : '@user'
- });
- });
- module.factory('UserFederatedIdentity', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:user/federated-identity/:provider', {
- realm : '@realm',
- user : '@user',
- provider : '@provider'
- });
- });
- module.factory('UserConsents', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:user/consents/:client', {
- realm : '@realm',
- user : '@user',
- client: '@client'
- });
- });
- module.factory('UserImpersonation', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:user/impersonation', {
- realm : '@realm',
- user : '@user'
- });
- });
- module.factory('UserCredentials', function($resource) {
- var credentials = {};
- credentials.getCredentials = $resource(authUrl + '/admin/realms/:realm/users/:userId/credentials', {
- realm : '@realm',
- userId : '@userId'
- }).query;
- credentials.getConfiguredUserStorageCredentialTypes = $resource(authUrl + '/admin/realms/:realm/users/:userId/configured-user-storage-credential-types', {
- realm : '@realm',
- userId : '@userId'
- }).query;
- credentials.deleteCredential = $resource(authUrl + '/admin/realms/:realm/users/:userId/credentials/:credentialId', {
- realm : '@realm',
- userId : '@userId',
- credentialId : '@credentialId'
- }).delete;
- credentials.updateCredentialLabel = $resource(authUrl + '/admin/realms/:realm/users/:userId/credentials/:credentialId/userLabel', {
- realm : '@realm',
- userId : '@userId',
- credentialId : '@credentialId'
- }, {
- update : {
- method : 'PUT',
- headers: {
- 'Content-Type': 'text/plain;charset=utf-8'
- },
- transformRequest: function(credential, getHeaders) {
- return credential.userLabel;
- }
- }
- }).update;
- credentials.resetPassword = $resource(authUrl + '/admin/realms/:realm/users/:userId/reset-password', {
- realm : '@realm',
- userId : '@userId'
- }, {
- update : {
- method : 'PUT'
- }
- }).update;
- credentials.removeTotp = $resource(authUrl + '/admin/realms/:realm/users/:userId/remove-totp', {
- realm : '@realm',
- userId : '@userId'
- }, {
- update : {
- method : 'PUT'
- }
- }).update;
- credentials.disableCredentialTypes = $resource(authUrl + '/admin/realms/:realm/users/:userId/disable-credential-types', {
- realm : '@realm',
- userId : '@userId'
- }, {
- update : {
- method : 'PUT'
- }
- }).update;
- credentials.moveCredentialAfter = $resource(authUrl + '/admin/realms/:realm/users/:userId/credentials/:credentialId/moveAfter/:newPreviousCredentialId', {
- realm : '@realm',
- userId : '@userId',
- credentialId : '@credentialId',
- newPreviousCredentialId : '@newPreviousCredentialId'
- }, {
- update : {
- method : 'POST'
- }
- }).update;
- credentials.moveToFirst = $resource(authUrl + '/admin/realms/:realm/users/:userId/credentials/:credentialId/moveToFirst', {
- realm : '@realm',
- userId : '@userId',
- credentialId : '@credentialId'
- }, {
- update : {
- method : 'POST'
- }
- }).update;
- return credentials;
- });
- module.factory('UserExecuteActionsEmail', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:userId/execute-actions-email', {
- realm : '@realm',
- userId : '@userId',
- lifespan : '@lifespan',
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('RealmRoleMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:userId/role-mappings/realm', {
- realm : '@realm',
- userId : '@userId'
- });
- });
- module.factory('CompositeRealmRoleMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:userId/role-mappings/realm/composite', {
- realm : '@realm',
- userId : '@userId'
- });
- });
- module.factory('AvailableRealmRoleMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:userId/role-mappings/realm/available', {
- realm : '@realm',
- userId : '@userId'
- });
- });
- module.factory('ClientRoleMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:userId/role-mappings/clients/:client', {
- realm : '@realm',
- userId : '@userId',
- client : "@client"
- });
- });
- module.factory('AvailableClientRoleMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:userId/role-mappings/clients/:client/available', {
- realm : '@realm',
- userId : '@userId',
- client : "@client"
- });
- });
- module.factory('CompositeClientRoleMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:userId/role-mappings/clients/:client/composite', {
- realm : '@realm',
- userId : '@userId',
- client : "@client"
- });
- });
- module.factory('ClientRealmScopeMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/scope-mappings/realm', {
- realm : '@realm',
- client : '@client'
- });
- });
- module.factory('ClientAvailableRealmScopeMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/scope-mappings/realm/available', {
- realm : '@realm',
- client : '@client'
- });
- });
- module.factory('ClientCompositeRealmScopeMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/scope-mappings/realm/composite', {
- realm : '@realm',
- client : '@client'
- });
- });
- module.factory('ClientClientScopeMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/scope-mappings/clients/:targetClient', {
- realm : '@realm',
- client : '@client',
- targetClient : '@targetClient'
- });
- });
- module.factory('ClientAvailableClientScopeMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/scope-mappings/clients/:targetClient/available', {
- realm : '@realm',
- client : '@client',
- targetClient : '@targetClient'
- });
- });
- module.factory('ClientCompositeClientScopeMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/scope-mappings/clients/:targetClient/composite', {
- realm : '@realm',
- client : '@client',
- targetClient : '@targetClient'
- });
- });
- module.factory('RealmRoles', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/roles', {
- realm : '@realm'
- });
- });
- module.factory('RoleRealmComposites', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/roles-by-id/:role/composites/realm', {
- realm : '@realm',
- role : '@role'
- });
- });
- module.factory('RealmPushRevocation', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/push-revocation', {
- realm : '@realm'
- });
- });
- module.factory('RealmClearUserCache', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clear-user-cache', {
- realm : '@realm'
- });
- });
- module.factory('RealmClearRealmCache', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clear-realm-cache', {
- realm : '@realm'
- });
- });
- module.factory('RealmClearKeysCache', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clear-keys-cache', {
- realm : '@realm'
- });
- });
- module.factory('RealmSessionStats', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/session-stats', {
- realm : '@realm'
- });
- });
- module.factory('RealmClientSessionStats', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-session-stats', {
- realm : '@realm'
- });
- });
- module.factory('RoleClientComposites', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/roles-by-id/:role/composites/clients/:client', {
- realm : '@realm',
- role : '@role',
- client : "@client"
- });
- });
- function clientSelectControl($scope, realm, Client) {
- $scope.clientsUiSelect = {
- minimumInputLength: 0,
- delay: 500,
- allowClear: true,
- query: function (query) {
- var data = {results: []};
- Client.query({realm: realm, search: true, clientId: query.term.trim(), max: 20}, function(response) {
- data.results = response;
- query.callback(data);
- });
- },
- formatResult: function(object, container, query) {
- object.text = object.clientId;
- return object.clientId;
- }
- };
- }
- function roleControl($scope, $route, realm, role, roles, Client,
- ClientRole, RoleById, RoleRealmComposites, RoleClientComposites,
- $http, $location, Notifications, Dialog, ComponentUtils) {
- $scope.$watch(function () {
- return $location.path();
- }, function () {
- $scope.path = $location.path().substring(1).split("/");
- });
- $scope.$watch('role', function () {
- if (!angular.equals($scope.role, role)) {
- $scope.changed = true;
- }
- }, true);
- $scope.update = function () {
- RoleById.update({
- realm: realm.realm,
- role: role.id
- }, $scope.role, function () {
- $scope.changed = false;
- role = angular.copy($scope.role);
- Notifications.success("Your changes have been saved to the role.");
- });
- };
- $scope.reset = function () {
- $scope.role = angular.copy(role);
- $scope.changed = false;
- };
- if (!role.id) return;
- $scope.compositeSwitch = role.composite;
- $scope.compositeSwitchDisabled = role.composite;
- $scope.realmRoles = angular.copy(roles);
- $scope.selectedRealmRoles = [];
- $scope.selectedRealmMappings = [];
- $scope.realmMappings = [];
- $scope.clientRoles = [];
- $scope.selectedClientRoles = [];
- $scope.selectedClientMappings = [];
- $scope.clientMappings = [];
- for (var j = 0; j < $scope.realmRoles.length; j++) {
- if ($scope.realmRoles[j].id == role.id) {
- var realmRole = $scope.realmRoles[j];
- var idx = $scope.realmRoles.indexOf(realmRole);
- $scope.realmRoles.splice(idx, 1);
- break;
- }
- }
- clientSelectControl($scope, $route.current.params.realm, Client);
-
- $scope.selectedClient = null;
- $scope.realmMappings = RoleRealmComposites.query({realm : realm.realm, role : role.id}, function(){
- for (var i = 0; i < $scope.realmMappings.length; i++) {
- var role = $scope.realmMappings[i];
- for (var j = 0; j < $scope.realmRoles.length; j++) {
- var realmRole = $scope.realmRoles[j];
- if (realmRole.id == role.id) {
- var idx = $scope.realmRoles.indexOf(realmRole);
- if (idx != -1) {
- $scope.realmRoles.splice(idx, 1);
- break;
- }
- }
- }
- }
- });
- $scope.addRealmRole = function() {
- $scope.compositeSwitchDisabled=true;
- $scope.selectedRealmRolesToAdd = JSON.parse('[' + $scope.selectedRealmRoles + ']');
- $http.post(authUrl + '/admin/realms/' + realm.realm + '/roles-by-id/' + role.id + '/composites',
- $scope.selectedRealmRolesToAdd).then(function() {
- for (var i = 0; i < $scope.selectedRealmRolesToAdd.length; i++) {
- var role = $scope.selectedRealmRolesToAdd[i];
- var idx = ComponentUtils.findIndexById($scope.realmRoles, role.id);
- if (idx != -1) {
- $scope.realmRoles.splice(idx, 1);
- $scope.realmMappings.push(role);
- }
- }
- $scope.selectedRealmRoles = [];
- $scope.selectedRealmRolesToAdd = [];
- Notifications.success("Role added to composite.");
- });
- };
- $scope.deleteRealmRole = function() {
- $scope.compositeSwitchDisabled=true;
- $scope.selectedRealmMappingsToRemove = JSON.parse('[' + $scope.selectedRealmMappings + ']');
- $http.delete(authUrl + '/admin/realms/' + realm.realm + '/roles-by-id/' + role.id + '/composites',
- {data : $scope.selectedRealmMappingsToRemove, headers : {"content-type" : "application/json"}}).then(function() {
- for (var i = 0; i < $scope.selectedRealmMappingsToRemove.length; i++) {
- var role = $scope.selectedRealmMappingsToRemove[i];
- var idx = ComponentUtils.findIndexById($scope.realmMappings, role.id);
- if (idx != -1) {
- $scope.realmMappings.splice(idx, 1);
- $scope.realmRoles.push(role);
- }
- }
- $scope.selectedRealmMappings = [];
- $scope.selectedRealmMappingsToRemove = [];
- Notifications.success("Role removed from composite.");
- });
- };
- $scope.addClientRole = function() {
- $scope.compositeSwitchDisabled=true;
- $scope.selectedClientRolesToAdd = JSON.parse('[' + $scope.selectedClientRoles + ']');
- $http.post(authUrl + '/admin/realms/' + realm.realm + '/roles-by-id/' + role.id + '/composites',
- $scope.selectedClientRolesToAdd).then(function() {
- for (var i = 0; i < $scope.selectedClientRolesToAdd.length; i++) {
- var role = $scope.selectedClientRolesToAdd[i];
- var idx = ComponentUtils.findIndexById($scope.clientRoles, role.id);
- if (idx != -1) {
- $scope.clientRoles.splice(idx, 1);
- $scope.clientMappings.push(role);
- }
- }
- $scope.selectedClientRoles = [];
- $scope.selectedClientRolesToAdd = [];
- Notifications.success("Client role added.");
- });
- };
- $scope.deleteClientRole = function() {
- $scope.compositeSwitchDisabled=true;
- $scope.selectedClientMappingsToRemove = JSON.parse('[' + $scope.selectedClientMappings + ']');
- $http.delete(authUrl + '/admin/realms/' + realm.realm + '/roles-by-id/' + role.id + '/composites',
- {data : $scope.selectedClientMappingsToRemove, headers : {"content-type" : "application/json"}}).then(function() {
- for (var i = 0; i < $scope.selectedClientMappingsToRemove.length; i++) {
- var role = $scope.selectedClientMappingsToRemove[i];
- var idx = ComponentUtils.findIndexById($scope.clientMappings, role.id);
- if (idx != -1) {
- $scope.clientMappings.splice(idx, 1);
- $scope.clientRoles.push(role);
- }
- }
- $scope.selectedClientMappings = [];
- $scope.selectedClientMappingsToRemove = [];
- Notifications.success("Client role removed.");
- });
- };
- $scope.changeClient = function(client) {
- console.log("selected client: ", client);
- if (!client || !client.id) {
- $scope.selectedClient = null;
- return;
- }
- $scope.selectedClient = client;
- $scope.clientRoles = ClientRole.query({realm : realm.realm, client : client.id}, function() {
- $scope.clientMappings = RoleClientComposites.query({realm : realm.realm, role : role.id, client : client.id}, function(){
- for (var i = 0; i < $scope.clientMappings.length; i++) {
- var role = $scope.clientMappings[i];
- for (var j = 0; j < $scope.clientRoles.length; j++) {
- var realmRole = $scope.clientRoles[j];
- if (realmRole.id == role.id) {
- var idx = $scope.clientRoles.indexOf(realmRole);
- if (idx != -1) {
- $scope.clientRoles.splice(idx, 1);
- break;
- }
- }
- }
- }
- });
- for (var j = 0; j < $scope.clientRoles.length; j++) {
- if ($scope.clientRoles[j] == role.id) {
- var appRole = $scope.clientRoles[j];
- var idx = $scope.clientRoles.indexof(appRole);
- $scope.clientRoles.splice(idx, 1);
- break;
- }
- }
- }
- );
- };
- }
- module.factory('Role', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/roles/:role', {
- realm : '@realm',
- role : '@role'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('RoleById', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/roles-by-id/:role', {
- realm : '@realm',
- role : '@role'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('ClientRole', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/roles/:role', {
- realm : '@realm',
- client : "@client",
- role : '@role'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('ClientDefaultClientScopes', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/default-client-scopes/:clientScopeId', {
- realm : '@realm',
- client : "@client",
- clientScopeId : '@clientScopeId'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('ClientOptionalClientScopes', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/optional-client-scopes/:clientScopeId', {
- realm : '@realm',
- client : "@client",
- clientScopeId : '@clientScopeId'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('ClientEvaluateProtocolMappers', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/evaluate-scopes/protocol-mappers?scope=:scopeParam', {
- realm : '@realm',
- client : "@client",
- scopeParam : "@scopeParam"
- });
- });
- module.factory('ClientEvaluateGrantedRoles', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/evaluate-scopes/scope-mappings/:roleContainer/granted?scope=:scopeParam', {
- realm : '@realm',
- client : "@client",
- roleContainer : "@roleContainer",
- scopeParam : "@scopeParam"
- });
- });
- module.factory('ClientEvaluateNotGrantedRoles', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/evaluate-scopes/scope-mappings/:roleContainer/not-granted?scope=:scopeParam', {
- realm : '@realm',
- client : "@client",
- roleContainer : "@roleContainer",
- scopeParam : "@scopeParam"
- });
- });
- module.factory('ClientEvaluateGenerateExampleAccessToken', function($resource) {
- return buildClientEvaluateGenerateExampleUrl('generate-example-access-token');
- });
- module.factory('ClientEvaluateGenerateExampleIDToken', function($resource) {
- return buildClientEvaluateGenerateExampleUrl('generate-example-id-token');
- });
- module.factory('ClientEvaluateGenerateExampleUserInfo', function($resource) {
- return buildClientEvaluateGenerateExampleUrl('generate-example-userinfo');
- });
- function buildClientEvaluateGenerateExampleUrl(subPath) {
- var urlTemplate = authUrl + '/admin/realms/:realm/clients/:client/evaluate-scopes/' + subPath + '?scope=:scopeParam&userId=:userId';
- return {
- url: function (parameters) {
- return urlTemplate
- .replace(':realm', parameters.realm)
- .replace(':client', parameters.client)
- .replace(':scopeParam', parameters.scopeParam)
- .replace(':userId', parameters.userId);
- }
- }
- }
- module.factory('ClientProtocolMappersByProtocol', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/protocol-mappers/protocol/:protocol', {
- realm : '@realm',
- client : "@client",
- protocol : "@protocol"
- });
- });
- module.factory('ClientScopeProtocolMappersByProtocol', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-scopes/:clientScope/protocol-mappers/protocol/:protocol', {
- realm : '@realm',
- clientScope : "@clientScope",
- protocol : "@protocol"
- });
- });
- module.factory('ClientScopeRealmScopeMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-scopes/:clientScope/scope-mappings/realm', {
- realm : '@realm',
- clientScope : '@clientScope'
- });
- });
- module.factory('ClientScopeAvailableRealmScopeMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-scopes/:clientScope/scope-mappings/realm/available', {
- realm : '@realm',
- clientScope : '@clientScope'
- });
- });
- module.factory('ClientScopeCompositeRealmScopeMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-scopes/:clientScope/scope-mappings/realm/composite', {
- realm : '@realm',
- clientScope : '@clientScope'
- });
- });
- module.factory('ClientScopeClientScopeMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-scopes/:clientScope/scope-mappings/clients/:targetClient', {
- realm : '@realm',
- clientScope : '@clientScope',
- targetClient : '@targetClient'
- });
- });
- module.factory('ClientScopeAvailableClientScopeMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-scopes/:clientScope/scope-mappings/clients/:targetClient/available', {
- realm : '@realm',
- clientScope : '@clientScope',
- targetClient : '@targetClient'
- });
- });
- module.factory('ClientScopeCompositeClientScopeMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-scopes/:clientScope/scope-mappings/clients/:targetClient/composite', {
- realm : '@realm',
- clientScope : '@clientScope',
- targetClient : '@targetClient'
- });
- });
- module.factory('ClientSessionStats', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/session-stats', {
- realm : '@realm',
- client : "@client"
- });
- });
- module.factory('ClientSessionStatsWithUsers', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/session-stats?users=true', {
- realm : '@realm',
- client : "@client"
- });
- });
- module.factory('ClientSessionCount', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/session-count', {
- realm : '@realm',
- client : "@client"
- });
- });
- module.factory('ClientUserSessions', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/user-sessions', {
- realm : '@realm',
- client : "@client"
- });
- });
- module.factory('ClientOfflineSessionCount', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/offline-session-count', {
- realm : '@realm',
- client : "@client"
- });
- });
- module.factory('ClientOfflineSessions', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/offline-sessions', {
- realm : '@realm',
- client : "@client"
- });
- });
- module.factory('RealmLogoutAll', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/logout-all', {
- realm : '@realm'
- });
- });
- module.factory('ClientPushRevocation', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/push-revocation', {
- realm : '@realm',
- client : "@client"
- });
- });
- module.factory('ClientClusterNode', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/nodes/:node', {
- realm : '@realm',
- client : "@client"
- });
- });
- module.factory('ClientTestNodesAvailable', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/test-nodes-available', {
- realm : '@realm',
- client : "@client"
- });
- });
- module.factory('ClientCertificate', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/certificates/:attribute', {
- realm : '@realm',
- client : "@client",
- attribute: "@attribute"
- });
- });
- module.factory('ClientCertificateGenerate', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/certificates/:attribute/generate', {
- realm : '@realm',
- client : "@client",
- attribute: "@attribute"
- },
- {
- generate : {
- method : 'POST'
- }
- });
- });
- module.factory('ClientCertificateDownload', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/certificates/:attribute/download', {
- realm : '@realm',
- client : "@client",
- attribute: "@attribute"
- },
- {
- download : {
- method : 'POST',
- responseType: 'arraybuffer'
- }
- });
- });
- module.factory('Client', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client', {
- realm : '@realm',
- client : '@client'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('ClientScope', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-scopes/:clientScope', {
- realm : '@realm',
- clientScope : '@clientScope'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('RealmDefaultClientScopes', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/default-default-client-scopes/:clientScopeId', {
- realm : '@realm',
- clientScopeId : '@clientScopeId'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('RealmOptionalClientScopes', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/default-optional-client-scopes/:clientScopeId', {
- realm : '@realm',
- clientScopeId : '@clientScopeId'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('ClientDescriptionConverter', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-description-converter', {
- realm : '@realm'
- });
- });
- /*
- module.factory('ClientInstallation', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/installation/providers/:provider', {
- realm : '@realm',
- client : '@client',
- provider : '@provider'
- });
- });
- */
- module.factory('ClientInstallation', function($resource) {
- var url = authUrl + '/admin/realms/:realm/clients/:client/installation/providers/:provider';
- return {
- url : function(parameters)
- {
- return url.replace(':realm', parameters.realm).replace(':client', parameters.client).replace(':provider', parameters.provider);
- }
- }
- });
- module.factory('ClientInstallationJBoss', function($resource) {
- var url = authUrl + '/admin/realms/:realm/clients/:client/installation/jboss';
- return {
- url : function(parameters)
- {
- return url.replace(':realm', parameters.realm).replace(':client', parameters.client);
- }
- }
- });
- module.factory('ClientSecret', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/client-secret', {
- realm : '@realm',
- client : '@client'
- }, {
- update : {
- method : 'POST'
- }
- });
- });
- module.factory('ClientRegistrationAccessToken', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/registration-access-token', {
- realm : '@realm',
- client : '@client'
- }, {
- update : {
- method : 'POST'
- }
- });
- });
- module.factory('ClientOrigins', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/allowed-origins', {
- realm : '@realm',
- client : '@client'
- }, {
- update : {
- method : 'PUT',
- isArray : true
- }
- });
- });
- module.factory('ClientServiceAccountUser', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/service-account-user', {
- realm : '@realm',
- client : '@client'
- });
- });
- module.factory('Current', function(Realm, $route, $rootScope) {
- var current = {
- realms: {},
- realm: null
- };
- $rootScope.$on('$routeChangeStart', function() {
- current.realms = Realm.query({briefRepresentation: true}, function(realms) {
- var currentRealm = null;
- if ($route.current.params.realm) {
- for (var i = 0; i < realms.length; i++) {
- if (realms[i].realm == $route.current.params.realm) {
- currentRealm = realms[i];
- }
- }
- }
- current.realm = currentRealm;
- });
- });
- return current;
- });
- module.factory('TimeUnit', function() {
- var t = {};
- t.autoUnit = function(time) {
- if (!time) {
- return 'Hours';
- }
- var unit = 'Seconds';
- if (time % 60 == 0) {
- unit = 'Minutes';
- time = time / 60;
- }
- if (time % 60 == 0) {
- unit = 'Hours';
- time = time / 60;
- }
- if (time % 24 == 0) {
- unit = 'Days'
- time = time / 24;
- }
- return unit;
- }
- t.toSeconds = function(time, unit) {
- switch (unit) {
- case 'Seconds': return time;
- case 'Minutes': return time * 60;
- case 'Hours': return time * 3600;
- case 'Days': return time * 86400;
- default: throw 'invalid unit ' + unit;
- }
- }
- t.toUnit = function(time, unit) {
- switch (unit) {
- case 'Seconds': return time;
- case 'Minutes': return Math.ceil(time / 60);
- case 'Hours': return Math.ceil(time / 3600);
- case 'Days': return Math.ceil(time / 86400);
- default: throw 'invalid unit ' + unit;
- }
- }
- return t;
- });
- module.factory('TimeUnit2', function() {
- var t = {};
- t.asUnit = function(time) {
- var unit = 'Minutes';
- if (time) {
- if (time == -1) {
- time = -1;
- } else {
- if (time < 60) {
- time = 60;
- }
- if (time % 60 == 0) {
- unit = 'Minutes';
- time = time / 60;
- }
- if (time % 60 == 0) {
- unit = 'Hours';
- time = time / 60;
- }
- if (time % 24 == 0) {
- unit = 'Days'
- time = time / 24;
- }
- }
- }
- var v = {
- unit: unit,
- time: time,
- toSeconds: function() {
- switch (v.unit) {
- case 'Minutes':
- return v.time * 60;
- case 'Hours':
- return v.time * 3600;
- case 'Days':
- return v.time * 86400;
- }
- }
- }
- return v;
- }
- return t;
- });
- module.filter('removeSelectedPolicies', function() {
- return function(policies, selectedPolicies) {
- var result = [];
- for(var i in policies) {
- var policy = policies[i];
- var policyAvailable = true;
- for(var j in selectedPolicies) {
- if(policy.id === selectedPolicies[j].id && !policy.multipleSupported) {
- policyAvailable = false;
- }
- }
- if(policyAvailable) {
- result.push(policy);
- }
- }
- return result;
- }
- });
- module.factory('IdentityProvider', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/identity-provider/instances/:alias', {
- realm : '@realm',
- alias : '@alias'
- }, {
- update: {
- method : 'PUT'
- }
- });
- });
- module.factory('IdentityProviderExport', function($resource) {
- var url = authUrl + '/admin/realms/:realm/identity-provider/instances/:alias/export';
- return {
- url : function(parameters)
- {
- return url.replace(':realm', parameters.realm).replace(':alias', parameters.alias);
- }
- }
- });
- module.factory('IdentityProviderFactory', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/identity-provider/providers/:provider_id', {
- realm : '@realm',
- provider_id : '@provider_id'
- });
- });
- module.factory('IdentityProviderMapperTypes', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/identity-provider/instances/:alias/mapper-types', {
- realm : '@realm',
- alias : '@alias'
- });
- });
- module.factory('IdentityProviderMappers', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/identity-provider/instances/:alias/mappers', {
- realm : '@realm',
- alias : '@alias'
- });
- });
- module.factory('IdentityProviderMapper', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/identity-provider/instances/:alias/mappers/:mapperId', {
- realm : '@realm',
- alias : '@alias',
- mapperId: '@mapperId'
- }, {
- update: {
- method : 'PUT'
- }
- });
- });
- module.factory('AuthenticationFlowExecutions', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/flows/:alias/executions', {
- realm : '@realm',
- alias : '@alias'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('CreateExecutionFlow', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/flows/:alias/executions/flow', {
- realm : '@realm',
- alias : '@alias'
- });
- });
- module.factory('CreateExecution', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/flows/:alias/executions/execution', {
- realm : '@realm',
- alias : '@alias'
- });
- });
- module.factory('AuthenticationFlows', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/flows/:flow', {
- realm : '@realm',
- flow: '@flow'
- });
- });
- module.factory('AuthenticationFormProviders', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/form-providers', {
- realm : '@realm'
- });
- });
- module.factory('AuthenticationFormActionProviders', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/form-action-providers', {
- realm : '@realm'
- });
- });
- module.factory('AuthenticatorProviders', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/authenticator-providers', {
- realm : '@realm'
- });
- });
- module.factory('ClientAuthenticatorProviders', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/client-authenticator-providers', {
- realm : '@realm'
- });
- });
- module.factory('AuthenticationFlowsCopy', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/flows/:alias/copy', {
- realm : '@realm',
- alias : '@alias'
- });
- });
- module.factory('AuthenticationFlowsUpdate', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/flows/:flow', {
- realm : '@realm',
- flow : '@flow'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('AuthenticationConfigDescription', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/config-description/:provider', {
- realm : '@realm',
- provider: '@provider'
- });
- });
- module.factory('PerClientAuthenticationConfigDescription', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/per-client-config-description', {
- realm : '@realm'
- });
- });
- module.factory('AuthenticationConfig', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/config/:config', {
- realm : '@realm',
- config: '@config'
- }, {
- update: {
- method : 'PUT'
- }
- });
- });
- module.factory('AuthenticationExecutionConfig', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/executions/:execution/config', {
- realm : '@realm',
- execution: '@execution'
- });
- });
- module.factory('AuthenticationExecution', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/executions/:execution', {
- realm : '@realm',
- execution : '@execution'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('AuthenticationExecutionRaisePriority', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/executions/:execution/raise-priority', {
- realm : '@realm',
- execution : '@execution'
- });
- });
- module.factory('AuthenticationExecutionLowerPriority', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/authentication/executions/:execution/lower-priority', {
- realm : '@realm',
- execution : '@execution'
- });
- });
- module.service('SelectRoleDialog', function($modal) {
- var dialog = {};
- var openDialog = function(title, message, btns) {
- var controller = function($scope, $modalInstance, title, message, btns) {
- $scope.title = title;
- $scope.message = message;
- $scope.btns = btns;
- $scope.ok = function () {
- $modalInstance.close();
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- };
- return $modal.open({
- templateUrl: resourceUrl + '/templates/kc-modal.html',
- controller: controller,
- resolve: {
- title: function() {
- return title;
- },
- message: function() {
- return message;
- },
- btns: function() {
- return btns;
- }
- }
- }).result;
- }
- var escapeHtml = function(str) {
- var div = document.createElement('div');
- div.appendChild(document.createTextNode(str));
- return div.innerHTML;
- };
- dialog.confirmDelete = function(name, type, success) {
- var title = 'Delete ' + escapeHtml(type.charAt(0).toUpperCase() + type.slice(1));
- var msg = 'Are you sure you want to permanently delete the ' + type + ' ' + name + '?';
- var btns = {
- ok: {
- label: 'Delete',
- cssClass: 'btn btn-danger'
- },
- cancel: {
- label: 'Cancel',
- cssClass: 'btn btn-default'
- }
- }
- openDialog(title, msg, btns).then(success);
- }
- dialog.confirmGenerateKeys = function(name, type, success) {
- var title = 'Generate new keys for realm';
- var msg = 'Are you sure you want to permanently generate new keys for ' + name + '?';
- var btns = {
- ok: {
- label: 'Generate Keys',
- cssClass: 'btn btn-danger'
- },
- cancel: {
- label: 'Cancel',
- cssClass: 'btn btn-default'
- }
- }
- openDialog(title, msg, btns).then(success);
- }
- dialog.confirm = function(title, message, success, cancel) {
- var btns = {
- ok: {
- label: title,
- cssClass: 'btn btn-danger'
- },
- cancel: {
- label: 'Cancel',
- cssClass: 'btn btn-default'
- }
- }
- openDialog(title, message, btns).then(success, cancel);
- }
- return dialog
- });
- module.factory('Group', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/groups/:groupId', {
- realm : '@realm',
- userId : '@groupId'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('GroupChildren', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/groups/:groupId/children', {
- realm : '@realm',
- groupId : '@groupId'
- });
- });
- module.factory('GroupsCount', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/groups/count', {
- realm : '@realm'
- },
- {
- query: {
- isArray: false,
- method: 'GET',
- params: {},
- transformResponse: function (data) {
- return angular.fromJson(data)
- }
- }
- });
- });
- module.factory('Groups', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/groups', {
- realm : '@realm'
- })
- });
- module.factory('GroupRealmRoleMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/groups/:groupId/role-mappings/realm', {
- realm : '@realm',
- groupId : '@groupId'
- });
- });
- module.factory('GroupCompositeRealmRoleMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/groups/:groupId/role-mappings/realm/composite', {
- realm : '@realm',
- groupId : '@groupId'
- });
- });
- module.factory('GroupAvailableRealmRoleMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/groups/:groupId/role-mappings/realm/available', {
- realm : '@realm',
- groupId : '@groupId'
- });
- });
- module.factory('GroupClientRoleMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/groups/:groupId/role-mappings/clients/:client', {
- realm : '@realm',
- groupId : '@groupId',
- client : "@client"
- });
- });
- module.factory('GroupAvailableClientRoleMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/groups/:groupId/role-mappings/clients/:client/available', {
- realm : '@realm',
- groupId : '@groupId',
- client : "@client"
- });
- });
- module.factory('GroupCompositeClientRoleMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/groups/:groupId/role-mappings/clients/:client/composite', {
- realm : '@realm',
- groupId : '@groupId',
- client : "@client"
- });
- });
- module.factory('GroupMembership', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/groups/:groupId/members', {
- realm : '@realm',
- groupId : '@groupId'
- });
- });
- module.factory('RoleList', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/roles', {
- realm : '@realm'
- });
- });
- module.factory('RoleMembership', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/roles/:role/users', {
- realm : '@realm',
- role : '@role'
- });
- });
- module.factory('ClientRoleList', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/roles', {
- realm : '@realm',
- client : '@client'
- });
- });
- module.factory('ClientRoleMembership', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/clients/:client/roles/:role/users', {
- realm : '@realm',
- client : '@client',
- role : '@role'
- });
- });
- module.factory('UserGroupMembership', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:userId/groups', {
- realm : '@realm',
- userId : '@userId'
- });
- });
- module.factory('UserGroupMapping', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:userId/groups/:groupId', {
- realm : '@realm',
- userId : '@userId',
- groupId : '@groupId'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('UserProfile', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/profile', {
- realm : '@realm'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('DefaultGroups', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/default-groups/:groupId', {
- realm : '@realm',
- groupId : '@groupId'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('SubComponentTypes', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/components/:componentId/sub-component-types', {
- realm: '@realm',
- componentId: '@componentId'
- });
- });
- module.factory('Components', function($resource, ComponentUtils) {
- return $resource(authUrl + '/admin/realms/:realm/components/:componentId', {
- realm : '@realm',
- componentId : '@componentId'
- }, {
- update : {
- method : 'PUT',
- transformRequest: function(componentInstance) {
- if (componentInstance.config) {
- ComponentUtils.removeLastEmptyValue(componentInstance.config);
- }
- return angular.toJson(componentInstance);
- }
- },
- save : {
- method : 'POST',
- transformRequest: function(componentInstance) {
- if (componentInstance.config) {
- ComponentUtils.removeLastEmptyValue(componentInstance.config);
- }
- return angular.toJson(componentInstance);
- }
- }
- });
- });
- module.factory('UserStorageOperations', function($resource) {
- var object = {}
- object.sync = $resource(authUrl + '/admin/realms/:realm/user-storage/:componentId/sync', {
- realm : '@realm',
- componentId : '@componentId'
- });
- object.removeImportedUsers = $resource(authUrl + '/admin/realms/:realm/user-storage/:componentId/remove-imported-users', {
- realm : '@realm',
- componentId : '@componentId'
- });
- object.unlinkUsers = $resource(authUrl + '/admin/realms/:realm/user-storage/:componentId/unlink-users', {
- realm : '@realm',
- componentId : '@componentId'
- });
- object.simpleName = $resource(authUrl + '/admin/realms/:realm/user-storage/:componentId/name', {
- realm : '@realm',
- componentId : '@componentId'
- });
- return object;
- });
- module.factory('ClientStorageOperations', function($resource) {
- var object = {}
- object.simpleName = $resource(authUrl + '/admin/realms/:realm/client-storage/:componentId/name', {
- realm : '@realm',
- componentId : '@componentId'
- });
- return object;
- });
- module.factory('ClientRegistrationPolicyProviders', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-registration-policy/providers', {
- realm : '@realm',
- });
- });
- module.factory('ClientPoliciesProfiles', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-policies/profiles?include-global-profiles=:includeGlobalProfiles', {
- realm : '@realm',
- includeGlobalProfiles : '@includeGlobalProfiles'
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('ClientPolicies', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/client-policies/policies', {
- realm : '@realm',
- }, {
- update : {
- method : 'PUT'
- }
- });
- });
- module.factory('LDAPMapperSync', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/user-storage/:parentId/mappers/:mapperId/sync', {
- realm : '@realm',
- componentId : '@componentId',
- mapperId: '@mapperId'
- });
- });
- module.factory('UserGroupMembershipCount', function($resource) {
- return $resource(authUrl + '/admin/realms/:realm/users/:userId/groups/count', {
- realm : '@realm',
- userId : '@userId'
- },
- {
- query: {
- isArray: false,
- method: 'GET',
- params: {},
- transformResponse: function (data) {
- return angular.fromJson(data)
- }
- }
- });
- });
|