lemonldap-ng/lemonldap-ng-manager/site/htdocs/static/js/sessions.min.js
2018-05-08 22:30:43 +02:00

1 line
6.9 KiB
JavaScript

(function(){var c,e,d,b,g,f,a;b=25;a={_whatToTrace:[function(i,h){return"groupBy=substr("+i+",1)"},function(i,h){return i+"="+h+"*&groupBy="+i},function(i,h){return i+"="+h}],ipAddr:[function(i,h){return"groupBy=net("+i+",16,1)"},function(i,h){if(!h.match(/:/)){h=h+"."}return i+"="+h+"*&groupBy=net("+i+",32,2)"},function(i,h){if(!h.match(/:/)){h=h+"."}return i+"="+h+"*&groupBy=net("+i+",48,3)"},function(i,h){if(!h.match(/:/)){h=h+"."}return i+"="+h+"*&groupBy=net("+i+",128,4)"},function(i,h){return i+"="+h+"&groupBy=_whatToTrace"},function(i,h,j){return j.replace(/\&groupBy.*$/,"")+("&_whatToTrace="+h)}],_startTime:[function(i,h){return"groupBy=substr("+i+",8)"},function(i,h){return i+"="+h+"*&groupBy=substr("+i+",10)"},function(i,h){return i+"="+h+"*&groupBy=substr("+i+",11)"},function(i,h){return i+"="+h+"*&groupBy=substr("+i+",12)"},function(i,h){return i+"="+h+"*&groupBy=_whatToTrace"},function(i,h,j){console.log(i);console.log(h);console.log(j);return j.replace(/\&groupBy.*$/,"")+("&_whatToTrace="+h)}],doubleIp:[function(i,h){return i},function(i,h){return"_whatToTrace="+h+"&groupBy=ipAddr"},function(i,h,j){return j.replace(/\&groupBy.*$/,"")+("&ipAddr="+h)}]};f={_whatToTrace:function(i,h,k,j){if(k===1){return i+"="+h+"*&groupBy=substr("+i+","+(k+j+1)+")"}else{return null}},ipAddr:function(i,h,k,j){if(k>0&&k<4){return i+"="+h+"*&groupBy=net("+i+","+(16*k+4*(j+1))+",2)"}else{return null}}};e="_password";c={dateTitle:["_utime","_startTime","_updateTime","_lastAuthnUTime","_lastSeen"],connectionTitle:["ipAddr","_timezone","_url"],authenticationTitle:["_session_id","_user","_password","authenticationLevel"],modulesTitle:["_auth","_userDB","_passwordDB","_issuerDB","_authChoice","_authMulti","_userDBMulti"],saml:["_idp","_idpConfKey","_samlToken","_lassoSessionDump","_lassoIdentityDump"],groups:["groups","hGroups"],ldap:["dn"],BrowserID:["_browserIdAnswer","_browserIdAnswerRaw"],OpenIDConnect:["_oidc_id_token","_oidc_OP","_oidc_access_token"],sfaTitle:["_2fDevices"]};g={session:[{title:"deleteSession",icon:"trash"}],home:[]};d=angular.module("llngSessionsExplorer",["ui.tree","ui.bootstrap","llApp"]);d.controller("SessionsExplorerCtrl",["$scope","$translator","$location","$q","$http",function(p,h,i,j,m){var n,l,k,o;p.links=links;p.menulinks=menulinks;p.staticPrefix=staticPrefix;p.scriptname=scriptname;p.formPrefix=formPrefix;p.availableLanguages=availableLanguages;p.waiting=true;p.showM=false;p.showT=true;p.data=[];p.currentScope=null;p.currentSession=null;p.menu=g;p.translateP=h.translateP;p.translate=h.translate;p.translateTitle=function(q){return h.translateField(q,"title")};o="global";p.menuClick=function(q){if(q.popup){window.open(q.popup)}else{if(!q.action){q.action=q.title}switch(typeof q.action){case"function":q.action(p.currentNode,p);break;case"string":p[q.action]();break;default:console.log(typeof q.action)}}return p.showM=false};p.deleteSession=function(){p.waiting=true;return m["delete"](scriptname+"sessions/"+o+"/"+p.currentSession.id).then(function(q){p.currentSession=null;p.currentScope.remove();return p.waiting=false},function(q){p.currentSession=null;p.currentScope.remove();return p.waiting=false})};p.stoggle=function(q){var r;r=q.$modelValue;if(r.nodes.length===0){p.updateTree(r.value,r.nodes,r.level,r.over,r.query,r.count)}return q.toggle()};p.displaySession=function(r){var s,q;q=function(t){var B,E,y,z,J,G,L,S,O,F,N,M,X,K,P,A,x,w,I,W,Q,u,D,V,C,T,v,U,R,H;E=function(Y){return Y};B=function(ab,ad){var Z,aa,Y,ac;Y=[];aa=new RegExp(ab);for(Z in t){ac=t[Z];if(Z.match(aa)&&ac){Y.push({title:Z,value:ac});delete t[Z]}}if(Y.length>0){return V.push({title:ad,nodes:Y})}};v=t._utime;F=t._session_id;for(X in t){H=t[X];if(!H){delete t[X]}else{if(typeof t==="string"&&H.match(/; /)){t[X]=H.split("; ")}if(typeof t[X]!=="object"){if(e.match(new RegExp("\b"+X+"\b"))){t[X]="********"}else{if(X.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)){t[X]=p.localeDate(H)}else{if(X.match(/^(_startTime|_updateTime)$/)){H=E(H);Q=/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/;z=H.match(Q);t[X]=z[3]+"/"+z[2]+"/"+z[1]+" à "+z[4]+":"+z[5]+":"+z[6]}}}}}}V=[];for(L in c){G=c[L];T=[];for(O=0,P=G.length;O<P;O++){J=G[O];if(t[J]){if(t[J].toString().match(/"type":\s*"(?:TOTP|U2F|UBK)"/)){T.push({title:"type",value:"name",epoch:"date"});y=JSON.parse(t[J]);for(N=0,A=y.length;N<A;N++){C=y[N];for(X in C){H=C[X];if(X==="type"){U=H}if(X==="name"){W=H}if(X==="epoch"){S=H}}T.push({title:U,value:W,epoch:S})}delete t[J]}else{if(t[J].toString().match(/\w+/)){T.push({title:J,value:t[J],epoch:""});delete t[J]}else{delete t[J]}}}else{delete t[J]}}if(T.length>0){V.push({title:"__"+L+"__",nodes:T})}}B("^openid","OpenID");B("^notification_(.+)","__notificationsDone__");if(t._loginHistory){R=[];if(t._loginHistory.successLogin){u=t._loginHistory.successLogin;for(M=0,x=u.length;M<x;M++){K=u[M];R.push({t:K._utime,title:p.localeDate(K._utime),value:"Success (IP "+K.ipAddr+")"})}}if(t._loginHistory.failedLogin){D=t._loginHistory.failedLogin;for(I=0,w=D.length;I<w;I++){K=D[I];R.push({t:K._utime,title:p.localeDate(K._utime),value:K.error+" (IP "+K.ipAddr+")"})}}delete t._loginHistory;R.sort(function(Z,Y){return Z.t-Y.t});V.push({title:"__loginHistory__",nodes:R})}R=[];for(X in t){H=t[X];R.push({title:X,value:H})}R.sort(function(Z,Y){if(Z.title>Y.title){return 1}else{if(Z.title<Y.title){return -1}else{return 0}}});V.push({title:"__attributesAndMacros__",nodes:R});return{_utime:v,id:F,nodes:V}};p.currentScope=r;s=r.$modelValue.session;m.get(scriptname+"sessions/"+o+"/"+s).then(function(t){return p.currentSession=q(t.data)});return p.showT=false};p.localeDate=function(q){var r;r=new Date(q*1000);return r.toLocaleString()};p.getLanguage=function(q){p.lang=q;p.form="white";p.init();return p.showM=false};k=function(r,q,s){var t;t=q.match(/#\/(\w+)/);o="global";if(t===null){p.type="_whatToTrace"}else{if(t[1].match(/^(persistent)$/)){o=RegExp.$1;p.type="_session_uid"}else{p.type=t[1]}}return p.init()};p.$on("$locationChangeSuccess",k);n=0;p.updateTree=function(y,s,q,v,x,u){var w,r,t;p.waiting=true;r=a[p.type]?a[p.type]:p.type==="_updateTime"?a._startTime:a._whatToTrace;w=r[q](p.type,y,x);if(u>b&&f[p.type]){if(t=f[p.type](p.type,y,q,v,x)){v++;w=t;q=q-1}else{v=0}}else{v=0}return m.get(scriptname+"sessions/"+o+"?"+w).then(function(A){var D,B,z,E,C;D=A.data;if(D.result){C=D.values;for(B=0,z=C.length;B<z;B++){E=C[B];n++;E.id="node"+n;if(q<r.length-1){E.nodes=[];E.level=q+1;E.query=w;E.over=v;if(p.type.match(/^(?:start|update)Time$/)){E.title=E.value.replace(/^(\d{8})(\d{2})(\d{2})$/,"$2:$3").replace(/^(\d{8})(\d{2})(\d)$/,"$2:$30").replace(/^(\d{8})(\d{2})$/,"$2h").replace(/^(\d{4})(\d{2})(\d{2})/,"$1-$2-$3")}}s.push(E)}if(y===""){p.total=D.total}}return p.waiting=false},function(z){return p.waiting=false})};p.init=function(){p.waiting=true;p.data=[];j.all([h.init(p.lang),p.updateTree("",p.data,0,0)]).then(function(){return p.waiting=false},function(q){return p.waiting=false});p.activeModule="sessions";return p.myStyle={color:"#ffb84d"}};l=i.path().match(/^\/(\w+)/);return p.type=l?l[1]:"_whatToTrace"}])}).call(this);