12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857 |
- Array.prototype.remove = function(from, to) {
- var rest = this.slice((to || from) + 1 || this.length);
- this.length = from < 0 ? this.length + from : from;
- return this.push.apply(this, rest);
- };
- module.controller('ClientTabCtrl', function(Dialog, $scope, Current, Notifications, $location) {
- $scope.removeClient = function() {
- Dialog.confirmDelete($scope.client.clientId, 'client', function() {
- $scope.client.$remove({
- realm : Current.realm.realm,
- client : $scope.client.id
- }, function() {
- $location.url("/realms/" + Current.realm.realm + "/clients");
- Notifications.success("The client has been deleted.");
- });
- });
- };
- });
- module.controller('ClientRoleListCtrl', function($scope, $route, realm, client, ClientRoleList, RoleById, Notifications, Dialog) {
- $scope.realm = realm;
- $scope.roles = [];
- $scope.client = client;
- $scope.query = {
- realm: realm.realm,
- client: $scope.client.id,
- search : null,
- max : 20,
- first : 0
- }
- $scope.$watch('query.search', function (newVal, oldVal) {
- if($scope.query.search && $scope.query.search.length >= 3) {
- $scope.firstPage();
- }
- }, true);
- $scope.firstPage = function() {
- $scope.query.first = 0;
- $scope.searchQuery();
- }
- $scope.previousPage = function() {
- $scope.query.first -= parseInt($scope.query.max);
- if ($scope.query.first < 0) {
- $scope.query.first = 0;
- }
- $scope.searchQuery();
- }
- $scope.nextPage = function() {
- $scope.query.first += parseInt($scope.query.max);
- $scope.searchQuery();
- }
- $scope.searchQuery = function() {
- $scope.searchLoaded = false;
- $scope.roles = ClientRoleList.query($scope.query, function() {
- $scope.searchLoaded = true;
- $scope.lastSearch = $scope.query.search;
- });
- };
- $scope.searchQuery();
- $scope.removeRole = function(role) {
- Dialog.confirmDelete(role.name, 'role', function() {
- RoleById.remove({
- realm: realm.realm,
- role: role.id
- }, function () {
- $route.reload();
- Notifications.success("The role has been deleted.");
- });
- });
- };
- });
- module.controller('ClientCredentialsCtrl', function($scope, $location, realm, client, clientAuthenticatorProviders, clientConfigProperties, Client, ClientRegistrationAccessToken, Notifications) {
- $scope.realm = realm;
- $scope.client = angular.copy(client);
- $scope.clientAuthenticatorProviders = clientAuthenticatorProviders;
- var updateCurrentPartial = function(val) {
- $scope.clientAuthenticatorConfigPartial;
- switch(val) {
- case 'client-secret':
- $scope.clientAuthenticatorConfigPartial = 'client-credentials-secret.html';
- break;
- case 'client-jwt':
- $scope.clientAuthenticatorConfigPartial = 'client-credentials-jwt.html';
- break;
- case 'client-secret-jwt':
- $scope.clientAuthenticatorConfigPartial = 'client-credentials-secret-jwt.html';
- break;
- case 'client-x509':
- $scope.clientAuthenticatorConfigPartial = 'client-credentials-x509.html';
- break;
- default:
- $scope.currentAuthenticatorConfigProperties = clientConfigProperties[val];
- $scope.clientAuthenticatorConfigPartial = 'client-credentials-generic.html';
- break;
- }
- };
- updateCurrentPartial(client.clientAuthenticatorType);
- $scope.$watch('client.clientAuthenticatorType', function() {
- if (!angular.equals($scope.client.clientAuthenticatorType, client.clientAuthenticatorType)) {
- Client.update({
- realm : realm.realm,
- client : client.id
- }, $scope.client, function() {
- $scope.changed = false;
- client = angular.copy($scope.client);
- updateCurrentPartial(client.clientAuthenticatorType)
- });
- }
- }, true);
- $scope.regenerateRegistrationAccessToken = function() {
- var secret = ClientRegistrationAccessToken.update({ realm : $scope.realm.realm, client : $scope.client.id },
- function(data) {
- Notifications.success('The registration access token has been updated.');
- $scope.client['registrationAccessToken'] = data.registrationAccessToken;
- },
- function() {
- Notifications.error('Failed to update the registration access token');
- }
- );
- };
- });
- module.controller('ClientSecretCtrl', function($scope, $location, Client, ClientSecret, Notifications) {
- var secret = ClientSecret.get({ realm : $scope.realm.realm, client : $scope.client.id },
- function() {
- $scope.secret = secret.value;
- }
- );
- $scope.changePassword = function() {
- var secret = ClientSecret.update({ realm : $scope.realm.realm, client : $scope.client.id },
- function() {
- Notifications.success('The secret has been changed.');
- $scope.secret = secret.value;
- },
- function() {
- Notifications.error("The secret was not changed due to a problem.");
- $scope.secret = "error";
- }
- );
- };
- $scope.tokenEndpointAuthSigningAlg = $scope.client.attributes['token.endpoint.auth.signing.alg'];
- $scope.switchChange = function() {
- $scope.changed = true;
- }
- $scope.save = function() {
- $scope.client.attributes['token.endpoint.auth.signing.alg'] = $scope.tokenEndpointAuthSigningAlg;
- Client.update({
- realm : $scope.realm.realm,
- client : $scope.client.id
- }, $scope.client, function() {
- $scope.changed = false;
- $scope.clientCopy = angular.copy($scope.client);
- Notifications.success("Client authentication configuration has been saved to the client.");
- });
- };
- $scope.$watch(function() {
- return $location.path();
- }, function() {
- $scope.path = $location.path().substring(1).split("/");
- });
- $scope.cancel = function() {
- $location.url("/realms/" + $scope.realm.realm + "/clients/" + $scope.client.id + "/credentials");
- };
- });
- module.controller('ClientX509Ctrl', function($scope, $location, Client, Notifications) {
- console.log('ClientX509Ctrl invoked');
- $scope.clientCopy = angular.copy($scope.client);
- $scope.changed = false;
- $scope.$watch('client', function() {
- if (!angular.equals($scope.client, $scope.clientCopy)) {
- $scope.changed = true;
- }
- }, true);
- function updateProperties() {
- if ($scope.client.attributes["x509.allow.regex.pattern.comparison"]) {
- if ($scope.client.attributes["x509.allow.regex.pattern.comparison"] == "true") {
- $scope.allowRegexPatternComparison = true;
- } else {
- $scope.allowRegexPatternComparison = false;
- }
- }
- }
- updateProperties();
- $scope.switchChange = function() {
- $scope.changed = true;
- }
- $scope.save = function() {
- if ($scope.allowRegexPatternComparison == true) {
- $scope.client.attributes["x509.allow.regex.pattern.comparison"] = "true";
- } else {
- $scope.client.attributes["x509.allow.regex.pattern.comparison"] = "false";
- }
- if (!$scope.client.attributes["x509.subjectdn"]) {
- Notifications.error("The SubjectDN must not be empty.");
- } else {
- Client.update({
- realm : $scope.realm.realm,
- client : $scope.client.id
- }, $scope.client, function() {
- $scope.changed = false;
- $scope.clientCopy = angular.copy($scope.client);
- Notifications.success("Client authentication configuration has been saved to the client.");
- }, function() {
- Notifications.error("The SubjectDN was not changed due to a problem.");
- $scope.subjectdn = "error";
- });
- }
- };
- $scope.$watch(function() {
- return $location.path();
- }, function() {
- $scope.path = $location.path().substring(1).split("/");
- });
- $scope.reset = function() {
- $scope.client.attributes["x509.subjectdn"] = $scope.clientCopy.attributes["x509.subjectdn"];
- $scope.client.attributes["x509.allow.regex.pattern.comparison"] = $scope.clientCopy.attributes["x509.allow.regex.pattern.comparison"];
- updateProperties();
- $location.url("/realms/" + $scope.realm.realm + "/clients/" + $scope.client.id + "/credentials");
- };
- });
- module.controller('ClientSignedJWTCtrl', function($scope, Client, Notifications) {
- console.log('ClientSignedJWTCtrl invoked');
- $scope.tokenEndpointAuthSigningAlg = $scope.client.attributes['token.endpoint.auth.signing.alg'];
- $scope.$watch('tokenEndpointAuthSigningAlg', function() {
- if (!angular.equals($scope.client.attributes['token.endpoint.auth.signing.alg'], $scope.tokenEndpointAuthSigningAlg)) {
- $scope.client.attributes['token.endpoint.auth.signing.alg'] = $scope.tokenEndpointAuthSigningAlg;
- Client.update({
- realm : $scope.realm.realm,
- client : $scope.client.id
- }, $scope.client, function() {
- Notifications.success("Signature algorithm has been saved to the client.");
- });
- }
- }, true);
- });
- module.controller('ClientGenericCredentialsCtrl', function($scope, $location, Client, Notifications) {
- console.log('ClientGenericCredentialsCtrl invoked');
- $scope.clientCopy = angular.copy($scope.client);
- $scope.changed = false;
- $scope.$watch('client', function() {
- if (!angular.equals($scope.client, $scope.clientCopy)) {
- $scope.changed = true;
- }
- }, true);
- $scope.save = function() {
- Client.update({
- realm : $scope.realm.realm,
- client : $scope.client.id
- }, $scope.client, function() {
- $scope.changed = false;
- $scope.clientCopy = angular.copy($scope.client);
- Notifications.success("Client authentication configuration has been saved to the client.");
- });
- };
- $scope.reset = function() {
- $scope.client = angular.copy($scope.clientCopy);
- $scope.changed = false;
- };
- });
- module.controller('ClientIdentityProviderCtrl', function($scope, $location, $route, realm, client, Client, $location, Notifications) {
- $scope.realm = realm;
- $scope.client = angular.copy(client);
- var length = 0;
- if ($scope.client.identityProviders) {
- length = $scope.client.identityProviders.length;
- for (i = 0; i < $scope.client.identityProviders.length; i++) {
- var clientProvider = $scope.client.identityProviders[i];
- if (clientProvider.retrieveToken) {
- clientProvider.retrieveToken = clientProvider.retrieveToken.toString();
- }
- }
- } else {
- $scope.client.identityProviders = [];
- }
- $scope.identityProviders = [];
- var providersMissingInClient = [];
- for (j = 0; j < realm.identityProviders.length; j++) {
- var identityProvider = realm.identityProviders[j];
- var clientProvider = null;
- for (i = 0; i < $scope.client.identityProviders.length; i++) {
- clientProvider = $scope.client.identityProviders[i];
- if (clientProvider) {
- if (clientProvider.id == identityProvider.id) {
- $scope.identityProviders[i] = {};
- $scope.identityProviders[i].identityProvider = identityProvider;
- $scope.identityProviders[i].retrieveToken = clientProvider.retrieveToken;
- break;
- }
- clientProvider = null;
- }
- }
- if (clientProvider == null) {
- providersMissingInClient.push(identityProvider);
- }
- }
- for (j = 0; j < providersMissingInClient.length; j++) {
- var identityProvider = providersMissingInClient[j];
- var currentProvider = {};
- currentProvider.identityProvider = identityProvider;
- currentProvider.retrieveToken = "false";
- $scope.identityProviders.push(currentProvider);
- var currentClientProvider = {};
- currentClientProvider.id = identityProvider.id;
- currentClientProvider.retrieveToken = "false";
- $scope.client.identityProviders.push(currentClientProvider);
- }
- var oldCopy = angular.copy($scope.client);
- $scope.save = function() {
- Client.update({
- realm : realm.realm,
- client : client.id
- }, $scope.client, function() {
- $scope.changed = false;
- $route.reload();
- Notifications.success("Your changes have been saved to the client.");
- });
- };
- $scope.reset = function() {
- $scope.client = angular.copy(oldCopy);
- $scope.changed = false;
- };
- $scope.$watch('client', function() {
- if (!angular.equals($scope.client, oldCopy)) {
- $scope.changed = true;
- }
- }, true);
- });
- module.controller('ClientSamlKeyCtrl', function($scope, $location, $http, $upload, realm, client,
- ClientCertificate, ClientCertificateGenerate,
- ClientCertificateDownload, Notifications) {
- $scope.realm = realm;
- $scope.client = client;
- var signingKeyInfo = ClientCertificate.get({ realm : realm.realm, client : client.id, attribute: 'saml.signing' },
- function() {
- $scope.signingKeyInfo = signingKeyInfo;
- }
- );
- $scope.generateSigningKey = function() {
- var keyInfo = ClientCertificateGenerate.generate({ realm : realm.realm, client : client.id, attribute: 'saml.signing' },
- function() {
- Notifications.success('Signing key has been regenerated.');
- $scope.signingKeyInfo = keyInfo;
- },
- function() {
- Notifications.error("Signing key was not regenerated.");
- }
- );
- };
- $scope.importSigningKey = function() {
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/saml/Signing/import/saml.signing");
- };
- $scope.exportSigningKey = function() {
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/saml/Signing/export/saml.signing");
- };
- var encryptionKeyInfo = ClientCertificate.get({ realm : realm.realm, client : client.id, attribute: 'saml.encryption' },
- function() {
- $scope.encryptionKeyInfo = encryptionKeyInfo;
- }
- );
- $scope.generateEncryptionKey = function() {
- var keyInfo = ClientCertificateGenerate.generate({ realm : realm.realm, client : client.id, attribute: 'saml.encryption' },
- function() {
- Notifications.success('Encryption key has been regenerated.');
- $scope.encryptionKeyInfo = keyInfo;
- },
- function() {
- Notifications.error("Encryption key was not regenerated.");
- }
- );
- };
- $scope.importEncryptionKey = function() {
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/saml/Encryption/import/saml.encryption");
- };
- $scope.exportEncryptionKey = function() {
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/saml/Encryption/export/saml.encryption");
- };
- $scope.$watch(function() {
- return $location.path();
- }, function() {
- $scope.path = $location.path().substring(1).split("/");
- });
- });
- module.controller('ClientCertificateImportCtrl', function($scope, $location, $http, $upload, realm, client, callingContext, $routeParams,
- ClientCertificate, ClientCertificateGenerate,
- ClientCertificateDownload, Notifications) {
- console.log("callingContext: " + callingContext);
- var keyType = $routeParams.keyType;
- var attribute = $routeParams.attribute;
- $scope.realm = realm;
- $scope.client = client;
- $scope.keyType = keyType;
- if (callingContext == 'saml') {
- var uploadUrl = authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id + '/certificates/' + attribute + '/upload';
- var redirectLocation = "/realms/" + realm.realm + "/clients/" + client.id + "/saml/keys";
- } else if (callingContext == 'oidc') {
- var uploadUrl = authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id + '/certificates/' + attribute + '/upload-certificate';
- var redirectLocation = "/realms/" + realm.realm + "/clients/" + client.id + "/oidc/keys";
- }
- $scope.files = [];
- $scope.onFileSelect = function($files) {
- $scope.files = $files;
- };
- $scope.cancel = function() {
- $location.url(redirectLocation);
- }
- $scope.keyFormats = [
- "JKS",
- "PKCS12",
- "Certificate PEM"
- ];
- if (callingContext == 'oidc') {
- $scope.keyFormats.push('Public Key PEM');
- $scope.keyFormats.push('JSON Web Key Set');
- }
- $scope.hideKeystoreSettings = function() {
- return $scope.uploadKeyFormat == 'Certificate PEM' || $scope.uploadKeyFormat == 'Public Key PEM' || $scope.uploadKeyFormat == 'JSON Web Key Set';
- }
- $scope.uploadKeyFormat = $scope.keyFormats[0];
- $scope.uploadFile = function() {
- //$files: an array of files selected, each file has name, size, and type.
- for (var i = 0; i < $scope.files.length; i++) {
- var $file = $scope.files[i];
- $scope.upload = $upload.upload({
- url: uploadUrl,
- // method: POST or PUT,
- // headers: {'headerKey': 'headerValue'}, withCredential: true,
- data: {keystoreFormat: $scope.uploadKeyFormat,
- keyAlias: $scope.uploadKeyAlias,
- keyPassword: $scope.uploadKeyPassword,
- storePassword: $scope.uploadStorePassword
- },
- file: $file
- /* set file formData name for 'Content-Desposition' header. Default: 'file' */
- //fileFormDataName: myFile,
- /* customize how data is added to formData. See #40#issuecomment-28612000 for example */
- //formDataAppender: function(formData, key, val){}
- }).then(function(data, status, headers) {
- Notifications.success("Keystore uploaded successfully.");
- $location.url(redirectLocation);
- })
- //.then(success, error, progress);
- }
- };
- $scope.$watch(function() {
- return $location.path();
- }, function() {
- $scope.path = $location.path().substring(1).split("/");
- });
- });
- module.controller('ClientCertificateExportCtrl', function($scope, $location, $http, $upload, realm, client, callingContext, $routeParams,
- ClientCertificate, ClientCertificateGenerate,
- ClientCertificateDownload, Notifications) {
- var keyType = $routeParams.keyType;
- var attribute = $routeParams.attribute;
- $scope.realm = realm;
- $scope.client = client;
- $scope.keyType = keyType;
- if (callingContext == 'saml') {
- var downloadUrl = authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id + '/certificates/' + attribute + '/download';
- var realmCertificate = true;
- } else if (callingContext == 'oidc') {
- var downloadUrl = authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id + '/certificates/' + attribute + '/generate-and-download'
- var realmCertificate = false;
- }
- var jks = {
- keyAlias: client.clientId,
- realmAlias: realm.realm,
- realmCertificate: realmCertificate
- };
- $scope.keyFormats = [
- "JKS",
- "PKCS12"
- ];
- var keyInfo = ClientCertificate.get({ realm : realm.realm, client : client.id, attribute: attribute },
- function() {
- $scope.keyInfo = keyInfo;
- }
- );
- $scope.jks = jks;
- $scope.jks.format = $scope.keyFormats[0];
- $scope.download = function() {
- $http({
- url: downloadUrl,
- method: 'POST',
- responseType: 'arraybuffer',
- data: $scope.jks,
- headers: {
- 'Content-Type': 'application/json',
- 'Accept': 'application/octet-stream'
- }
- }).then(function(response){
- var blob = new Blob([response.data], {
- type: 'application/octet-stream'
- });
- var ext = ".jks";
- if ($scope.jks.format == 'PKCS12') ext = ".p12";
- if (callingContext == 'oidc') {
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/oidc/keys");
- Notifications.success("New keypair and certificate generated successfully. Download keystore file")
- }
- saveAs(blob, 'keystore' + ext);
- }).catch(function(response) {
- var errorMsg = 'Error downloading';
- try {
- var error = JSON.parse(String.fromCharCode.apply(null, new Uint8Array(response.data)));
- errorMsg = error['error_description'] ? error['error_description'] : errorMsg;
- } catch (err) {
- }
- Notifications.error(errorMsg);
- });
- }
- $scope.$watch(function() {
- return $location.path();
- }, function() {
- $scope.path = $location.path().substring(1).split("/");
- });
- $scope.cancel = function() {
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/oidc/keys");
- }
- });
- module.controller('ClientOidcKeyCtrl', function($scope, $location, realm, client, Client, ClientCertificate, Notifications, $route) {
- $scope.realm = realm;
- $scope.client = angular.copy(client);
- var signingKeyInfo = ClientCertificate.get({ realm : realm.realm, client : client.id, attribute: 'jwt.credential' },
- function() {
- $scope.signingKeyInfo = signingKeyInfo;
- }
- );
- $scope.changed = false;
- $scope.$watch('client', function() {
- if (!angular.equals($scope.client, client)) {
- $scope.changed = true;
- }
- }, true);
- if ($scope.client.attributes["use.jwks.url"]) {
- if ($scope.client.attributes["use.jwks.url"] == "true") {
- $scope.useJwksUrl = true;
- } else {
- $scope.useJwksUrl = false;
- }
- }
- if ($scope.client.attributes["use.jwks.string"]) {
- if ($scope.client.attributes["use.jwks.string"] == "true") {
- $scope.useJwksString = true;
- } else {
- $scope.useJwksString = false;
- }
- }
- $scope.jwksUrlSwitchChange = function() {
- $scope.changed = true;
- if ($scope.useJwksUrl == false) {
- $scope.useJwksString = false;
- }
- }
- $scope.jwksStringSwitchChange = function() {
- $scope.changed = true;
- if ($scope.useJwksString == false) {
- $scope.useJwksUrl = false;
- }
- }
- $scope.save = function() {
- if ($scope.useJwksUrl == true) {
- $scope.client.attributes["use.jwks.url"] = "true";
- } else {
- $scope.client.attributes["use.jwks.url"] = "false";
- }
- if ($scope.useJwksString == true) {
- $scope.client.attributes["use.jwks.string"] = "true";
- } else {
- $scope.client.attributes["use.jwks.string"] = "false";
- }
- Client.update({
- realm : realm.realm,
- client : client.id
- }, $scope.client, function() {
- $scope.changed = false;
- client = angular.copy($scope.client);
- Notifications.success("OIDC key has been saved to the client.");
- });
- };
- $scope.importCertificate = function() {
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/oidc/Signing/import/jwt.credential");
- };
- $scope.generateSigningKey = function() {
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/oidc/Signing/export/jwt.credential");
- };
- $scope.reset = function() {
- $route.reload();
- };
- });
- module.controller('ClientSessionsCtrl', function($scope, realm, sessionCount, client,
- ClientUserSessions) {
- $scope.realm = realm;
- $scope.count = sessionCount.count;
- $scope.sessions = [];
- $scope.client = client;
- $scope.page = 0;
- $scope.query = {
- realm : realm.realm,
- client: $scope.client.id,
- max : 5,
- first : 0
- }
- $scope.firstPage = function() {
- $scope.query.first = 0;
- if ($scope.query.first < 0) {
- $scope.query.first = 0;
- }
- $scope.loadUsers();
- }
- $scope.previousPage = function() {
- $scope.query.first -= parseInt($scope.query.max);
- if ($scope.query.first < 0) {
- $scope.query.first = 0;
- }
- $scope.loadUsers();
- }
- $scope.nextPage = function() {
- $scope.query.first += parseInt($scope.query.max);
- $scope.loadUsers();
- }
- $scope.toDate = function(val) {
- return new Date(val);
- };
- $scope.loadUsers = function() {
- ClientUserSessions.query($scope.query, function(updated) {
- $scope.sessions = updated;
- })
- };
- });
- module.controller('ClientOfflineSessionsCtrl', function($scope, realm, offlineSessionCount, client,
- ClientOfflineSessions) {
- $scope.realm = realm;
- $scope.count = offlineSessionCount.count;
- $scope.sessions = [];
- $scope.client = client;
- $scope.page = 0;
- $scope.query = {
- realm : realm.realm,
- client: $scope.client.id,
- max : 5,
- first : 0
- }
- $scope.firstPage = function() {
- $scope.query.first = 0;
- if ($scope.query.first < 0) {
- $scope.query.first = 0;
- }
- $scope.loadUsers();
- }
- $scope.previousPage = function() {
- $scope.query.first -= parseInt($scope.query.max);
- if ($scope.query.first < 0) {
- $scope.query.first = 0;
- }
- $scope.loadUsers();
- }
- $scope.nextPage = function() {
- $scope.query.first += parseInt($scope.query.max);
- $scope.loadUsers();
- }
- $scope.toDate = function(val) {
- return new Date(val);
- };
- $scope.loadUsers = function() {
- ClientOfflineSessions.query($scope.query, function(updated) {
- $scope.sessions = updated;
- })
- };
- });
- module.controller('ClientRoleDetailCtrl', function($scope, $route, realm, client, role, roles, Client,
- Role, ClientRole, RoleById, RoleRealmComposites, RoleClientComposites,
- $http, $location, Dialog, Notifications, ComponentUtils) {
- $scope.realm = realm;
- $scope.client = client;
- $scope.role = angular.copy(role);
- $scope.create = !role.name;
- $scope.changed = $scope.create;
-
- $scope.save = function() {
- convertAttributeValuesToLists();
- if ($scope.create) {
- ClientRole.save({
- realm: realm.realm,
- client : client.id
- }, $scope.role, function (data, headers) {
- $scope.changed = false;
- convertAttributeValuesToString($scope.role);
- role = angular.copy($scope.role);
- ClientRole.get({ realm: realm.realm, client : client.id, role: role.name }, function(role) {
- var id = role.id;
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/roles/" + id);
- Notifications.success("The role has been created.");
- });
- });
- } else {
- $scope.update();
- }
- };
- $scope.remove = function() {
- Dialog.confirmDelete($scope.role.name, 'role', function() {
- $scope.role.$remove({
- realm : realm.realm,
- client : client.id,
- role : $scope.role.id
- }, function() {
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/roles");
- Notifications.success("The role has been deleted.");
- });
- });
- };
- $scope.cancel = function () {
- $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/roles");
- };
- $scope.addAttribute = function() {
- $scope.role.attributes[$scope.newAttribute.key] = $scope.newAttribute.value;
- delete $scope.newAttribute;
- }
- $scope.removeAttribute = function(key) {
- delete $scope.role.attributes[key];
- }
- function convertAttributeValuesToLists() {
- var attrs = $scope.role.attributes;
- for (var attribute in attrs) {
- if (typeof attrs[attribute] === "string") {
- var attrVals = attrs[attribute].split("##");
- attrs[attribute] = attrVals;
- }
- }
- }
- function convertAttributeValuesToString(role) {
- var attrs = role.attributes;
- for (var attribute in attrs) {
- if (typeof attrs[attribute] === "object") {
- var attrVals = attrs[attribute].join("##");
- attrs[attribute] = attrVals;
- }
- }
- }
- roleControl($scope, $route, realm, role, roles, Client,
- ClientRole, RoleById, RoleRealmComposites, RoleClientComposites,
- $http, $location, Notifications, Dialog, ComponentUtils);
- });
- module.controller('ClientRoleMembersCtrl', function($scope, realm, client, role, ClientRoleMembership, Dialog, Notifications, $location) {
- $scope.realm = realm;
- $scope.page = 0;
- $scope.role = role;
- $scope.client = client;
- $scope.query = {
- realm: realm.realm,
- role: role.name,
- client: client.id,
- max : 5,
- first : 0
- }
- $scope.firstPage = function() {
- $scope.query.first = 0;
- $scope.searchQuery();
- }
- $scope.previousPage = function() {
- $scope.query.first -= parseInt($scope.query.max);
- if ($scope.query.first < 0) {
- $scope.query.first = 0;
- }
- $scope.searchQuery();
- }
- $scope.nextPage = function() {
- $scope.query.first += parseInt($scope.query.max);
- $scope.searchQuery();
- }
- $scope.searchQuery = function() {
- $scope.searchLoaded = false;
- $scope.users = ClientRoleMembership.query($scope.query, function() {
- console.log('search loaded');
- $scope.searchLoaded = true;
- $scope.lastSearch = $scope.query.search;
- });
- };
- $scope.searchQuery();
- });
- module.controller('ClientImportCtrl', function($scope, $location, $upload, realm, serverInfo, Notifications) {
- $scope.realm = realm;
- $scope.files = [];
- $scope.onFileSelect = function($files) {
- $scope.files = $files;
- };
- $scope.clearFileSelect = function() {
- $scope.files = null;
- }
- $scope.uploadFile = function() {
- //$files: an array of files selected, each file has name, size, and type.
- for (var i = 0; i < $scope.files.length; i++) {
- var $file = $scope.files[i];
- $scope.upload = $upload.upload({
- url: authUrl + '/admin/realms/' + realm.realm + '/client-importers/' + $scope.configFormat.id + '/upload',
- // method: POST or PUT,
- // headers: {'headerKey': 'headerValue'}, withCredential: true,
- data: {myObj: ""},
- file: $file
- /* set file formData name for 'Content-Desposition' header. Default: 'file' */
- //fileFormDataName: myFile,
- /* customize how data is added to formData. See #40#issuecomment-28612000 for example */
- //formDataAppender: function(formData, key, val){}
- }).success(function(data, status, headers) {
- Notifications.success("Uploaded successfully.");
- $location.url("/realms/" + realm.realm + "/clients");
- })
- .error(function() {
- Notifications.error("The file can not be uploaded. Please verify the file.");
- });
- //.then(success, error, progress);
- }
- };
- $scope.$watch(function() {
- return $location.path();
- }, function() {
- $scope.path = $location.path().substring(1).split("/");
- });
- });
- module.controller('ClientListCtrl', function($scope, realm, Client, ClientListSearchState, $route, Dialog, Notifications) {
- $scope.init = function() {
- $scope.realm = realm;
- $scope.searchLoaded = true;
- ClientListSearchState.query.realm = realm.realm;
- $scope.query = ClientListSearchState.query;
- if (!ClientListSearchState.isFirstSearch) {
- $scope.searchQuery();
- } else {
- $scope.query.clientId = null;
- $scope.firstPage();
- }
- };
-
- $scope.searchQuery = function() {
- console.log("query.search: ", $scope.query);
- $scope.searchLoaded = false;
- $scope.clients = Client.query($scope.query, function() {
- $scope.searchLoaded = true;
- $scope.lastSearch = $scope.query.search;
- ClientListSearchState.isFirstSearch = false;
- });
- };
- $scope.firstPage = function() {
- $scope.query.first = 0;
- $scope.searchQuery();
- }
- $scope.previousPage = function() {
- $scope.query.first -= parseInt($scope.query.max);
- if ($scope.query.first < 0) {
- $scope.query.first = 0;
- }
- $scope.searchQuery();
- }
- $scope.nextPage = function() {
- $scope.query.first += parseInt($scope.query.max);
- $scope.searchQuery();
- }
- $scope.removeClient = function(client) {
- Dialog.confirmDelete(client.clientId, 'client', function() {
- Client.remove({
- realm : realm.realm,
- client : client.id
- }, function() {
- $route.reload();
- Notifications.success("The client has been deleted.");
- });
- });
- };
- $scope.exportClient = function(client) {
- var clientCopy = angular.copy(client);
- delete clientCopy.id;
- if (clientCopy.protocolMappers) {
- for (var i = 0; i < clientCopy.protocolMappers.length; i++) {
- delete clientCopy.protocolMappers[i].id;
- }
- }
- saveAs(new Blob([angular.toJson(clientCopy, 4)], { type: 'application/json' }), clientCopy.clientId + '.json');
- }
- });
- module.controller('ClientInstallationCtrl', function($scope, realm, client, serverInfo, ClientInstallation,$http, $routeParams) {
- $scope.realm = realm;
- $scope.client = client;
- $scope.installation = null;
- $scope.download = null;
- $scope.configFormat = null;
- $scope.filename = null;
- var protocol = client.protocol;
- if (!protocol) protocol = 'openid-connect';
- $scope.configFormats = serverInfo.clientInstallations[protocol];
- console.log('configFormats.length: ' + $scope.configFormats.length);
- $scope.changeFormat = function() {
- var url = ClientInstallation.url({ realm: $routeParams.realm, client: $routeParams.client, provider: $scope.configFormat.id });
- if ($scope.configFormat.mediaType == 'application/zip') {
- $http({
- url: url,
- method: 'GET',
- responseType: 'arraybuffer',
- cache: false
- }).then(function(response) {
- var installation = response.data;
- $scope.installation = installation;
- }
- );
- } else {
- $http.get(url).then(function (response) {
- var installation = response.data;
- if ($scope.configFormat.mediaType == 'application/json') {
- installation = angular.fromJson(response.data);
- installation = angular.toJson(installation, true);
- }
- $scope.installation = installation;
- });
- }
- };
- $scope.download = function() {
- saveAs(new Blob([$scope.installation], { type: $scope.configFormat.mediaType }), $scope.configFormat.filename);
- }
- });
- module.controller('ClientDetailCtrl', function($scope, realm, client, flows, $route, serverInfo, Client, ClientDescriptionConverter, Components, ClientStorageOperations, $location, $modal, Dialog, Notifications, TimeUnit2) {
- $scope.serverInfo = serverInfo;
- $scope.flows = [];
- $scope.clientFlows = [];
- var emptyFlow = {
- id: "",
- alias: ""
- }
- for (var i=0 ; i<flows.length ; i++) {
- if (flows[i].providerId == 'client-flow') {
- $scope.clientFlows.push(flows[i]);
- } else {
- $scope.flows.push(flows[i]);
- }
- }
- $scope.flows.push(emptyFlow)
- $scope.clientFlows.push(emptyFlow)
- $scope.accessTypes = [
- "confidential",
- "public",
- "bearer-only"
- ];
- $scope.protocols = serverInfo.listProviderIds('login-protocol');
- $scope.signatureAlgorithms = [
- "RSA_SHA1",
- "RSA_SHA256",
- "RSA_SHA256_MGF1",
- "RSA_SHA512",
- "RSA_SHA512_MGF1",
- "DSA_SHA1"
- ];
- $scope.nameIdFormats = [
- "username",
- "email",
- "transient",
- "persistent"
- ];
- $scope.xmlKeyNameTranformers = [
- "NONE",
- "KEY_ID",
- "CERT_SUBJECT"
- ];
- $scope.canonicalization = [
- {name: "EXCLUSIVE", value: "http://www.w3.org/2001/10/xml-exc-c14n#" },
- {name: "EXCLUSIVE_WITH_COMMENTS", value: "http://www.w3.org/2001/10/xml-exc-c14n#WithComments"},
- {name: "INCLUSIVE", value: "http://www.w3.org/TR/2001/REC-xml-c14n-20010315" },
- {name: "INCLUSIVE_WITH_COMMENTS", value: "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"}
- ];
- $scope.requestObjectRequiredOptions = [
- "not required",
- "request or request_uri",
- "request only",
- "request_uri only"
- ];
- $scope.changePkceCodeChallengeMethodOptions = [
- "S256",
- "plain",
- ""
- ];
- $scope.realm = realm;
- $scope.samlAuthnStatement = false;
- $scope.samlOneTimeUseCondition = false;
- $scope.samlMultiValuedRoles = false;
- $scope.samlArtifactBinding = false;
- $scope.samlServerSignature = false;
- $scope.samlServerSignatureEnableKeyInfoExtension = false;
- $scope.samlAssertionSignature = false;
- $scope.samlClientSignature = false;
- $scope.samlEncrypt = false;
- $scope.samlForcePostBinding = false;
- $scope.samlForceNameIdFormat = false;
- $scope.samlXmlKeyNameTranformer = $scope.xmlKeyNameTranformers[1];
- $scope.disableAuthorizationTab = !client.authorizationServicesEnabled;
- $scope.disableServiceAccountRolesTab = !client.serviceAccountsEnabled;
- $scope.disableCredentialsTab = client.publicClient;
- $scope.oauth2DeviceAuthorizationGrantEnabled = false;
- $scope.oidcCibaGrantEnabled = false;
- // KEYCLOAK-6771 Certificate Bound Token
- // https://tools.ietf.org/html/draft-ietf-oauth-mtls-08#section-3
- $scope.tlsClientCertificateBoundAccessTokens = false;
- $scope.useRefreshTokens = true;
- $scope.useIdTokenAsDetachedSignature = false;
- $scope.accessTokenLifespan = TimeUnit2.asUnit(client.attributes['access.token.lifespan']);
- $scope.samlAssertionLifespan = TimeUnit2.asUnit(client.attributes['saml.assertion.lifespan']);
- $scope.clientSessionIdleTimeout = TimeUnit2.asUnit(client.attributes['client.session.idle.timeout']);
- $scope.clientSessionMaxLifespan = TimeUnit2.asUnit(client.attributes['client.session.max.lifespan']);
- $scope.clientOfflineSessionIdleTimeout = TimeUnit2.asUnit(client.attributes['client.offline.session.idle.timeout']);
- $scope.clientOfflineSessionMaxLifespan = TimeUnit2.asUnit(client.attributes['client.offline.session.max.lifespan']);
- $scope.oauth2DeviceCodeLifespan = TimeUnit2.asUnit(client.attributes['oauth2.device.code.lifespan']);
- $scope.oauth2DevicePollingInterval = parseInt(client.attributes['oauth2.device.polling.interval']);
- // PAR request.
- $scope.requirePushedAuthorizationRequests = false;
- if(client.origin) {
- if ($scope.access.viewRealm) {
- Components.get({realm: realm.realm, componentId: client.origin}, function (link) {
- $scope.originName = link.name;
- //$scope.originLink = "#/realms/" + realm.realm + "/user-storage/providers/" + link.providerId + "/" + link.id;
- })
- }
- else {
- // KEYCLOAK-4328
- ClientStorageOperations.simpleName.get({realm: realm.realm, componentId: client.origin}, function (link) {
- $scope.originName = link.name;
- //$scope.originLink = $location.absUrl();
- })
- }
- } else {
- console.log("origin is null");
- }
- function updateProperties() {
- if (!$scope.client.attributes) {
- $scope.client.attributes = {};
- }
- $scope.accessType = $scope.accessTypes[0];
- if ($scope.client.bearerOnly) {
- $scope.accessType = $scope.accessTypes[2];
- } else if ($scope.client.publicClient) {
- $scope.accessType = $scope.accessTypes[1];
- }
- if ($scope.client.protocol) {
- $scope.protocol = $scope.protocols[$scope.protocols.indexOf($scope.client.protocol)];
- } else {
- $scope.protocol = $scope.protocols[0];
- }
- if ($scope.client.attributes['saml.signature.algorithm'] == 'RSA_SHA1') {
- $scope.signatureAlgorithm = $scope.signatureAlgorithms[0];
- } else if ($scope.client.attributes['saml.signature.algorithm'] == 'RSA_SHA256') {
- $scope.signatureAlgorithm = $scope.signatureAlgorithms[1];
- } else if ($scope.client.attributes['saml.signature.algorithm'] == 'RSA_SHA256_MGF1') {
- $scope.signatureAlgorithm = $scope.signatureAlgorithms[2];
- } else if ($scope.client.attributes['saml.signature.algorithm'] == 'RSA_SHA512') {
- $scope.signatureAlgorithm = $scope.signatureAlgorithms[3];
- } else if ($scope.client.attributes['saml.signature.algorithm'] == 'RSA_SHA512_MGF1') {
- $scope.signatureAlgorithm = $scope.signatureAlgorithms[4];
- } else if ($scope.client.attributes['saml.signature.algorithm'] == 'DSA_SHA1') {
- $scope.signatureAlgorithm = $scope.signatureAlgorithms[5];
- }
- if ($scope.client.attributes['saml_name_id_format'] == 'username') {
- $scope.nameIdFormat = $scope.nameIdFormats[0];
- } else if ($scope.client.attributes['saml_name_id_format'] == 'email') {
- $scope.nameIdFormat = $scope.nameIdFormats[1];
- } else if ($scope.client.attributes['saml_name_id_format'] == 'transient') {
- $scope.nameIdFormat = $scope.nameIdFormats[2];
- } else if ($scope.client.attributes['saml_name_id_format'] == 'persistent') {
- $scope.nameIdFormat = $scope.nameIdFormats[3];
- }
- if ($scope.client.attributes["saml.artifact.binding"]) {
- if ($scope.client.attributes["saml.artifact.binding"] == "true") {
- $scope.samlArtifactBinding = true;
- } else {
- $scope.samlArtifactBinding = false;
- }
- }
- if ($scope.client.attributes["saml.server.signature"]) {
- if ($scope.client.attributes["saml.server.signature"] == "true") {
- $scope.samlServerSignature = true;
- } else {
- $scope.samlServerSignature = false;
- }
- }
- if ($scope.client.attributes["saml.server.signature.keyinfo.ext"]) {
- if ($scope.client.attributes["saml.server.signature.keyinfo.ext"] == "true") {
- $scope.samlServerSignatureEnableKeyInfoExtension = true;
- } else {
- $scope.samlServerSignatureEnableKeyInfoExtension = false;
- }
- }
- if ($scope.client.attributes['saml.server.signature.keyinfo.xmlSigKeyInfoKeyNameTransformer'] === 'NONE') {
- $scope.samlXmlKeyNameTranformer = $scope.xmlKeyNameTranformers[0];
- } else if ($scope.client.attributes['saml.server.signature.keyinfo.xmlSigKeyInfoKeyNameTransformer'] === 'KEY_ID') {
- $scope.samlXmlKeyNameTranformer = $scope.xmlKeyNameTranformers[1];
- } else if ($scope.client.attributes['saml.server.signature.keyinfo.xmlSigKeyInfoKeyNameTransformer'] === 'CERT_SUBJECT') {
- $scope.samlXmlKeyNameTranformer = $scope.xmlKeyNameTranformers[2];
- }
- if ($scope.client.attributes["saml.assertion.signature"]) {
- if ($scope.client.attributes["saml.assertion.signature"] == "true") {
- $scope.samlAssertionSignature = true;
- } else {
- $scope.samlAssertionSignature = false;
- }
- }
- if ($scope.client.attributes["saml.client.signature"]) {
- if ($scope.client.attributes["saml.client.signature"] == "true") {
- $scope.samlClientSignature = true;
- } else {
- $scope.samlClientSignature = false;
- }
- }
- if ($scope.client.attributes["saml.encrypt"]) {
- if ($scope.client.attributes["saml.encrypt"] == "true") {
- $scope.samlEncrypt = true;
- } else {
- $scope.samlEncrypt = false;
- }
- }
- if ($scope.client.attributes["saml.authnstatement"]) {
- if ($scope.client.attributes["saml.authnstatement"] == "true") {
- $scope.samlAuthnStatement = true;
- } else {
- $scope.samlAuthnStatement = false;
- }
- }
- if ($scope.client.attributes["saml.onetimeuse.condition"]) {
- if ($scope.client.attributes["saml.onetimeuse.condition"] == "true") {
- $scope.samlOneTimeUseCondition = true;
- } else {
- $scope.samlOneTimeUseCondition = false;
- }
- }
- if ($scope.client.attributes["saml_force_name_id_format"]) {
- if ($scope.client.attributes["saml_force_name_id_format"] == "true") {
- $scope.samlForceNameIdFormat = true;
- } else {
- $scope.samlForceNameIdFormat = false;
- }
- }
- if ($scope.client.attributes["saml.multivalued.roles"]) {
- if ($scope.client.attributes["saml.multivalued.roles"] == "true") {
- $scope.samlMultiValuedRoles = true;
- } else {
- $scope.samlMultiValuedRoles = false;
- }
- }
- if ($scope.client.attributes["saml.force.post.binding"]) {
- if ($scope.client.attributes["saml.force.post.binding"] == "true") {
- $scope.samlForcePostBinding = true;
- } else {
- $scope.samlForcePostBinding = false;
- }
- }
- $scope.accessTokenSignedResponseAlg = $scope.client.attributes['access.token.signed.response.alg'];
- $scope.idTokenSignedResponseAlg = $scope.client.attributes['id.token.signed.response.alg'];
- $scope.idTokenEncryptedResponseAlg = $scope.client.attributes['id.token.encrypted.response.alg'];
- $scope.idTokenEncryptedResponseEnc = $scope.client.attributes['id.token.encrypted.response.enc'];
- $scope.authorizationSignedResponseAlg = $scope.client.attributes['authorization.signed.response.alg'];
- $scope.authorizationEncryptedResponseAlg = $scope.client.attributes['authorization.encrypted.response.alg'];
- $scope.authorizationEncryptedResponseEnc = $scope.client.attributes['authorization.encrypted.response.enc'];
- var attrVal1 = $scope.client.attributes['user.info.response.signature.alg'];
- $scope.userInfoSignedResponseAlg = attrVal1==null ? 'unsigned' : attrVal1;
- var attrVal2 = $scope.client.attributes['request.object.signature.alg'];
- $scope.requestObjectSignatureAlg = attrVal2==null ? 'any' : attrVal2;
- var attrVal3 = $scope.client.attributes['request.object.required'];
- $scope.requestObjectRequired = attrVal3==null ? 'not required' : attrVal3;
- var attrVal4 = $scope.client.attributes['pkce.code.challenge.method'];
- $scope.pkceCodeChallengeMethod = attrVal4==null ? 'none' : attrVal4;
- var attrVal5 = $scope.client.attributes['ciba.backchannel.auth.request.signing.alg'];
- $scope.cibaBackchannelAuthRequestSigningAlg = attrVal5==null ? 'none' : attrVal5;
- var attrVal6 = $scope.client.attributes['request.object.encryption.alg'];
- $scope.requestObjectEncryptionAlg = attrVal6==null ? 'any' : attrVal6;
- var attrVal7 = $scope.client.attributes['request.object.encryption.enc'];
- $scope.requestObjectEncryptionEnc = attrVal7==null ? 'any' : attrVal7;
- var attrVal8 = $scope.client.attributes['ciba.backchannel.auth.request.signing.alg'];
- $scope.cibaBackchannelAuthRequestSigningAlg = attrVal8==null ? 'any' : attrVal8;
- if ($scope.client.attributes["exclude.session.state.from.auth.response"]) {
- if ($scope.client.attributes["exclude.session.state.from.auth.response"] == "true") {
- $scope.excludeSessionStateFromAuthResponse = true;
- } else {
- $scope.excludeSessionStateFromAuthResponse = false;
- }
- }
- if ($scope.client.attributes["oauth2.device.authorization.grant.enabled"]) {
- if ($scope.client.attributes["oauth2.device.authorization.grant.enabled"] == "true") {
- $scope.oauth2DeviceAuthorizationGrantEnabled = true;
- } else {
- $scope.oauth2DeviceAuthorizationGrantEnabled = false;
- }
- }
- if ($scope.client.attributes["oidc.ciba.grant.enabled"]) {
- if ($scope.client.attributes["oidc.ciba.grant.enabled"] == "true") {
- $scope.oidcCibaGrantEnabled = true;
- } else {
- $scope.oidcCibaGrantEnabled = false;
- }
- }
- $scope.cibaBackchannelTokenDeliveryMode = $scope.client.attributes['ciba.backchannel.token.delivery.mode'];
- if ($scope.client.attributes["use.refresh.tokens"]) {
- if ($scope.client.attributes["use.refresh.tokens"] == "true") {
- $scope.useRefreshTokens = true;
- } else {
- $scope.useRefreshTokens = false;
- }
- }
- if ($scope.client.attributes["id.token.as.detached.signature"]) {
- if ($scope.client.attributes["id.token.as.detached.signature"] == "true") {
- $scope.useIdTokenAsDetachedSignature = true;
- } else {
- $scope.useIdTokenAsDetachedSignature = false;
- }
- }
- // KEYCLOAK-6771 Certificate Bound Token
- // https://tools.ietf.org/html/draft-ietf-oauth-mtls-08#section-3
- if ($scope.client.attributes["tls.client.certificate.bound.access.tokens"]) {
- if ($scope.client.attributes["tls.client.certificate.bound.access.tokens"] == "true") {
- $scope.tlsClientCertificateBoundAccessTokens = true;
- } else {
- $scope.tlsClientCertificateBoundAccessTokens = false;
- }
- }
- // PAR request.
- if ($scope.client.attributes["require.pushed.authorization.requests"]) {
- if ($scope.client.attributes["require.pushed.authorization.requests"] == "true") {
- $scope.requirePushedAuthorizationRequests = true;
- } else {
- $scope.requirePushedAuthorizationRequests = false;
- }
- }
- var useRefreshToken = $scope.client.attributes["client_credentials.use_refresh_token"];
- if (useRefreshToken === "true") {
- $scope.useRefreshTokenForClientCredentialsGrant = true;
- } else {
- $scope.useRefreshTokenForClientCredentialsGrant = false;
- }
- if ($scope.client.attributes["display.on.consent.screen"]) {
- if ($scope.client.attributes["display.on.consent.screen"] == "true") {
- $scope.displayOnConsentScreen = true;
- } else {
- $scope.displayOnConsentScreen = false;
- }
- }
- if ($scope.client.attributes["backchannel.logout.session.required"]) {
- if ($scope.client.attributes["backchannel.logout.session.required"] == "true") {
- $scope.backchannelLogoutSessionRequired = true;
- } else {
- $scope.backchannelLogoutSessionRequired = false;
- }
- }
- if ($scope.client.attributes["backchannel.logout.revoke.offline.tokens"]) {
- if ($scope.client.attributes["backchannel.logout.revoke.offline.tokens"] == "true") {
- $scope.backchannelLogoutRevokeOfflineSessions = true;
- } else {
- $scope.backchannelLogoutRevokeOfflineSessions = false;
- }
- }
- if ($scope.client.attributes["request.uris"] && $scope.client.attributes["request.uris"].length > 0) {
- $scope.client.requestUris = $scope.client.attributes["request.uris"].split("##");
- } else {
- $scope.client.requestUris = [];
- }
- }
- if (!$scope.create) {
- $scope.client = client;
- updateProperties();
- $scope.clientEdit = angular.copy(client);
- }
- $scope.samlIdpInitiatedUrl = function(ssoName) {
- return encodeURI($location.absUrl().replace(/\/admin.*/, "/realms/") + realm.realm + "/protocol/saml/clients/") + encodeURIComponent(ssoName)
- }
- $scope.importFile = function(fileContent){
- console.debug(fileContent);
- ClientDescriptionConverter.save({
- realm: realm.realm
- }, fileContent, function (data) {
- $scope.client = data;
- updateProperties();
- $scope.importing = true;
- $scope.clientEdit = angular.copy(client);
- });
- };
- $scope.viewImportDetails = function() {
- $modal.open({
- templateUrl: resourceUrl + '/partials/modal/view-object.html',
- controller: 'ObjectModalCtrl',
- resolve: {
- object: function () {
- return $scope.client;
- }
- }
- })
- };
- $scope.switchChange = function() {
- $scope.changed = true;
- }
- $scope.changeAccessType = function() {
- if ($scope.accessType == "confidential") {
- $scope.clientEdit.bearerOnly = false;
- $scope.clientEdit.publicClient = false;
- } else if ($scope.accessType == "public") {
- $scope.clientEdit.bearerOnly = false;
- $scope.clientEdit.publicClient = true;
- } else if ($scope.accessType == "bearer-only") {
- $scope.clientEdit.bearerOnly = true;
- $scope.clientEdit.publicClient = false;
- $scope.clientEdit.alwaysDisplayInConsole = false;
- }
- };
- $scope.changeProtocol = function() {
- if ($scope.protocol == "openid-connect") {
- $scope.clientEdit.protocol = "openid-connect";
- } else if ($scope.protocol == "saml") {
- $scope.clientEdit.protocol = "saml";
- }
- };
- $scope.changeAlgorithm = function() {
- $scope.clientEdit.attributes['saml.signature.algorithm'] = $scope.signatureAlgorithm;
- };
- $scope.changeNameIdFormat = function() {
- $scope.clientEdit.attributes['saml_name_id_format'] = $scope.nameIdFormat;
- };
- $scope.changeSamlSigKeyNameTranformer = function() {
- $scope.clientEdit.attributes['saml.server.signature.keyinfo.xmlSigKeyInfoKeyNameTransformer'] = $scope.samlXmlKeyNameTranformer;
- };
- $scope.changeAccessTokenSignedResponseAlg = function() {
- $scope.clientEdit.attributes['access.token.signed.response.alg'] = $scope.accessTokenSignedResponseAlg;
- };
- $scope.changeIdTokenSignedResponseAlg = function() {
- $scope.clientEdit.attributes['id.token.signed.response.alg'] = $scope.idTokenSignedResponseAlg;
- };
- $scope.changeIdTokenEncryptedResponseAlg = function() {
- $scope.clientEdit.attributes['id.token.encrypted.response.alg'] = $scope.idTokenEncryptedResponseAlg;
- };
- $scope.changeIdTokenEncryptedResponseEnc = function() {
- $scope.clientEdit.attributes['id.token.encrypted.response.enc'] = $scope.idTokenEncryptedResponseEnc;
- };
- $scope.changeUserInfoSignedResponseAlg = function() {
- if ($scope.userInfoSignedResponseAlg === 'unsigned') {
- $scope.clientEdit.attributes['user.info.response.signature.alg'] = null;
- } else {
- $scope.clientEdit.attributes['user.info.response.signature.alg'] = $scope.userInfoSignedResponseAlg;
- }
- };
- $scope.changeRequestObjectSignatureAlg = function() {
- if ($scope.requestObjectSignatureAlg === 'any') {
- $scope.clientEdit.attributes['request.object.signature.alg'] = null;
- } else {
- $scope.clientEdit.attributes['request.object.signature.alg'] = $scope.requestObjectSignatureAlg;
- }
- };
- $scope.changeRequestObjectRequired = function() {
- if ($scope.requestObjectRequired === 'not required') {
- $scope.clientEdit.attributes['request.object.required'] = null;
- } else {
- $scope.clientEdit.attributes['request.object.required'] = $scope.requestObjectRequired;
- }
- };
- $scope.changeRequestObjectEncryptionAlg = function() {
- if ($scope.requestObjectEncryptionAlg === 'any') {
- $scope.clientEdit.attributes['request.object.encryption.alg'] = null;
- } else {
- $scope.clientEdit.attributes['request.object.encryption.alg'] = $scope.requestObjectEncryptionAlg;
- }
- };
- $scope.changeRequestObjectEncryptionEnc = function() {
- if ($scope.requestObjectEncryptionEnc === 'any') {
- $scope.clientEdit.attributes['request.object.encryption.enc'] = null;
- } else {
- $scope.clientEdit.attributes['request.object.encryption.enc'] = $scope.requestObjectEncryptionEnc;
- }
- };
- $scope.changePkceCodeChallengeMethod = function() {
- $scope.clientEdit.attributes['pkce.code.challenge.method'] = $scope.pkceCodeChallengeMethod;
- };
- $scope.changeCibaBackchannelAuthRequestSigningAlg = function() {
- if ($scope.cibaBackchannelAuthRequestSigningAlg === 'any') {
- $scope.clientEdit.attributes['ciba.backchannel.auth.request.signing.alg'] = null;
- } else {
- $scope.clientEdit.attributes['ciba.backchannel.auth.request.signing.alg'] = $scope.cibaBackchannelAuthRequestSigningAlg;
- }
- };
- $scope.changeCibaBackchannelTokenDeliveryMode = function() {
- $scope.clientEdit.attributes['ciba.backchannel.token.delivery.mode'] = $scope.cibaBackchannelTokenDeliveryMode;
- };
- $scope.changeAuthorizationSignedResponseAlg = function() {
- $scope.clientEdit.attributes['authorization.signed.response.alg'] = $scope.authorizationSignedResponseAlg;
- };
- $scope.changeAuthorizationEncryptedResponseAlg = function() {
- $scope.clientEdit.attributes['authorization.encrypted.response.alg'] = $scope.authorizationEncryptedResponseAlg;
- };
- $scope.changeAuthorizationEncryptedResponseEnc = function() {
- $scope.clientEdit.attributes['authorization.encrypted.response.enc'] = $scope.authorizationEncryptedResponseEnc;
- };
- $scope.$watch(function() {
- return $location.path();
- }, function() {
- $scope.path = $location.path().substring(1).split("/");
- });
- function isChanged() {
- if (!angular.equals($scope.client, $scope.clientEdit)) {
- return true;
- }
- if ($scope.newRedirectUri && $scope.newRedirectUri.length > 0) {
- return true;
- }
- if ($scope.newWebOrigin && $scope.newWebOrigin.length > 0) {
- return true;
- }
- if ($scope.newRequestUri && $scope.newRequestUri.length > 0) {
- return true;
- }
- return false;
- }
- $scope.updateTimeouts = function() {
- if ($scope.accessTokenLifespan.time) {
- if ($scope.accessTokenLifespan.time === -1) {
- $scope.clientEdit.attributes['access.token.lifespan'] = -1;
- } else {
- $scope.clientEdit.attributes['access.token.lifespan'] = $scope.accessTokenLifespan.toSeconds();
- }
- } else {
- $scope.clientEdit.attributes['access.token.lifespan'] = null;
- }
- }
- $scope.updateAssertionLifespan = function() {
- if ($scope.samlAssertionLifespan.time) {
- $scope.clientEdit.attributes['saml.assertion.lifespan'] = $scope.samlAssertionLifespan.toSeconds();
- } else {
- $scope.clientEdit.attributes['saml.assertion.lifespan'] = null;
- }
- }
- $scope.updateClientSessionIdleTimeout = function() {
- if ($scope.clientSessionIdleTimeout.time) {
- $scope.clientEdit.attributes['client.session.idle.timeout'] = $scope.clientSessionIdleTimeout.toSeconds();
- } else {
- $scope.clientEdit.attributes['client.session.idle.timeout'] = null;
- }
- }
- $scope.updateClientSessionMaxLifespan = function() {
- if ($scope.clientSessionMaxLifespan.time) {
- $scope.clientEdit.attributes['client.session.max.lifespan'] = $scope.clientSessionMaxLifespan.toSeconds();
- } else {
- $scope.clientEdit.attributes['client.session.max.lifespan'] = null;
- }
- }
- $scope.updateClientOfflineSessionIdleTimeout = function() {
- if ($scope.clientOfflineSessionIdleTimeout.time) {
- $scope.clientEdit.attributes['client.offline.session.idle.timeout'] = $scope.clientOfflineSessionIdleTimeout.toSeconds();
- } else {
- $scope.clientEdit.attributes['client.offline.session.idle.timeout'] = null;
- }
- }
- $scope.updateClientOfflineSessionMaxLifespan = function() {
- if ($scope.clientOfflineSessionMaxLifespan.time) {
- $scope.clientEdit.attributes['client.offline.session.max.lifespan'] = $scope.clientOfflineSessionMaxLifespan.toSeconds();
- } else {
- $scope.clientEdit.attributes['client.offline.session.max.lifespan'] = null;
- }
- }
- $scope.updateOauth2DeviceCodeLifespan = function() {
- if ($scope.oauth2DeviceCodeLifespan.time) {
- $scope.clientEdit.attributes['oauth2.device.code.lifespan'] = $scope.oauth2DeviceCodeLifespan.toSeconds();
- } else {
- $scope.clientEdit.attributes['oauth2.device.code.lifespan'] = null;
- }
- }
- $scope.updateOauth2DevicePollingInterval = function() {
- if ($scope.oauth2DevicePollingInterval) {
- $scope.clientEdit.attributes['oauth2.device.polling.interval'] = $scope.oauth2DevicePollingInterval;
- } else {
- $scope.clientEdit.attributes['oauth2.device.polling.interval'] = null;
- }
- }
- $scope.confirmChangeAuthzSettings = function($event) {
- if ($scope.client.authorizationServicesEnabled && $scope.clientEdit.authorizationServicesEnabled) {
- $event.preventDefault();
- Dialog.confirm("Disable Authorization Settings", "Are you sure you want to disable authorization ? Once you save your changes, all authorization settings associated with this client will be removed. This operation can not be reverted.", function () {
- $scope.clientEdit.authorizationServicesEnabled = false;
- }, function () {
- $scope.clientEdit.authorizationServicesEnabled = true;
- });
- }
- }
- function configureAuthorizationServices() {
- if ($scope.clientEdit.authorizationServicesEnabled) {
- if ($scope.accessType == 'public') {
- $scope.accessType = 'confidential';
- }
- $scope.clientEdit.publicClient = false;
- $scope.clientEdit.serviceAccountsEnabled = true;
- } else if ($scope.clientEdit.bearerOnly) {
- $scope.clientEdit.serviceAccountsEnabled = false;
- }
- }
- $scope.$watch('clientEdit', function() {
- $scope.changed = isChanged();
- configureAuthorizationServices();
- }, true);
- $scope.$watch('newRedirectUri', function() {
- $scope.changed = isChanged();
- }, true);
- $scope.$watch('newWebOrigin', function() {
- $scope.changed = isChanged();
- }, true);
- $scope.$watch('newRequestUri', function() {
- $scope.changed = isChanged();
- }, true);
- $scope.deleteWebOrigin = function(index) {
- $scope.clientEdit.webOrigins.splice(index, 1);
- }
- $scope.addWebOrigin = function() {
- $scope.clientEdit.webOrigins.push($scope.newWebOrigin);
- $scope.newWebOrigin = "";
- }
- $scope.deleteRequestUri = function(index) {
- $scope.clientEdit.requestUris.splice(index, 1);
- }
- $scope.addRequestUri = function() {
- $scope.clientEdit.requestUris.push($scope.newRequestUri);
- $scope.newRequestUri = "";
- }
- $scope.deleteRedirectUri = function(index) {
- $scope.clientEdit.redirectUris.splice(index, 1);
- }
- $scope.addRedirectUri = function() {
- $scope.clientEdit.redirectUris.push($scope.newRedirectUri);
- $scope.newRedirectUri = "";
- }
- $scope.save = function() {
- if ($scope.newRedirectUri && $scope.newRedirectUri.length > 0) {
- $scope.addRedirectUri();
- }
- if ($scope.newWebOrigin && $scope.newWebOrigin.length > 0) {
- $scope.addWebOrigin();
- }
- if ($scope.newRequestUri && $scope.newRequestUri.length > 0) {
- $scope.addRequestUri();
- }
- if ($scope.clientEdit.requestUris && $scope.clientEdit.requestUris.length > 0) {
- $scope.clientEdit.attributes["request.uris"] = $scope.clientEdit.requestUris.join("##");
- } else {
- $scope.clientEdit.attributes["request.uris"] = null;
- }
- if (!$scope.clientEdit.frontchannelLogout) {
- $scope.clientEdit.attributes["frontchannel.logout.url"] = null;
- }
- delete $scope.clientEdit.requestUris;
- if ($scope.samlArtifactBinding == true) {
- $scope.clientEdit.attributes["saml.artifact.binding"] = "true";
- } else {
- $scope.clientEdit.attributes["saml.artifact.binding"] = "false";
- }
- if ($scope.samlServerSignature == true) {
- $scope.clientEdit.attributes["saml.server.signature"] = "true";
- } else {
- $scope.clientEdit.attributes["saml.server.signature"] = "false";
- }
- if ($scope.samlServerSignatureEnableKeyInfoExtension == true) {
- $scope.clientEdit.attributes["saml.server.signature.keyinfo.ext"] = "true";
- } else {
- $scope.clientEdit.attributes["saml.server.signature.keyinfo.ext"] = "false";
- }
- if ($scope.samlAssertionSignature == true) {
- $scope.clientEdit.attributes["saml.assertion.signature"] = "true";
- } else {
- $scope.clientEdit.attributes["saml.assertion.signature"] = "false";
- }
- if ($scope.samlClientSignature == true) {
- $scope.clientEdit.attributes["saml.client.signature"] = "true";
- } else {
- $scope.clientEdit.attributes["saml.client.signature"] = "false";
- }
- if ($scope.samlEncrypt == true) {
- $scope.clientEdit.attributes["saml.encrypt"] = "true";
- } else {
- $scope.clientEdit.attributes["saml.encrypt"] = "false";
- }
- if ($scope.samlAuthnStatement == true) {
- $scope.clientEdit.attributes["saml.authnstatement"] = "true";
- } else {
- $scope.clientEdit.attributes["saml.authnstatement"] = "false";
- }
- if ($scope.samlOneTimeUseCondition == true) {
- $scope.clientEdit.attributes["saml.onetimeuse.condition"] = "true";
- } else {
- $scope.clientEdit.attributes["saml.onetimeuse.condition"] = "false";
- }
- if ($scope.samlForceNameIdFormat == true) {
- $scope.clientEdit.attributes["saml_force_name_id_format"] = "true";
- } else {
- $scope.clientEdit.attributes["saml_force_name_id_format"] = "false";
- }
- if ($scope.samlMultiValuedRoles == true) {
- $scope.clientEdit.attributes["saml.multivalued.roles"] = "true";
- } else {
- $scope.clientEdit.attributes["saml.multivalued.roles"] = "false";
- }
- if ($scope.samlForcePostBinding == true) {
- $scope.clientEdit.attributes["saml.force.post.binding"] = "true";
- } else {
- $scope.clientEdit.attributes["saml.force.post.binding"] = "false";
- }
- if ($scope.excludeSessionStateFromAuthResponse == true) {
- $scope.clientEdit.attributes["exclude.session.state.from.auth.response"] = "true";
- } else {
- $scope.clientEdit.attributes["exclude.session.state.from.auth.response"] = "false";
- }
- if ($scope.oauth2DeviceAuthorizationGrantEnabled == true) {
- $scope.clientEdit.attributes["oauth2.device.authorization.grant.enabled"] = "true";
- } else {
- $scope.clientEdit.attributes["oauth2.device.authorization.grant.enabled"] = "false";
- }
- if ($scope.oidcCibaGrantEnabled == true) {
- $scope.clientEdit.attributes["oidc.ciba.grant.enabled"] = "true";
- } else {
- $scope.clientEdit.attributes["oidc.ciba.grant.enabled"] = "false";
- }
- if ($scope.useRefreshTokens == true) {
- $scope.clientEdit.attributes["use.refresh.tokens"] = "true";
- } else {
- $scope.clientEdit.attributes["use.refresh.tokens"] = "false";
- }
- if ($scope.useIdTokenAsDetachedSignature == true) {
- $scope.clientEdit.attributes["id.token.as.detached.signature"] = "true";
- } else {
- $scope.clientEdit.attributes["id.token.as.detached.signature"] = "false";
- }
- // KEYCLOAK-6771 Certificate Bound Token
- // https://tools.ietf.org/html/draft-ietf-oauth-mtls-08#section-3
- if ($scope.tlsClientCertificateBoundAccessTokens == true) {
- $scope.clientEdit.attributes["tls.client.certificate.bound.access.tokens"] = "true";
- } else {
- $scope.clientEdit.attributes["tls.client.certificate.bound.access.tokens"] = "false";
- }
- // PAR request.
- if ($scope.requirePushedAuthorizationRequests == true) {
- $scope.clientEdit.attributes["require.pushed.authorization.requests"] = "true";
- } else {
- $scope.clientEdit.attributes["require.pushed.authorization.requests"] = "false";
- }
- // KEYCLOAK-9551 Client Credentials Grant generates refresh token
- // https://tools.ietf.org/html/rfc6749#section-4.4.3
- if ($scope.useRefreshTokenForClientCredentialsGrant === true) {
- $scope.clientEdit.attributes["client_credentials.use_refresh_token"] = "true";
- } else {
- $scope.clientEdit.attributes["client_credentials.use_refresh_token"] = "false";
- }
- if ($scope.displayOnConsentScreen == true) {
- $scope.clientEdit.attributes["display.on.consent.screen"] = "true";
- } else {
- $scope.clientEdit.attributes["display.on.consent.screen"] = "false";
- }
- if ($scope.backchannelLogoutSessionRequired == true) {
- $scope.clientEdit.attributes["backchannel.logout.session.required"] = "true";
- } else {
- $scope.clientEdit.attributes["backchannel.logout.session.required"] = "false";
- }
- if ($scope.backchannelLogoutRevokeOfflineSessions == true) {
- $scope.clientEdit.attributes["backchannel.logout.revoke.offline.tokens"] = "true";
- } else {
- $scope.clientEdit.attributes["backchannel.logout.revoke.offline.tokens"] = "false";
- }
- $scope.clientEdit.protocol = $scope.protocol;
- $scope.clientEdit.attributes['saml.signature.algorithm'] = $scope.signatureAlgorithm;
- $scope.clientEdit.attributes['saml_name_id_format'] = $scope.nameIdFormat;
- if ($scope.clientEdit.protocol != 'saml' && !$scope.clientEdit.bearerOnly && ($scope.clientEdit.standardFlowEnabled || $scope.clientEdit.implicitFlowEnabled) && (!$scope.clientEdit.redirectUris || $scope.clientEdit.redirectUris.length == 0)) {
- Notifications.error("You must specify at least one redirect uri");
- } else {
- Client.update({
- realm : realm.realm,
- client : client.id
- }, $scope.clientEdit, function() {
- $route.reload();
- Notifications.success("Your changes have been saved to the client.");
- });
- }
- };
- $scope.reset = function() {
- $route.reload();
- };
- $scope.cancel = function() {
- $location.url("/realms/" + realm.realm + "/clients");
- };
- });
- module.controller('CreateClientCtrl', function($scope, realm, client, $route, serverInfo, Client, ClientDescriptionConverter, $location, $modal, Dialog, Notifications) {
- $scope.protocols = serverInfo.listProviderIds('login-protocol');
- $scope.create = true;
- $scope.realm = realm;
- $scope.client = {
- enabled: true,
- attributes: {}
- };
- $scope.client.redirectUris = [];
- $scope.protocol = $scope.protocols[0];
- $scope.importFile = function(fileContent){
- console.debug(fileContent);
- ClientDescriptionConverter.save({
- realm: realm.realm
- }, fileContent, function (data) {
- $scope.client = data;
- if (data.protocol) {
- $scope.protocol = data.protocol;
- }
- $scope.importing = true;
- });
- };
- $scope.viewImportDetails = function() {
- $modal.open({
- templateUrl: resourceUrl + '/partials/modal/view-object.html',
- controller: 'ObjectModalCtrl',
- resolve: {
- object: function () {
- return $scope.client;
- }
- }
- })
- };
- $scope.switchChange = function() {
- $scope.changed = true;
- }
- $scope.changeProtocol = function() {
- if ($scope.protocol == "openid-connect") {
- $scope.client.protocol = "openid-connect";
- } else if ($scope.protocol == "saml") {
- $scope.client.protocol = "saml";
- }
- };
- $scope.$watch(function() {
- return $location.path();
- }, function() {
- $scope.path = $location.path().substring(1).split("/");
- });
- function isChanged() {
- if (!angular.equals($scope.client, client)) {
- return true;
- }
- return false;
- }
- $scope.$watch('client', function() {
- $scope.changed = isChanged();
- }, true);
- $scope.save = function() {
- $scope.client.protocol = $scope.protocol;
- Client.save({
- realm: realm.realm,
- client: ''
- }, $scope.client, function (data, headers) {
- $scope.changed = false;
- var l = headers().location;
- var id = l.substring(l.lastIndexOf("/") + 1);
- $location.url("/realms/" + realm.realm + "/clients/" + id);
- Notifications.success("The client has been created.");
- });
- };
- $scope.reset = function() {
- $route.reload();
- };
- $scope.cancel = function() {
- $location.url("/realms/" + realm.realm + "/clients");
- };
- });
- module.controller('ClientScopeMappingCtrl', function($scope, $http, realm, $route, client, clients, Notifications,
- Client, ClientScope,
- ClientRealmScopeMapping, ClientClientScopeMapping, ClientRole,
- ClientAvailableRealmScopeMapping, ClientAvailableClientScopeMapping,
- ClientCompositeRealmScopeMapping, ClientCompositeClientScopeMapping) {
- $scope.realm = realm;
- $scope.client = angular.copy(client);
- $scope.selectedRealmRoles = [];
- $scope.selectedRealmMappings = [];
- $scope.realmMappings = [];
- $scope.clients = clients;
- $scope.clientRoles = [];
- $scope.clientComposite = [];
- $scope.selectedClientRoles = [];
- $scope.selectedClientMappings = [];
- $scope.clientMappings = [];
- $scope.dummymodel = [];
- $scope.hideRoleSelector = function() {
- return $scope.client.fullScopeAllowed;
- }
- $scope.changeFlag = function() {
- console.log('changeFlag');
- Client.update({
- realm : realm.realm,
- client : client.id
- }, $scope.client, function() {
- $scope.changed = false;
- client = angular.copy($scope.client);
- updateRealmRoles();
- Notifications.success("Scope mappings updated.");
- });
- }
-
- $scope.selectedClient = null;
- $scope.selectClient = function(client) {
- if (!client || !client.id) {
- $scope.selectedClient = null;
- return;
- }
- $scope.selectedClient = client;
- updateClientRoles();
- }
- function updateRealmRoles() {
- $scope.realmRoles = ClientAvailableRealmScopeMapping.query({realm : realm.realm, client : client.id});
- $scope.realmMappings = ClientRealmScopeMapping.query({realm : realm.realm, client : client.id});
- $scope.realmComposite = ClientCompositeRealmScopeMapping.query({realm : realm.realm, client : client.id});
- }
- function updateClientRoles() {
- if ($scope.selectedClient) {
- $scope.clientRoles = ClientAvailableClientScopeMapping.query({realm : realm.realm, client : client.id, targetClient : $scope.selectedClient.id});
- $scope.clientMappings = ClientClientScopeMapping.query({realm : realm.realm, client : client.id, targetClient : $scope.selectedClient.id});
- $scope.clientComposite = ClientCompositeClientScopeMapping.query({realm : realm.realm, client : client.id, targetClient : $scope.selectedClient.id});
- } else {
- $scope.clientRoles = null;
- $scope.clientMappings = null;
- $scope.clientComposite = null;
- }
- }
- $scope.addRealmRole = function() {
- $scope.selectedRealmRolesToAdd = JSON.parse('[' + $scope.selectedRealmRoles + ']');
- $scope.selectedRealmRoles = [];
- $http.post(authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id + '/scope-mappings/realm',
- $scope.selectedRealmRolesToAdd).then(function() {
- updateRealmRoles();
- $scope.selectedRealmRolesToAdd = [];
- Notifications.success("Scope mappings updated.");
- });
- };
- $scope.deleteRealmRole = function() {
- $scope.selectedRealmMappingsToRemove = JSON.parse('[' + $scope.selectedRealmMappings + ']');
- $scope.selectedRealmMappings = [];
- $http.delete(authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id + '/scope-mappings/realm',
- {data : $scope.selectedRealmMappingsToRemove, headers : {"content-type" : "application/json"}}).then(function () {
- updateRealmRoles();
- $scope.selectedRealmMappingsToRemove = [];
- Notifications.success("Scope mappings updated.");
- });
- };
- $scope.addClientRole = function() {
- $scope.selectedClientRolesToAdd = JSON.parse('[' + $scope.selectedClientRoles + ']');
- $scope.selectedClientRoles = [];
- $http.post(authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id + '/scope-mappings/clients/' + $scope.selectedClient.id,
- $scope.selectedClientRolesToAdd).then(function () {
- updateClientRoles();
- $scope.selectedClientRolesToAdd = [];
- Notifications.success("Scope mappings updated.");
- });
- };
- $scope.deleteClientRole = function() {
- $scope.selectedClientMappingsToRemove = JSON.parse('[' + $scope.selectedClientMappings + ']');
- $scope.selectedClientMappings = [];
- $http.delete(authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id + '/scope-mappings/clients/' + $scope.selectedClient.id,
- {data : $scope.selectedClientMappingsToRemove, headers : {"content-type" : "application/json"}}).then(function () {
- updateClientRoles();
- $scope.selectedClientMappingsToRemove = [];
- Notifications.success("Scope mappings updated.");
- });
- };
- clientSelectControl($scope, $route.current.params.realm, Client);
- updateRealmRoles();
- });
- module.controller('ClientRevocationCtrl', function($scope, realm, client, Client, ClientPushRevocation, $location, Dialog, Notifications) {
- $scope.realm = realm;
- $scope.client = client;
- var setNotBefore = function() {
- if ($scope.client.notBefore == 0) {
- $scope.notBefore = "None";
- } else {
- $scope.notBefore = new Date($scope.client.notBefore * 1000);
- }
- };
- setNotBefore();
- var refresh = function() {
- Client.get({ realm : realm.realm, client: $scope.client.id }, function(updated) {
- $scope.client = updated;
- setNotBefore();
- })
- };
- $scope.clear = function() {
- $scope.client.notBefore = 0;
- Client.update({ realm : realm.realm, client: client.id}, $scope.client, function () {
- $scope.notBefore = "None";
- Notifications.success('Not Before cleared for client.');
- refresh();
- });
- }
- $scope.setNotBeforeNow = function() {
- $scope.client.notBefore = new Date().getTime()/1000;
- Client.update({ realm : realm.realm, client: $scope.client.id}, $scope.client, function () {
- Notifications.success('Not Before set for client.');
- refresh();
- });
- }
- $scope.pushRevocation = function() {
- ClientPushRevocation.save({realm : realm.realm, client: $scope.client.id}, function (globalReqResult) {
- var successCount = globalReqResult.successRequests ? globalReqResult.successRequests.length : 0;
- var failedCount = globalReqResult.failedRequests ? globalReqResult.failedRequests.length : 0;
- if (successCount==0 && failedCount==0) {
- Notifications.warn('No push sent. No admin URI configured or no registered cluster nodes available');
- } else if (failedCount > 0) {
- var msgStart = successCount>0 ? 'Successfully push notBefore to: ' + globalReqResult.successRequests + ' . ' : '';
- Notifications.error(msgStart + 'Failed to push notBefore to: ' + globalReqResult.failedRequests + '. Verify availability of failed hosts and try again');
- } else {
- Notifications.success('Successfully push notBefore to: ' + globalReqResult.successRequests);
- }
- });
- }
- });
- module.controller('ClientClusteringCtrl', function($scope, client, Client, ClientTestNodesAvailable, ClientClusterNode, realm, $location, $route, Dialog, Notifications, TimeUnit) {
- $scope.client = client;
- $scope.realm = realm;
- var oldCopy = angular.copy($scope.client);
- $scope.changed = false;
- $scope.$watch('client', function() {
- if (!angular.equals($scope.client, oldCopy)) {
- $scope.changed = true;
- }
- }, true);
- $scope.client.nodeReRegistrationTimeoutUnit = TimeUnit.autoUnit(client.nodeReRegistrationTimeout);
- $scope.client.nodeReRegistrationTimeout = TimeUnit.toUnit(client.nodeReRegistrationTimeout, $scope.client.nodeReRegistrationTimeoutUnit);
- $scope.save = function() {
- var clientCopy = angular.copy($scope.client);
- delete clientCopy['nodeReRegistrationTimeoutUnit'];
- clientCopy.nodeReRegistrationTimeout = TimeUnit.toSeconds($scope.client.nodeReRegistrationTimeout, $scope.client.nodeReRegistrationTimeoutUnit)
- Client.update({ realm : realm.realm, client : client.id }, clientCopy, function () {
- $route.reload();
- Notifications.success('Your changes have been saved to the client.');
- });
- };
- $scope.reset = function() {
- $route.reload();
- };
- $scope.testNodesAvailable = function() {
- ClientTestNodesAvailable.get({ realm : realm.realm, client : client.id }, function(globalReqResult) {
- $route.reload();
- var successCount = globalReqResult.successRequests ? globalReqResult.successRequests.length : 0;
- var failedCount = globalReqResult.failedRequests ? globalReqResult.failedRequests.length : 0;
- if (successCount==0 && failedCount==0) {
- Notifications.warn('No requests sent. No admin URI configured or no registered cluster nodes available');
- } else if (failedCount > 0) {
- var msgStart = successCount>0 ? 'Successfully verify availability for ' + globalReqResult.successRequests + ' . ' : '';
- Notifications.error(msgStart + 'Failed to verify availability for: ' + globalReqResult.failedRequests + '. Fix or unregister failed cluster nodes and try again');
- } else {
- Notifications.success('Successfully sent requests to: ' + globalReqResult.successRequests);
- }
- });
- };
- if (client.registeredNodes) {
- var nodeRegistrations = [];
- for (node in client.registeredNodes) {
- reg = {
- host: node,
- lastRegistration: new Date(client.registeredNodes[node] * 1000)
- }
- nodeRegistrations.push(reg);
- }
- $scope.nodeRegistrations = nodeRegistrations;
- };
- $scope.removeNode = function(node) {
- Dialog.confirmDelete(node.host, 'node', function() {
- ClientClusterNode.remove({ realm : realm.realm, client : client.id , node: node.host }, function() {
- Notifications.success('Node ' + node.host + ' unregistered successfully.');
- $route.reload();
- });
- });
- };
- });
- module.controller('ClientClusteringNodeCtrl', function($scope, client, Client, ClientClusterNode, realm,
- $location, $routeParams, Notifications, Dialog) {
- $scope.client = client;
- $scope.realm = realm;
- $scope.create = !$routeParams.node;
- $scope.save = function() {
- ClientClusterNode.save({ realm : realm.realm, client : client.id , node: $scope.node.host }, function() {
- Notifications.success('Node ' + $scope.node.host + ' registered successfully.');
- $location.url('/realms/' + realm.realm + '/clients/' + client.id + '/clustering');
- });
- }
- $scope.unregisterNode = function() {
- Dialog.confirmDelete($scope.node.host, 'node', function() {
- ClientClusterNode.remove({ realm : realm.realm, client : client.id , node: $scope.node.host }, function() {
- Notifications.success('Node ' + $scope.node.host + ' unregistered successfully.');
- $location.url('/realms/' + realm.realm + '/clients/' + client.id + '/clustering');
- });
- });
- }
- if ($scope.create) {
- $scope.node = {}
- $scope.registered = false;
- } else {
- var lastRegTime = client.registeredNodes[$routeParams.node];
- if (lastRegTime) {
- $scope.registered = true;
- $scope.node = {
- host: $routeParams.node,
- lastRegistration: new Date(lastRegTime * 1000)
- }
- } else {
- $scope.registered = false;
- $scope.node = {
- host: $routeParams.node
- }
- }
- }
- });
- module.controller('AddBuiltinProtocolMapperCtrl', function($scope, realm, client, serverInfo,
- ClientProtocolMappersByProtocol,
- $http, $location, Dialog, Notifications) {
- $scope.realm = realm;
- $scope.client = client;
- if (client.protocol == null) {
- client.protocol = 'openid-connect';
- }
- var protocolMappers = serverInfo.protocolMapperTypes[client.protocol];
- var mapperTypes = {};
- for (var i = 0; i < protocolMappers.length; i++) {
- mapperTypes[protocolMappers[i].id] = protocolMappers[i];
- }
- $scope.mapperTypes = mapperTypes;
- var updateMappers = function() {
- var clientMappers = ClientProtocolMappersByProtocol.query({realm : realm.realm, client : client.id, protocol : client.protocol}, function() {
- var builtinMappers = serverInfo.builtinProtocolMappers[client.protocol];
- for (var i = 0; i < clientMappers.length; i++) {
- for (var j = 0; j < builtinMappers.length; j++) {
- if (builtinMappers[j].name == clientMappers[i].name
- && builtinMappers[j].protocolMapper == clientMappers[i].protocolMapper) {
- builtinMappers.splice(j, 1);
- break;
- }
- }
- }
- $scope.mappers = builtinMappers;
- for (var i = 0; i < $scope.mappers.length; i++) {
- $scope.mappers[i].isChecked = false;
- }
- });
- };
- updateMappers();
- $scope.add = function() {
- var toAdd = [];
- for (var i = 0; i < $scope.mappers.length; i++) {
- if ($scope.mappers[i].isChecked) {
- delete $scope.mappers[i].isChecked;
- toAdd.push($scope.mappers[i]);
- }
- }
- $http.post(authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id + '/protocol-mappers/add-models',
- toAdd).then(function() {
- Notifications.success("Mappers added");
- $location.url('/realms/' + realm.realm + '/clients/' + client.id + '/mappers');
- }).catch(function() {
- Notifications.error("Error adding mappers");
- $location.url('/realms/' + realm.realm + '/clients/' + client.id + '/mappers');
- });
- };
- });
- module.controller('ClientProtocolMapperListCtrl', function($scope, realm, client, serverInfo,
- Client,
- ClientProtocolMappersByProtocol, ClientProtocolMapper,
- $route, Dialog, Notifications) {
- $scope.realm = realm;
- $scope.client = client;
- if (client.protocol == null) {
- client.protocol = 'openid-connect';
- }
- $scope.changeFlag = function() {
- Client.update({
- realm : realm.realm,
- client : client.id
- }, $scope.client, function() {
- $scope.changed = false;
- client = angular.copy($scope.client);
- Notifications.success("Client updated.");
- });
- }
- var protocolMappers = serverInfo.protocolMapperTypes[client.protocol];
- var mapperTypes = {};
- for (var i = 0; i < protocolMappers.length; i++) {
- mapperTypes[protocolMappers[i].id] = protocolMappers[i];
- }
- $scope.mapperTypes = mapperTypes;
- $scope.removeMapper = function(mapper) {
- console.debug(mapper);
- Dialog.confirmDelete(mapper.name, 'mapper', function() {
- ClientProtocolMapper.remove({ realm: realm.realm, client: client.id, id : mapper.id }, function() {
- Notifications.success("The mapper has been deleted.");
- $route.reload();
- });
- });
- };
- $scope.sortMappersByPriority = function(mapper) {
- return $scope.mapperTypes[mapper.protocolMapper].priority;
- }
- var updateMappers = function() {
- $scope.mappers = ClientProtocolMappersByProtocol.query({realm : realm.realm, client : client.id, protocol : client.protocol});
- };
- updateMappers();
- });
- module.controller('ClientProtocolMapperCtrl', function($scope, realm, serverInfo, client, clients, mapper, ClientProtocolMapper, Notifications, Dialog, $location) {
- $scope.realm = realm;
- $scope.clients = clients;
- /*
- $scope.client = client;
- $scope.create = false;
- $scope.protocol = client.protocol;
- $scope.mapper = angular.copy(mapper);
- $scope.changed = false;
- */
- if (client.protocol == null) {
- client.protocol = 'openid-connect';
- }
- $scope.model = {
- realm: realm,
- client: client,
- create: false,
- protocol: client.protocol,
- mapper: angular.copy(mapper),
- changed: false
- };
- var protocolMappers = serverInfo.protocolMapperTypes[client.protocol];
- for (var i = 0; i < protocolMappers.length; i++) {
- if (protocolMappers[i].id === mapper.protocolMapper) {
- $scope.model.mapperType = protocolMappers[i];
- }
- }
- $scope.$watch(function() {
- return $location.path();
- }, function() {
- $scope.path = $location.path().substring(1).split("/");
- });
- $scope.$watch('model.mapper', function() {
- if (!angular.equals($scope.model.mapper, mapper)) {
- $scope.model.changed = true;
- }
- }, true);
- $scope.save = function() {
- ClientProtocolMapper.update({
- realm : realm.realm,
- client: client.id,
- id : $scope.model.mapper.id
- }, $scope.model.mapper, function() {
- $scope.model.changed = false;
- mapper = angular.copy($scope.mapper);
- $location.url("/realms/" + realm.realm + '/clients/' + client.id + "/mappers/" + $scope.model.mapper.id);
- Notifications.success("Your changes have been saved.");
- });
- };
- $scope.reset = function() {
- $scope.model.mapper = angular.copy(mapper);
- $scope.model.changed = false;
- };
- $scope.cancel = function() {
- //$location.url("/realms");
- window.history.back();
- };
- $scope.remove = function() {
- Dialog.confirmDelete($scope.model.mapper.name, 'mapper', function() {
- ClientProtocolMapper.remove({ realm: realm.realm, client: client.id, id : $scope.model.mapper.id }, function() {
- Notifications.success("The mapper has been deleted.");
- $location.url("/realms/" + realm.realm + '/clients/' + client.id + "/mappers");
- });
- });
- };
- });
- module.controller('ClientProtocolMapperCreateCtrl', function($scope, realm, serverInfo, client, clients, ClientProtocolMapper, Notifications, Dialog, $location) {
- $scope.realm = realm;
- $scope.clients = clients;
- if (client.protocol == null) {
- client.protocol = 'openid-connect';
- }
- var protocol = client.protocol;
- /*
- $scope.client = client;
- $scope.create = true;
- $scope.protocol = protocol;
- $scope.mapper = { protocol : client.protocol, config: {}};
- $scope.mapperTypes = serverInfo.protocolMapperTypes[protocol];
- */
- $scope.model = {
- realm: realm,
- client: client,
- create: true,
- protocol: client.protocol,
- mapper: { protocol : client.protocol, config: {}},
- changed: false,
- mapperTypes: serverInfo.protocolMapperTypes[protocol]
- };
- console.log("mapper types: ", $scope.model.mapperTypes);
- // apply default configurations on change for selected protocolmapper type.
- $scope.$watch('model.mapperType', function() {
- var currentMapperType = $scope.model.mapperType;
- var defaultConfig = {};
- if (currentMapperType && Array.isArray(currentMapperType.properties)) {
- for (var i = 0; i < currentMapperType.properties.length; i++) {
- var property = currentMapperType.properties[i];
- if (property && property.name && property.defaultValue) {
- defaultConfig[property.name] = property.defaultValue;
- }
- }
- }
- $scope.model.mapper.config = defaultConfig;
- }, true);
- $scope.model.mapperType = $scope.model.mapperTypes[0];
- $scope.$watch(function() {
- return $location.path();
- }, function() {
- $scope.path = $location.path().substring(1).split("/");
- });
- $scope.save = function() {
- $scope.model.mapper.protocolMapper = $scope.model.mapperType.id;
- ClientProtocolMapper.save({
- realm : realm.realm, client: client.id
- }, $scope.model.mapper, function(data, headers) {
- var l = headers().location;
- var id = l.substring(l.lastIndexOf("/") + 1);
- $location.url("/realms/" + realm.realm + '/clients/' + client.id + "/mappers/" + id);
- Notifications.success("Mapper has been created.");
- });
- };
- $scope.cancel = function() {
- //$location.url("/realms");
- window.history.back();
- };
- });
- module.controller('ClientClientScopesSetupCtrl', function($scope, realm, Realm, client, clientScopes, serverInfo,
- clientDefaultClientScopes, ClientDefaultClientScopes, clientOptionalClientScopes, ClientOptionalClientScopes, $route, Notifications, $location) {
- console.log('ClientClientScopesSetupCtrl');
- $scope.realm = realm;
- $scope.client = client;
- $scope.clientDefaultClientScopes = clientDefaultClientScopes;
- $scope.clientOptionalClientScopes = clientOptionalClientScopes;
- $scope.availableClientScopes = [];
- $scope.selectedDefaultClientScopes = [];
- $scope.selectedDefDefaultClientScopes = [];
- $scope.selectedOptionalClientScopes = [];
- $scope.selectedDefOptionalClientScopes = [];
- // Populate available client scopes. Available client scopes are neither already assigned to 'default' or 'optional'
- for (var i = 0; i < clientScopes.length; i++) {
- var clientScope = clientScopes[i];
- var scopeName = clientScopes[i].name;
- var available = true;
- if (clientScope.protocol != client.protocol) {
- available = false;
- }
- for (var j = 0; j < $scope.clientDefaultClientScopes.length; j++) {
- if (scopeName === $scope.clientDefaultClientScopes[j].name) {
- available = false;
- }
- }
- for (var j = 0; j < $scope.clientOptionalClientScopes.length; j++) {
- if (scopeName === $scope.clientOptionalClientScopes[j].name) {
- available = false;
- }
- }
- if (available) {
- $scope.availableClientScopes.push(clientScope);
- }
- }
- $scope.addDefaultClientScope = function () {
- $scope.selectedDefaultClientScopesToAdd = JSON.parse('[' + $scope.selectedDefaultClientScopes + ']');
- toAdd = $scope.selectedDefaultClientScopesToAdd.length;
- for (var i = 0; i < $scope.selectedDefaultClientScopesToAdd.length; i++) {
- var currentScope = $scope.selectedDefaultClientScopesToAdd[i];
- ClientDefaultClientScopes.update({
- realm : realm.realm,
- client : client.id,
- clientScopeId : currentScope.id
- }, function () {
- toAdd = toAdd - 1;
- if (toAdd === 0) {
- $route.reload();
- Notifications.success("Default scopes updated.");
- }
- });
- }
- $scope.selectedDefaultClientScopesToAdd = [];
- };
- $scope.deleteDefaultClientScope = function () {
- $scope.selectedDefDefaultClientScopesToRemove = JSON.parse('[' + $scope.selectedDefDefaultClientScopes + ']');
- toRemove = $scope.selectedDefDefaultClientScopesToRemove.length;
- for (var i = 0; i < $scope.selectedDefDefaultClientScopesToRemove.length; i++) {
- var currentScope = $scope.selectedDefDefaultClientScopesToRemove[i];
- ClientDefaultClientScopes.remove({
- realm : realm.realm,
- client : client.id,
- clientScopeId : currentScope.id
- }, function () {
- toRemove = toRemove - 1;
- if (toRemove === 0) {
- $route.reload();
- Notifications.success("Default scopes updated.");
- }
- });
- }
- $scope.selectedDefDefaultClientScopesToRemove = [];
- };
- $scope.addOptionalClientScope = function () {
- $scope.selectedOptionalClientScopesToAdd = JSON.parse('[' + $scope.selectedOptionalClientScopes + ']');
- toAdd = $scope.selectedOptionalClientScopesToAdd.length;
- for (var i = 0; i < $scope.selectedOptionalClientScopesToAdd.length; i++) {
- var currentScope = $scope.selectedOptionalClientScopesToAdd[i];
- ClientOptionalClientScopes.update({
- realm : realm.realm,
- client : client.id,
- clientScopeId : currentScope.id
- }, function () {
- toAdd = toAdd - 1;
- if (toAdd === 0) {
- $route.reload();
- Notifications.success("Optional scopes updated.");
- }
- });
- }
- };
- $scope.deleteOptionalClientScope = function () {
- $scope.selectedDefOptionalClientScopesToRemove = JSON.parse('[' + $scope.selectedDefOptionalClientScopes + ']');
- toRemove = $scope.selectedDefOptionalClientScopesToRemove.length;
- for (var i = 0; i < $scope.selectedDefOptionalClientScopesToRemove.length; i++) {
- var currentScope = $scope.selectedDefOptionalClientScopesToRemove[i];
- ClientOptionalClientScopes.remove({
- realm : realm.realm,
- client : client.id,
- clientScopeId : currentScope.id
- }, function () {
- toRemove = toRemove - 1;
- if (toRemove === 0) {
- $route.reload();
- Notifications.success("Optional scopes updated.");
- }
- });
- }
- $scope.selectedDefOptionalClientScopesToRemove = [];
- };
- });
- module.controller('ClientClientScopesEvaluateCtrl', function($scope, Realm, User, ClientEvaluateProtocolMappers, ClientEvaluateGrantedRoles,
- ClientEvaluateNotGrantedRoles, ClientEvaluateGenerateExampleAccessToken, ClientEvaluateGenerateExampleIDToken,
- ClientEvaluateGenerateExampleUserInfo, realm, client, clients, clientScopes, serverInfo, ComponentUtils,
- clientOptionalClientScopes, clientDefaultClientScopes, $route, $routeParams, $http, Notifications, $location,
- Client) {
- console.log('ClientClientScopesEvaluateCtrl');
- var protocolMappers = serverInfo.protocolMapperTypes[client.protocol];
- var mapperTypes = {};
- for (var i = 0; i < protocolMappers.length; i++) {
- mapperTypes[protocolMappers[i].id] = protocolMappers[i];
- }
- $scope.mapperTypes = mapperTypes;
- $scope.realm = realm;
- $scope.client = client;
- $scope.clients = clients;
- $scope.userId = null;
- $scope.availableClientScopes = [];
- $scope.assignedClientScopes = [];
- $scope.selectedClientScopes = [];
- $scope.selectedDefClientScopes = [];
- $scope.effectiveClientScopes = [];
- // Populate available client scopes. Available client scopes are neither already assigned to 'default' or 'optional'
- for (var i = 0; i < clientOptionalClientScopes.length; i++) {
- $scope.availableClientScopes.push(clientOptionalClientScopes[i]);
- }
- function clearEvalResponse() {
- $scope.protocolMappers = null;
- $scope.grantedRealmRoles = null;
- $scope.notGrantedRealmRoles = null;
- $scope.grantedClientRoles = null;
- $scope.notGrantedClientRoles = null;
- $scope.targetClient = null;
- $scope.oidcAccessToken = null;
- $scope.oidcIDToken = null;
- $scope.oidcUserInfo = null;
- $scope.selectedTab = 0;
- }
- function updateState() {
- // Compute scope parameter
- $scope.scopeParam = 'openid';
- for (var i = 0; i < $scope.assignedClientScopes.length; i++) {
- var currentScopeParam = $scope.assignedClientScopes[i].name;
- $scope.scopeParam = $scope.scopeParam + ' ' + currentScopeParam;
- }
- // Compute effective scopes
- $scope.effectiveClientScopes = [];
- for (var i = 0; i < clientDefaultClientScopes.length; i++) {
- var currentScope = clientDefaultClientScopes[i];
- $scope.effectiveClientScopes.push(currentScope);
- }
- for (var i = 0; i < $scope.assignedClientScopes.length; i++) {
- var currentScope = $scope.assignedClientScopes[i];
- $scope.effectiveClientScopes.push(currentScope);
- }
- // Clear the evaluation response
- clearEvalResponse();
- }
- updateState();
- $scope.addAppliedClientScope = function () {
- $scope.selectedClientScopesToAdd = JSON.parse('[' + $scope.selectedClientScopes + ']');
- for (var i = 0; i < $scope.selectedClientScopesToAdd.length; i++) {
- var currentScope = $scope.selectedClientScopesToAdd[i];
- $scope.assignedClientScopes.push(currentScope);
- var index = ComponentUtils.findIndexById($scope.availableClientScopes, currentScope.id);
- if (index > -1) {
- $scope.availableClientScopes.splice(index, 1);
- }
- }
- $scope.selectedClientScopes = [];
- $scope.selectedClientScopesToAdd = [];
- updateState();
- };
- $scope.deleteAppliedClientScope = function () {
- $scope.selectedDefClientScopesToRemove = JSON.parse('[' + $scope.selectedDefClientScopes + ']');
- for (var i = 0; i < $scope.selectedDefClientScopesToRemove.length; i++) {
- var currentScope = $scope.selectedDefClientScopesToRemove[i];
- $scope.availableClientScopes.push(currentScope);
- var index = ComponentUtils.findIndexById($scope.assignedClientScopes, currentScope.id);
- if (index > -1) {
- $scope.assignedClientScopes.splice(index, 1);
- }
- }
- $scope.selectedDefClientScopes = [];
- $scope.selectedDefClientScopesToRemove = [];
- updateState();
- };
- $scope.usersUiSelect = {
- minimumInputLength: 1,
- delay: 500,
- allowClear: true,
- query: function (query) {
- var data = {results: []};
- if ('' == query.term.trim()) {
- query.callback(data);
- return;
- }
- User.query({realm: $route.current.params.realm, search: query.term.trim(), max: 20}, function(response) {
- data.results = response;
- query.callback(data);
- });
- },
- formatResult: function(object, container, query) {
- object.text = object.username;
- return object.username;
- }
- };
- $scope.selectedUser = null;
- $scope.selectUser = function(user) {
- clearEvalResponse();
- if (!user || !user.id) {
- $scope.selectedUser = null;
- $scope.userId = '';
- return;
- }
- $scope.userId = user.id;
- }
- clientSelectControl($scope, $route.current.params.realm, Client);
-
- $scope.selectedClient = null;
- $scope.selectClient = function(client) {
- console.log("selected client: ", client);
- if (!client || !client.id) {
- $scope.selectedClient = null;
- return;
- }
- $scope.selectedClient = client;
- updateScopeClientRoles();
- }
- $scope.sendEvaluationRequest = function () {
- // Send request for retrieve protocolMappers
- $scope.protocolMappers = ClientEvaluateProtocolMappers.query({
- realm: realm.realm,
- client: client.id,
- scopeParam: $scope.scopeParam
- });
- // Send request for retrieve realmRoles
- updateScopeRealmRoles();
- // Send request for retrieve accessToken (in case user was selected)
- if (client.protocol === 'openid-connect' && $scope.userId != null && $scope.userId !== '') {
- var exampleRequestParams = {
- realm: realm.realm,
- client: client.id,
- userId: $scope.userId,
- scopeParam: $scope.scopeParam
- };
- var accessTokenUrl = ClientEvaluateGenerateExampleAccessToken.url(exampleRequestParams);
- getPrettyJsonResponse(accessTokenUrl).then(function (result) {
- $scope.oidcAccessToken = result;
- });
- var idTokenUrl = ClientEvaluateGenerateExampleIDToken.url(exampleRequestParams);
- getPrettyJsonResponse(idTokenUrl).then(function (result) {
- $scope.oidcIDToken = result;
- });
- var userInfoUrl = ClientEvaluateGenerateExampleUserInfo.url(exampleRequestParams);
- getPrettyJsonResponse(userInfoUrl).then(function (result) {
- $scope.oidcUserInfo = result;
- });
- }
- $scope.showTab(1);
- };
- function getPrettyJsonResponse(url) {
- return $http.get(url).then(function (response) {
- if (response.data) {
- var responseJson = angular.fromJson(response.data);
- return angular.toJson(responseJson, true);
- } else {
- return null;
- }
- });
- }
- $scope.isResponseAvailable = function () {
- return $scope.protocolMappers != null;
- }
- $scope.isAccessTokenAvailable = function () {
- return $scope.oidcAccessToken != null;
- }
- $scope.isIDTokenAvailable = function () {
- return $scope.oidcIDToken != null;
- }
- $scope.isUserInfoAvailable = function () {
- return $scope.oidcUserInfo != null;
- }
- $scope.showTab = function (tab) {
- $scope.selectedTab = tab;
- $scope.tabCss = {
- tab1: getTabCssClass(1, tab),
- tab2: getTabCssClass(2, tab),
- tab3: getTabCssClass(3, tab),
- tab4: getTabCssClass(4, tab),
- tab5: getTabCssClass(5, tab)
- }
- }
- function getTabCssClass(tabNo, selectedTab) {
- return (tabNo === selectedTab) ? 'active' : '';
- }
- $scope.protocolMappersShown = function () {
- return $scope.selectedTab === 1;
- }
- $scope.rolesShown = function () {
- return $scope.selectedTab === 2;
- }
- $scope.exampleTabInfo = function() {
- switch ($scope.selectedTab) {
- case 3:
- return { isShown: true, value: $scope.oidcAccessToken}
- case 4:
- return { isShown: true, value: $scope.oidcIDToken}
- case 5:
- return { isShown: true, value: $scope.oidcUserInfo}
- default:
- return { isShown: false, value: null}
- }
- }
- $scope.sortMappersByPriority = function(mapper) {
- return $scope.mapperTypes[mapper.protocolMapper].priority;
- }
- // Roles
- function updateScopeRealmRoles() {
- $scope.grantedRealmRoles = ClientEvaluateGrantedRoles.query({
- realm: realm.realm,
- client: client.id,
- roleContainer: realm.realm,
- scopeParam: $scope.scopeParam
- });
- $scope.notGrantedRealmRoles = ClientEvaluateNotGrantedRoles.query({
- realm: realm.realm,
- client: client.id,
- roleContainer: realm.realm,
- scopeParam: $scope.scopeParam
- });
- }
- function updateScopeClientRoles() {
- if ($scope.selectedClient) {
- $scope.grantedClientRoles = ClientEvaluateGrantedRoles.query({
- realm: realm.realm,
- client: client.id,
- roleContainer: $scope.selectedClient.id,
- scopeParam: $scope.scopeParam
- });
- $scope.notGrantedClientRoles = ClientEvaluateNotGrantedRoles.query({
- realm: realm.realm,
- client: client.id,
- roleContainer: $scope.selectedClient.id,
- scopeParam: $scope.scopeParam
- });
- } else {
- $scope.grantedClientRoles = null;
- $scope.notGrantedClientRoles = null;
- }
- }
- });
- module.controller('ClientScopeTabCtrl', function(Dialog, $scope, Current, Notifications, $location) {
- $scope.removeClientScope = function() {
- Dialog.confirmDelete($scope.clientScope.name, 'client scope', function() {
- $scope.clientScope.$remove({
- realm : Current.realm.realm,
- clientScope : $scope.clientScope.id
- }, function() {
- $location.url("/realms/" + Current.realm.realm + "/client-scopes");
- Notifications.success("The client scope has been deleted.");
- });
- });
- };
- });
- module.controller('ClientScopeListCtrl', function($scope, realm, clientScopes, ClientScope, serverInfo, $route, Dialog, Notifications, $location) {
- $scope.realm = realm;
- $scope.clientScopes = clientScopes;
- $scope.removeClientScope = function(clientScope) {
- Dialog.confirmDelete(clientScope.name, 'client scope', function() {
- ClientScope.remove({
- realm : realm.realm,
- clientScope : clientScope.id
- }, function() {
- $route.reload();
- Notifications.success("The client scope been deleted.");
- });
- });
- };
- });
- module.controller('ClientScopesRealmDefaultCtrl', function($scope, realm, Realm, clientScopes, realmDefaultClientScopes, RealmDefaultClientScopes,
- realmOptionalClientScopes, RealmOptionalClientScopes, serverInfo, $route, Dialog, Notifications, $location) {
- console.log('ClientScopesRealmDefaultCtrl');
- $scope.realm = realm;
- $scope.realmDefaultClientScopes = realmDefaultClientScopes;
- $scope.realmOptionalClientScopes = realmOptionalClientScopes;
- $scope.availableClientScopes = [];
- $scope.selectedDefaultClientScopes = [];
- $scope.selectedDefDefaultClientScopes = [];
- $scope.selectedOptionalClientScopes = [];
- $scope.selectedDefOptionalClientScopes = [];
- // Populate available client scopes. Available client scopes are neither already assigned to 'default' or 'optional'
- for (var i = 0; i < clientScopes.length; i++) {
- var scopeName = clientScopes[i].name;
- var available = true;
- for (var j = 0; j < $scope.realmDefaultClientScopes.length; j++) {
- if (scopeName === $scope.realmDefaultClientScopes[j].name) {
- available = false;
- }
- }
- for (var j = 0; j < $scope.realmOptionalClientScopes.length; j++) {
- if (scopeName === $scope.realmOptionalClientScopes[j].name) {
- available = false;
- }
- }
- if (available) {
- $scope.availableClientScopes.push(clientScopes[i]);
- }
- }
- $scope.addDefaultClientScope = function () {
- $scope.selectedDefaultClientScopesToAdd = JSON.parse('[' + $scope.selectedDefaultClientScopes + ']');
- toAdd = $scope.selectedDefaultClientScopesToAdd.length;
- for (var i = 0; i < $scope.selectedDefaultClientScopesToAdd.length; i++) {
- var currentScope = $scope.selectedDefaultClientScopesToAdd[i];
- RealmDefaultClientScopes.update({
- realm : realm.realm,
- clientScopeId : currentScope.id
- }, function () {
- toAdd = toAdd - 1;
- console.log('toAdd: ' + toAdd);
- if (toAdd === 0) {
- $route.reload();
- Notifications.success("Realm default scopes updated.");
- }
- });
- }
- $scope.selectedDefaultClientScopesToAdd = [];
- };
- $scope.deleteDefaultClientScope = function () {
- $scope.selectedDefDefaultClientScopesToRemove = JSON.parse('[' + $scope.selectedDefDefaultClientScopes + ']');
- toRemove = $scope.selectedDefDefaultClientScopesToRemove.length;
- for (var i = 0; i < $scope.selectedDefDefaultClientScopesToRemove.length; i++) {
- var currentScope = $scope.selectedDefDefaultClientScopesToRemove[i];
- RealmDefaultClientScopes.remove({
- realm : realm.realm,
- clientScopeId : currentScope.id
- }, function () {
- toRemove = toRemove - 1;
- if (toRemove === 0) {
- $route.reload();
- Notifications.success("Realm default scopes updated.");
- }
- });
- }
- $scope.selectedDefDefaultClientScopesToRemove = [];
- };
- $scope.addOptionalClientScope = function () {
- $scope.selectedOptionalClientScopesToAdd = JSON.parse('[' + $scope.selectedOptionalClientScopes + ']');
- toAdd = $scope.selectedOptionalClientScopesToAdd.length;
- for (var i = 0; i < $scope.selectedOptionalClientScopesToAdd.length; i++) {
- var currentScope = $scope.selectedOptionalClientScopesToAdd[i];
- RealmOptionalClientScopes.update({
- realm : realm.realm,
- clientScopeId : currentScope.id
- }, function () {
- toAdd = toAdd - 1;
- console.log('toAdd: ' + toAdd);
- if (toAdd === 0) {
- $route.reload();
- Notifications.success("Realm optional scopes updated.");
- }
- });
- }
- $scope.selectedOptionalClientScopesToAdd = [];
- };
- $scope.deleteOptionalClientScope = function () {
- $scope.selectedDefOptionalClientScopesToRemove = JSON.parse('[' + $scope.selectedDefOptionalClientScopes + ']');
- toRemove = $scope.selectedDefOptionalClientScopesToRemove.length;
- for (var i = 0; i < $scope.selectedDefOptionalClientScopesToRemove.length; i++) {
- var currentScope = $scope.selectedDefOptionalClientScopesToRemove[i];
- RealmOptionalClientScopes.remove({
- realm : realm.realm,
- clientScopeId : currentScope.id
- }, function () {
- toRemove = toRemove - 1;
- if (toRemove === 0) {
- $route.reload();
- Notifications.success("Realm optional scopes updated.");
- }
- });
- }
- $scope.selectedDefOptionalClientScopesToRemove = [];
- };
- });
- module.controller('ClientScopeDetailCtrl', function($scope, realm, clientScope, $route, serverInfo, ClientScope, $location, $modal, Dialog, Notifications) {
- $scope.protocols = serverInfo.listProviderIds('login-protocol');
- $scope.realm = realm;
- $scope.create = !clientScope.name;
- function updateProperties() {
- if (!$scope.clientScope.attributes) {
- $scope.clientScope.attributes = {};
- }
- if ($scope.clientScope.protocol) {
- $scope.protocol = $scope.protocols[$scope.protocols.indexOf($scope.clientScope.protocol)];
- } else {
- $scope.protocol = $scope.protocols[0];
- }
- if ($scope.clientScope.attributes["display.on.consent.screen"]) {
- if ($scope.clientScope.attributes["display.on.consent.screen"] == "true") {
- $scope.displayOnConsentScreen = true;
- } else {
- $scope.displayOnConsentScreen = false;
- }
- } else {
- $scope.displayOnConsentScreen = true;
- }
- if ($scope.clientScope.attributes["include.in.token.scope"]) {
- if ($scope.clientScope.attributes["include.in.token.scope"] == "true") {
- $scope.includeInTokenScope = true;
- } else {
- $scope.includeInTokenScope = false;
- }
- } else {
- $scope.includeInTokenScope = true;
- }
- }
- if (!$scope.create) {
- $scope.clientScope = angular.copy(clientScope);
- } else {
- $scope.clientScope = {};
- }
- updateProperties();
- $scope.switchChange = function() {
- $scope.changed = true;
- }
- $scope.changeProtocol = function() {
- if ($scope.protocol == "openid-connect") {
- $scope.clientScope.protocol = "openid-connect";
- } else if ($scope.protocol == "saml") {
- $scope.clientScope.protocol = "saml";
- }
- };
- $scope.$watch(function() {
- return $location.path();
- }, function() {
- $scope.path = $location.path().substring(1).split("/");
- });
- function isChanged() {
- if (!angular.equals($scope.clientScope, clientScope)) {
- return true;
- }
- return false;
- }
- $scope.$watch('clientScope', function() {
- $scope.changed = isChanged();
- }, true);
- $scope.save = function() {
- $scope.clientScope.protocol = $scope.protocol;
- if ($scope.displayOnConsentScreen == true) {
- $scope.clientScope.attributes["display.on.consent.screen"] = "true";
- } else {
- $scope.clientScope.attributes["display.on.consent.screen"] = "false";
- }
- if ($scope.includeInTokenScope == true) {
- $scope.clientScope.attributes["include.in.token.scope"] = "true";
- } else {
- $scope.clientScope.attributes["include.in.token.scope"] = "false";
- }
- if ($scope.create) {
- ClientScope.save({
- realm: realm.realm,
- clientScope: ''
- }, $scope.clientScope, function (data, headers) {
- $scope.changed = false;
- var l = headers().location;
- var id = l.substring(l.lastIndexOf("/") + 1);
- $location.url("/realms/" + realm.realm + "/client-scopes/" + id);
- Notifications.success("The client scope has been created.");
- });
- } else {
- ClientScope.update({
- realm : realm.realm,
- clientScope : clientScope.id
- }, $scope.clientScope, function() {
- $scope.changed = false;
- clientScope = angular.copy($scope.clientScope);
- $location.url("/realms/" + realm.realm + "/client-scopes/" + clientScope.id);
- Notifications.success("Your changes have been saved to the client scope.");
- });
- }
- };
- $scope.reset = function() {
- $route.reload();
- };
- $scope.cancel = function() {
- $location.url("/realms/" + realm.realm + "/client-scopes");
- };
- });
- module.controller('ClientScopeProtocolMapperListCtrl', function($scope, realm, clientScope, serverInfo,
- ClientScopeProtocolMappersByProtocol, ClientScopeProtocolMapper,
- $route, Dialog, Notifications) {
- $scope.realm = realm;
- $scope.clientScope = clientScope;
- if (clientScope.protocol == null) {
- clientScope.protocol = 'openid-connect';
- }
- var protocolMappers = serverInfo.protocolMapperTypes[clientScope.protocol];
- var mapperTypes = {};
- for (var i = 0; i < protocolMappers.length; i++) {
- mapperTypes[protocolMappers[i].id] = protocolMappers[i];
- }
- $scope.mapperTypes = mapperTypes;
- $scope.removeMapper = function(mapper) {
- console.debug(mapper);
- Dialog.confirmDelete(mapper.name, 'mapper', function() {
- ClientScopeProtocolMapper.remove({ realm: realm.realm, clientScope: clientScope.id, id : mapper.id }, function() {
- Notifications.success("The mapper has been deleted.");
- $route.reload();
- });
- });
- };
- $scope.sortMappersByPriority = function(mapper) {
- return $scope.mapperTypes[mapper.protocolMapper].priority;
- }
- var updateMappers = function() {
- $scope.mappers = ClientScopeProtocolMappersByProtocol.query({realm : realm.realm, clientScope : clientScope.id, protocol : clientScope.protocol});
- };
- updateMappers();
- });
- module.controller('ClientScopeProtocolMapperCtrl', function($scope, realm, serverInfo, clientScope, mapper, clients, ClientScopeProtocolMapper, Notifications, Dialog, $location, $route) {
- $scope.realm = realm;
- $scope.clients = clients;
- if (clientScope.protocol == null) {
- clientScope.protocol = 'openid-connect';
- }
- $scope.model = {
- realm: realm,
- clientScope: clientScope,
- create: false,
- protocol: clientScope.protocol,
- mapper: angular.copy(mapper),
- changed: false
- }
- var protocolMappers = serverInfo.protocolMapperTypes[clientScope.protocol];
- for (var i = 0; i < protocolMappers.length; i++) {
- if (protocolMappers[i].id == mapper.protocolMapper) {
- $scope.model.mapperType = protocolMappers[i];
- }
- }
- $scope.$watch(function() {
- return $location.path();
- }, function() {
- $scope.path = $location.path().substring(1).split("/");
- });
- $scope.$watch('model.mapper', function() {
- if (!angular.equals($scope.model.mapper, mapper)) {
- $scope.model.changed = true;
- }
- }, true);
- $scope.save = function() {
- ClientScopeProtocolMapper.update({
- realm : realm.realm,
- clientScope: clientScope.id,
- id : mapper.id
- }, $scope.model.mapper, function() {
- $route.reload();
- Notifications.success("Your changes have been saved.");
- });
- };
- $scope.reset = function() {
- $scope.model.mapper = angular.copy(mapper);
- $scope.model.changed = false;
- };
- $scope.cancel = function() {
- //$location.url("/realms");
- window.history.back();
- };
- $scope.remove = function() {
- Dialog.confirmDelete($scope.model.mapper.name, 'mapper', function() {
- ClientScopeProtocolMapper.remove({ realm: realm.realm, clientScope: clientScope.id, id : $scope.model.mapper.id }, function() {
- Notifications.success("The mapper has been deleted.");
- $location.url("/realms/" + realm.realm + '/client-scopes/' + clientScope.id + "/mappers");
- });
- });
- };
- });
- module.controller('ClientScopeProtocolMapperCreateCtrl', function($scope, realm, serverInfo, clientScope, clients, ClientScopeProtocolMapper, Notifications, Dialog, $location) {
- $scope.realm = realm;
- $scope.clients = clients;
- if (clientScope.protocol == null) {
- clientScope.protocol = 'openid-connect';
- }
- var protocol = clientScope.protocol;
- $scope.model = {
- realm: realm,
- clientScope: clientScope,
- create: true,
- protocol: clientScope.protocol,
- mapper: { protocol : clientScope.protocol, config: {}},
- changed: false,
- mapperTypes: serverInfo.protocolMapperTypes[protocol]
- }
- // apply default configurations on change for selected protocolmapper type.
- $scope.$watch('model.mapperType', function() {
- var currentMapperType = $scope.model.mapperType;
- var defaultConfig = {};
- if (currentMapperType && Array.isArray(currentMapperType.properties)) {
- for (var i = 0; i < currentMapperType.properties.length; i++) {
- var property = currentMapperType.properties[i];
- if (property && property.name && property.defaultValue) {
- defaultConfig[property.name] = property.defaultValue;
- }
- }
- }
- $scope.model.mapper.config = defaultConfig;
- }, true);
- $scope.model.mapperType = $scope.model.mapperTypes[0];
- $scope.$watch(function() {
- return $location.path();
- }, function() {
- $scope.path = $location.path().substring(1).split("/");
- });
- $scope.save = function() {
- $scope.model.mapper.protocolMapper = $scope.model.mapperType.id;
- ClientScopeProtocolMapper.save({
- realm : realm.realm, clientScope: clientScope.id
- }, $scope.model.mapper, function(data, headers) {
- var l = headers().location;
- var id = l.substring(l.lastIndexOf("/") + 1);
- $location.url("/realms/" + realm.realm + '/client-scopes/' + clientScope.id + "/mappers/" + id);
- Notifications.success("Mapper has been created.");
- });
- };
- $scope.cancel = function() {
- //$location.url("/realms");
- window.history.back();
- };
- });
- module.controller('ClientScopeAddBuiltinProtocolMapperCtrl', function($scope, realm, clientScope, serverInfo,
- ClientScopeProtocolMappersByProtocol,
- $http, $location, Dialog, Notifications) {
- $scope.realm = realm;
- $scope.clientScope = clientScope;
- if (clientScope.protocol == null) {
- clientScope.protocol = 'openid-connect';
- }
- var protocolMappers = serverInfo.protocolMapperTypes[clientScope.protocol];
- var mapperTypes = {};
- for (var i = 0; i < protocolMappers.length; i++) {
- mapperTypes[protocolMappers[i].id] = protocolMappers[i];
- }
- $scope.mapperTypes = mapperTypes;
- var updateMappers = function() {
- var clientMappers = ClientScopeProtocolMappersByProtocol.query({realm : realm.realm, clientScope : clientScope.id, protocol : clientScope.protocol}, function() {
- var builtinMappers = serverInfo.builtinProtocolMappers[clientScope.protocol];
- for (var i = 0; i < clientMappers.length; i++) {
- for (var j = 0; j < builtinMappers.length; j++) {
- if (builtinMappers[j].name == clientMappers[i].name
- && builtinMappers[j].protocolMapper == clientMappers[i].protocolMapper) {
- builtinMappers.splice(j, 1);
- break;
- }
- }
- }
- $scope.mappers = builtinMappers;
- for (var i = 0; i < $scope.mappers.length; i++) {
- $scope.mappers[i].isChecked = false;
- }
- });
- };
- updateMappers();
- $scope.add = function() {
- var toAdd = [];
- for (var i = 0; i < $scope.mappers.length; i++) {
- if ($scope.mappers[i].isChecked) {
- delete $scope.mappers[i].isChecked;
- toAdd.push($scope.mappers[i]);
- }
- }
- $http.post(authUrl + '/admin/realms/' + realm.realm + '/client-scopes/' + clientScope.id + '/protocol-mappers/add-models',
- toAdd).then(function() {
- Notifications.success("Mappers added");
- $location.url('/realms/' + realm.realm + '/client-scopes/' + clientScope.id + '/mappers');
- }).catch(function() {
- Notifications.error("Error adding mappers");
- $location.url('/realms/' + realm.realm + '/client-scopes/' + clientScope.id + '/mappers');
- });
- };
- });
- module.controller('ClientScopeScopeMappingCtrl', function($scope, $http, $route, realm, clientScope, Notifications,
- ClientScope, Client,
- ClientScopeRealmScopeMapping, ClientScopeClientScopeMapping, ClientRole,
- ClientScopeAvailableRealmScopeMapping, ClientScopeAvailableClientScopeMapping,
- ClientScopeCompositeRealmScopeMapping, ClientScopeCompositeClientScopeMapping) {
- $scope.realm = realm;
- $scope.clientScope = angular.copy(clientScope);
- $scope.selectedRealmRoles = [];
- $scope.selectedRealmMappings = [];
- $scope.realmMappings = [];
- $scope.clientRoles = [];
- $scope.clientComposite = [];
- $scope.selectedClientRoles = [];
- $scope.selectedClientMappings = [];
- $scope.clientMappings = [];
- $scope.dummymodel = [];
- $scope.selectedClient = null;
- function updateScopeRealmRoles() {
- $scope.realmRoles = ClientScopeAvailableRealmScopeMapping.query({realm : realm.realm, clientScope : clientScope.id});
- $scope.realmMappings = ClientScopeRealmScopeMapping.query({realm : realm.realm, clientScope : clientScope.id});
- $scope.realmComposite = ClientScopeCompositeRealmScopeMapping.query({realm : realm.realm, clientScope : clientScope.id});
- }
- function updateScopeClientRoles() {
- if ($scope.selectedClient) {
- $scope.clientRoles = ClientScopeAvailableClientScopeMapping.query({realm : realm.realm, clientScope : clientScope.id, targetClient : $scope.selectedClient.id});
- $scope.clientMappings = ClientScopeClientScopeMapping.query({realm : realm.realm, clientScope : clientScope.id, targetClient : $scope.selectedClient.id});
- $scope.clientComposite = ClientScopeCompositeClientScopeMapping.query({realm : realm.realm, clientScope : clientScope.id, targetClient : $scope.selectedClient.id});
- } else {
- $scope.clientRoles = null;
- $scope.clientMappings = null;
- $scope.clientComposite = null;
- }
- }
- $scope.changeClient = function(client) {
- if (!client || !client.id) {
- $scope.selectedClient = null;
- return;
- }
- $scope.selectedClient = client;
- updateScopeClientRoles();
- };
- $scope.addRealmRole = function() {
- $scope.selectedRealmRolesToAdd = JSON.parse('[' + $scope.selectedRealmRoles + ']');
- $scope.selectedRealmRoles = [];
- $http.post(authUrl + '/admin/realms/' + realm.realm + '/client-scopes/' + clientScope.id + '/scope-mappings/realm',
- $scope.selectedRealmRolesToAdd).then(function() {
- updateScopeRealmRoles();
- $scope.selectedRealmRolesToAdd = [];
- Notifications.success("Scope mappings updated.");
- });
- };
- $scope.deleteRealmRole = function() {
- $scope.selectedRealmMappingsToRemove = JSON.parse('[' + $scope.selectedRealmMappings + ']');
- $scope.selectedRealmMappings = [];
- $http.delete(authUrl + '/admin/realms/' + realm.realm + '/client-scopes/' + clientScope.id + '/scope-mappings/realm',
- {data : $scope.selectedRealmMappingsToRemove, headers : {"content-type" : "application/json"}}).then(function () {
- updateScopeRealmRoles();
- $scope.selectedRealmMappingsToRemove = [];
- Notifications.success("Scope mappings updated.");
- });
- };
- $scope.addClientRole = function() {
- $scope.selectedClientRolesToAdd = JSON.parse('[' + $scope.selectedClientRoles + ']');
- $scope.selectedClientRoles = [];
- $http.post(authUrl + '/admin/realms/' + realm.realm + '/client-scopes/' + clientScope.id + '/scope-mappings/clients/' + $scope.selectedClient.id,
- $scope.selectedClientRolesToAdd).then(function () {
- updateScopeClientRoles();
- $scope.selectedClientRolesToAdd = [];
- Notifications.success("Scope mappings updated.");
- });
- };
- $scope.deleteClientRole = function() {
- $scope.selectedClientMappingsToRemove = JSON.parse('[' + $scope.selectedClientMappings + ']');
- $scope.selectedClientMappings = [];
- $http.delete(authUrl + '/admin/realms/' + realm.realm + '/client-scopes/' + clientScope.id + '/scope-mappings/clients/' + $scope.selectedClient.id,
- {data : $scope.selectedClientMappingsToRemove, headers : {"content-type" : "application/json"}}).then(function () {
- updateScopeClientRoles();
- $scope.selectedClientMappingsToRemove = [];
- Notifications.success("Scope mappings updated.");
- });
- };
- clientSelectControl($scope, $route.current.params.realm, Client);
- updateScopeRealmRoles();
- });
- module.controller('ClientStoresCtrl', function($scope, $location, $route, realm, serverInfo, Components, Notifications, Dialog) {
- console.log('ClientStoresCtrl ++++****');
- $scope.realm = realm;
- $scope.providers = serverInfo.componentTypes['org.keycloak.storage.client.ClientStorageProvider'];
- $scope.clientStorageProviders = serverInfo.componentTypes['org.keycloak.storage.client.ClientStorageProvider'];
- $scope.instancesLoaded = false;
- if (!$scope.providers) $scope.providers = [];
- $scope.addProvider = function(provider) {
- console.log('Add provider: ' + provider.id);
- $location.url("/create/client-storage/" + realm.realm + "/providers/" + provider.id);
- };
- $scope.getInstanceLink = function(instance) {
- return "/realms/" + realm.realm + "/client-storage/providers/" + instance.providerId + "/" + instance.id;
- }
- $scope.getInstanceName = function(instance) {
- return instance.name;
- }
- $scope.getInstanceProvider = function(instance) {
- return instance.providerId;
- }
- $scope.isProviderEnabled = function(instance) {
- return !instance.config['enabled'] || instance.config['enabled'][0] == 'true';
- }
- $scope.getInstancePriority = function(instance) {
- if (!instance.config['priority']) {
- return "0";
- }
- return instance.config['priority'][0];
- }
- Components.query({realm: realm.realm,
- parent: realm.id,
- type: 'org.keycloak.storage.client.ClientStorageProvider'
- }, function(data) {
- $scope.instances = data;
- $scope.instancesLoaded = true;
- });
- $scope.removeInstance = function(instance) {
- Dialog.confirmDelete(instance.name, 'client storage provider', function() {
- Components.remove({
- realm : realm.realm,
- componentId : instance.id
- }, function() {
- $route.reload();
- Notifications.success("The provider has been deleted.");
- });
- });
- };
- });
- module.controller('GenericClientStorageCtrl', function($scope, $location, Notifications, $route, Dialog, realm,
- serverInfo, instance, providerId, Components) {
- console.log('GenericClientStorageCtrl');
- console.log('providerId: ' + providerId);
- $scope.create = !instance.providerId;
- console.log('create: ' + $scope.create);
- var providers = serverInfo.componentTypes['org.keycloak.storage.client.ClientStorageProvider'];
- console.log('providers length ' + providers.length);
- var providerFactory = null;
- for (var i = 0; i < providers.length; i++) {
- var p = providers[i];
- console.log('provider: ' + p.id);
- if (p.id == providerId) {
- $scope.providerFactory = p;
- providerFactory = p;
- break;
- }
- }
- $scope.changed = false;
- console.log("providerFactory: " + providerFactory.id);
- function initClientStorageSettings() {
- if ($scope.create) {
- $scope.changed = true;
- instance.name = providerFactory.id;
- instance.providerId = providerFactory.id;
- instance.providerType = 'org.keycloak.storage.client.ClientStorageProvider';
- instance.parentId = realm.id;
- instance.config = {
- };
- instance.config['priority'] = ["0"];
- instance.config['enabled'] = ["true"];
- $scope.fullSyncEnabled = false;
- $scope.changedSyncEnabled = false;
- instance.config['cachePolicy'] = ['DEFAULT'];
- instance.config['evictionDay'] = [''];
- instance.config['evictionHour'] = [''];
- instance.config['evictionMinute'] = [''];
- instance.config['maxLifespan'] = [''];
- if (providerFactory.properties) {
- for (var i = 0; i < providerFactory.properties.length; i++) {
- var configProperty = providerFactory.properties[i];
- if (configProperty.defaultValue) {
- instance.config[configProperty.name] = [configProperty.defaultValue];
- } else {
- instance.config[configProperty.name] = [''];
- }
- }
- }
- } else {
- $scope.changed = false;
- if (!instance.config['enabled']) {
- instance.config['enabled'] = ['true'];
- }
- if (!instance.config['cachePolicy']) {
- instance.config['cachePolicy'] = ['DEFAULT'];
- }
- if (!instance.config['evictionDay']) {
- instance.config['evictionDay'] = [''];
- }
- if (!instance.config['evictionHour']) {
- instance.config['evictionHour'] = [''];
- }
- if (!instance.config['evictionMinute']) {
- instance.config['evictionMinute'] = [''];
- }
- if (!instance.config['maxLifespan']) {
- instance.config['maxLifespan'] = [''];
- }
- if (!instance.config['priority']) {
- instance.config['priority'] = ['0'];
- }
- if (providerFactory.properties) {
- for (var i = 0; i < providerFactory.properties.length; i++) {
- var configProperty = providerFactory.properties[i];
- if (!instance.config[configProperty.name]) {
- instance.config[configProperty.name] = [''];
- }
- }
- }
- }
- }
- initClientStorageSettings();
- $scope.instance = angular.copy(instance);
- $scope.realm = realm;
- $scope.$watch('instance', function() {
- if (!angular.equals($scope.instance, instance)) {
- $scope.changed = true;
- }
- }, true);
- $scope.save = function() {
- console.log('save provider');
- $scope.changed = false;
- if ($scope.create) {
- console.log('saving new provider');
- Components.save({realm: realm.realm}, $scope.instance, function (data, headers) {
- var l = headers().location;
- var id = l.substring(l.lastIndexOf("/") + 1);
- $location.url("/realms/" + realm.realm + "/client-storage/providers/" + $scope.instance.providerId + "/" + id);
- Notifications.success("The provider has been created.");
- });
- } else {
- console.log('update existing provider');
- Components.update({realm: realm.realm,
- componentId: instance.id
- },
- $scope.instance, function () {
- $route.reload();
- Notifications.success("The provider has been updated.");
- });
- }
- };
- $scope.reset = function() {
- $route.reload();
- };
- $scope.cancel = function() {
- console.log('cancel');
- if ($scope.create) {
- $location.url("/realms/" + realm.realm + "/client-stores");
- } else {
- $route.reload();
- }
- };
- });
|