lemonldap-ng/lemonldap-ng-manager/site/htdocs/static/js/sessions.min.js

1 line
9.1 KiB
JavaScript

!function(){var f={_whatToTrace:[function(e,t){return"groupBy=substr("+e+",1)"},function(e,t){return e+"="+t+"*&groupBy="+e},function(e,t){return e+"="+t}],ipAddr:[function(e,t){return"groupBy=net("+e+",16,1)"},function(e,t){return t.match(/:/)||(t+="."),e+"="+t+"*&groupBy=net("+e+",32,2)"},function(e,t){return t.match(/:/)||(t+="."),e+"="+t+"*&groupBy=net("+e+",48,3)"},function(e,t){return t.match(/:/)||(t+="."),e+"="+t+"*&groupBy=net("+e+",128,4)"},function(e,t){return e+"="+t+"&groupBy=_whatToTrace"},function(e,t,n){return n.replace(/\&groupBy.*$/,"")+"&_whatToTrace="+t}],_startTime:[function(e,t){return"groupBy=substr("+e+",8)"},function(e,t){return e+"="+t+"*&groupBy=substr("+e+",10)"},function(e,t){return e+"="+t+"*&groupBy=substr("+e+",11)"},function(e,t){return e+"="+t+"*&groupBy=substr("+e+",12)"},function(e,t){return e+"="+t+"*&groupBy=_whatToTrace"},function(e,t,n){return console.log(e),console.log(t),console.log(n),n.replace(/\&groupBy.*$/,"")+"&_whatToTrace="+t}],doubleIp:[function(e,t){return e},function(e,t){return"_whatToTrace="+t+"&groupBy=ipAddr"},function(e,t,n){return n.replace(/\&groupBy.*$/,"")+"&ipAddr="+t}],_session_uid:[function(e,t){return"groupBy=substr("+e+",1)"},function(e,t){return e+"="+t+"*&groupBy="+e},function(e,t){return e+"="+t}]},g={_whatToTrace:function(e,t,n,o){return console.log("overScheme => level",n,"over",o),1===n&&t.length>o?e+"="+t+"*&groupBy=substr("+e+","+(n+o+1)+")":null},ipAddr:function(e,t,n,o){return console.log("overScheme => level",n,"over",o),0<n&&n<4&&!t.match(/^\d+\.\d/)&&o<2?e+"="+t+"*&groupBy=net("+e+","+(16*n+4*(o+1))+","+(1+n+o)+")":null},_startTime:function(e,t,n,o){return console.log("overScheme => level",n,"over",o),3<n?e+"="+t+"*&groupBy=substr("+e+","+(10+n+o)+")":null},_session_uid:function(e,t,n,o){return console.log("overScheme => level",n,"over",o),1===n&&t.length>o?e+"="+t+"*&groupBy=substr("+e+","+(n+o+1)+")":null}},O={dateTitle:["_utime","_startTime","_updateTime","_lastAuthnUTime","_lastSeen"],connectionTitle:["ipAddr","_timezone","_url"],authenticationTitle:["_session_id","_user","_password","authenticationLevel"],modulesTitle:["_auth","_userDB","_passwordDB","_issuerDB","_authChoice","_authMulti","_userDBMulti","_2f"],saml:["_idp","_idpConfKey","_samlToken","_lassoSessionDump","_lassoIdentityDump"],groups:["groups","hGroups"],ldap:["dn"],OpenIDConnect:["_oidc_id_token","_oidc_OP","_oidc_access_token","_oidc_refresh_token","_oidc_access_token_eol"],sfaTitle:["_2fDevices"],oidcConsents:["_oidcConsents"]},i={session:[{title:"deleteSession",icon:"trash"}],home:[]};angular.module("llngSessionsExplorer",["ui.tree","ui.bootstrap","llApp"]).controller("SessionsExplorerCtrl",["$scope","$translator","$location","$q","$http",function(M,t,r,e,o){var p,n,d;return M.links=links,M.menulinks=menulinks,M.staticPrefix=staticPrefix,M.scriptname=scriptname,M.formPrefix=formPrefix,M.impPrefix=impPrefix,M.sessionTTL=sessionTTL,M.availableLanguages=availableLanguages,M.waiting=!0,M.showM=!1,M.showT=!0,M.data=[],M.currentScope=null,M.currentSession=null,M.menu=i,M.translateP=t.translateP,M.translate=t.translate,M.translateTitle=function(e){return t.translateField(e,"title")},d="global",M.menuClick=function(e){if(e.popup)window.open(e.popup);else switch(e.action||(e.action=e.title),typeof e.action){case"function":e.action(M.currentNode,M);break;case"string":M[e.action]();break;default:console.log(typeof e.action)}return M.showM=!1},M.deleteOIDCConsent=function(e,t){var i=document.querySelectorAll(".data-"+t);return M.waiting=!0,o.delete(scriptname+"sessions/OIDCConsent/"+d+"/"+M.currentSession.id+"?rp="+e+"&epoch="+t).then(function(e){var t,n,o,r;for(M.waiting=!1,r=[],n=0,o=i.length;n<o;n++)t=i[n],r.push(t.remove());return r},function(e){return M.waiting=!1}),M.showT=!1},M.deleteSession=function(){return M.waiting=!0,o.delete(scriptname+"sessions/"+d+"/"+M.currentSession.id).then(function(e){return M.currentSession=null,M.currentScope.remove(),M.waiting=!1},function(e){return M.waiting=!1})},M.stoggle=function(e){var t=e.$modelValue;return 0===t.nodes.length&&M.updateTree(t.value,t.nodes,t.level,t.over,t.query,t.count),e.toggle()},M.displaySession=function(e){var t,n=function(p){var e,t,n,o,r,i,s,l,u,a,c,d,f,g,h,_,m,y,T,v,w,S,$,B,b,D,L,A,P,x,C,k,I,R,E=function(e,t){var n,o,r,i,s,l,u=[],a=new RegExp(e),c="";for(o in p)s=p[o],o.match(a)&&s&&(c+=s+":"+o+",",delete p[o]);if(c){for((i=(c=c.replace(/,$/,"")).split(",")).sort(),i.reverse(),n=0,r=i.length;n<r;n++)l=i[n].split(":"),u.push({title:l[1],value:M.localeDate(l[0])});return L.push({title:t,nodes:u})}},H=p._utime;for(c in p)(R=p[c])?("string"==typeof p&&R.match(/; /)&&(p[c]=R.split("; ")),"object"!=typeof p[c]&&("_password".match(new RegExp("\b"+c+"\b"))?p[c]="********":c.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)?p[c]=M.localeDate(R):c.match(/^(_startTime|_updateTime)$/)&&(p[c]=M.strToLocaleDate(R)))):delete p[c];for(o in L=[],O){for(x=[],l=0,f=(n=O[o]).length;l<f;l++)if(t=n[l],p[t])if("_2fDevices"===t&&p[t]){if(0<(e=JSON.parse(p[t])).length)for(x.push({title:"type",value:"name",epoch:"date",td:"0"}),u=0,g=e.length;u<g;u++){for(c in A=e[u])R=A[c],"type"===c&&(k=R),"name"===c&&(v=R),"epoch"===c&&(s=R);x.push({title:k,value:v,epoch:s,td:"1"})}delete p[t]}else if(p[t].toString().match(/"rp":\s*"[\w-]+"/)){for(x.push({title:"RP",value:"scope",epoch:"date",td:"0"}),a=0,h=(e=JSON.parse(p[t])).length;a<h;a++){for(c in S=e[a])R=S[c],"rp"===c&&(k=R),"scope"===c&&(v=R),"epoch"===c&&(s=R);x.push({title:k,value:v,epoch:s,td:"2"})}delete p[t]}else p[t].toString().match(/\w+/)&&x.push({title:t,value:p[t],epoch:""}),delete p[t];else delete p[t];0<x.length&&L.push({title:"__"+o+"__",nodes:x})}if(E("^openid","OpenID"),E("^notification_(.+)","__notificationsDone__"),p._loginHistory){if(I=[],p._loginHistory.successLogin)for(T=0,_=(b=p._loginHistory.successLogin).length;T<_;T++){for(c in r="",d=b[T])R=d[c],c.match(/^(_utime|ipAddr|error)$/)||(r+=", "+c+" : "+R);(C=r.split(", ")).sort(),r=C.join(", "),I.push({t:d._utime,title:M.localeDate(d._utime),value:"Success (IP "+d.ipAddr+")"+r})}if(p._loginHistory.failedLogin)for(w=0,m=(D=p._loginHistory.failedLogin).length;w<m;w++){for(c in r="",d=D[w])R=d[c],c.match(/^(_utime|ipAddr|error)$/)||(r+=", "+c+" : "+R);(C=r.split(", ")).sort(),r=C.join(", "),I.push({t:d._utime,title:M.localeDate(d._utime),value:"Error "+d.error+" (IP "+d.ipAddr+")"+r})}delete p._loginHistory,I.sort(function(e,t){return t.t-e.t}),L.push({title:"__loginHistory__",nodes:I})}for(c in I=[],p)R=p[c],I.push({title:c,value:R});for(I.sort(function(e,t){return e.title>t.title?1:e.title<t.title?-1:0}),B=[],P=[],$=0,y=I.length;$<y;$++)(i=I[$]).title.match(new RegExp("^"+M.impPrefix+".+$"))?(console.log(i,"-> real attribute"),B.push(i)):P.push(i);return I=P.concat(B),L.push({title:"__attributesAndMacros__",nodes:I}),{_utime:H,nodes:L}};return M.currentScope=e,t=e.$modelValue.session,o.get(scriptname+"sessions/"+d+"/"+t).then(function(e){return M.currentSession=n(e.data),M.currentSession.id=t}),M.showT=!1},M.localeDate=function(e){return new Date(1e3*e).toLocaleString()},M.isValid=function(e,t){var n=r.path(),o=Date.now()/1e3;return console.log("Path",n),console.log("Session epoch",e),console.log("Current date",o),console.log("Session TTL",sessionTTL),e=o-e<sessionTTL||r.path().match(/^\/persistent/),"msg"===t?(console.log("Return msg"),e?"info":"warning"):"style"===t?(console.log("Return style"),e?{}:{color:"#627990","font-style":"italic"}):(console.log("Return isValid"),e)},M.strToLocaleDate=function(e){var t=e.match(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/);return t.length?new Date(t[1]+"-"+t[2]+"-"+t[3]+"T"+t[4]+":"+t[5]+":"+t[6]).toLocaleString():e},M.getLanguage=function(e){return M.lang=e,M.form="white",M.init(),M.showM=!1},n=function(e,t,n){t=t.match(/#!?\/(\w+)/);return d="global",null===t?M.type="_whatToTrace":t[1].match(/^(persistent|offline)$/)?(d=RegExp.$1,M.type="_session_uid"):M.type=t[1],M.init()},M.$on("$locationChangeSuccess",n),p=0,M.updateTree=function(i,s,l,u,e,t){var a,c,n;if(M.waiting=!0,c=f[M.type]||("_updateTime"===M.type?f._startTime:f._whatToTrace),a=c[l](M.type,i,e),25<t&&g[M.type]&&(n=g[M.type](M.type,i,l,u,e))?(u++,a=n,l-=1):u=0,o.get(scriptname+"sessions/"+d+"?"+a).then(function(e){var t,n,o,r,e=e.data;if(e.result){for(t=0,n=(r=e.values).length;t<n;t++)o=r[t],p++,o.id="node"+p,l<c.length-1&&(o.nodes=[],o.level=l+1,o.query=a,o.over=u,M.type.match(/^(?:start|update)Time$/)&&(o.title=o.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(o);""===i&&(M.total=e.total)}return M.waiting=!1},function(e){return M.waiting=!1}),console.log("Selection",d),M.navssoStyle={color:"#777"},M.offlineStyle={color:"#777"},M.persistentStyle={color:"#777"},"global"===d&&(M.navssoStyle={color:"#333"}),"offline"===d&&(M.offlineStyle={color:"#333"}),"persistent"===d)return M.persistentStyle={color:"#333"}},M.init=function(){return M.waiting=!0,M.data=[],M.currentScope=null,M.currentSession=null,e.all([t.init(M.lang),M.updateTree("",M.data,0,0)]).then(function(){return M.waiting=!1},function(e){return M.waiting=!1}),M.activeModule="sessions",M.myStyle={color:"#ffb84d"}},n=r.path().match(/^\/(\w+)/),M.type=n?n[1]:"_whatToTrace"}])}.call(this);