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

1 line
9.0 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}},M={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"],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(H,t,r,e,o){var p,n,d;return H.links=links,H.menulinks=menulinks,H.staticPrefix=staticPrefix,H.scriptname=scriptname,H.formPrefix=formPrefix,H.impPrefix=impPrefix,H.sessionTTL=sessionTTL,H.availableLanguages=availableLanguages,H.waiting=!0,H.showM=!1,H.showT=!0,H.data=[],H.currentScope=null,H.currentSession=null,H.menu=i,H.translateP=t.translateP,H.translate=t.translate,H.translateTitle=function(e){return t.translateField(e,"title")},d="global",H.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(H.currentNode,H);break;case"string":H[e.action]();break;default:console.log(typeof e.action)}return H.showM=!1},H.deleteOIDCConsent=function(e,t){var i=document.querySelectorAll(".data-"+t);return H.waiting=!0,o.delete(scriptname+"sessions/OIDCConsent/"+d+"/"+H.currentSession.id+"?rp="+e+"&epoch="+t).then(function(e){var t,n,o,r;for(H.waiting=!1,r=[],n=0,o=i.length;n<o;n++)t=i[n],r.push(t.remove());return r},function(e){return H.waiting=!1}),H.showT=!1},H.deleteSession=function(){return H.waiting=!0,o.delete(scriptname+"sessions/"+d+"/"+H.currentSession.id).then(function(e){return H.currentSession=null,H.currentScope.remove(),H.waiting=!1},function(e){return H.waiting=!1})},H.stoggle=function(e){var t=e.$modelValue;return 0===t.nodes.length&&H.updateTree(t.value,t.nodes,t.level,t.over,t.query,t.count),e.toggle()},H.displaySession=function(e){var t,n=function(s){var e,t,n,o,r,i,l,u,a,c,p,d,f,g,h,_,m,y,T,v,w,S,$,B,b,D,L,A,P,x,C,k,I,O,R=function(e,t){var n,o,r=[],i=new RegExp(e);for(n in s)o=s[n],n.match(i)&&o&&(r.push({title:n,value:o}),delete s[n]);if(0<r.length)return L.push({title:t,nodes:r})},E=s._utime;for(p in s)(O=s[p])?("string"==typeof s&&O.match(/; /)&&(s[p]=O.split("; ")),"object"!=typeof s[p]&&("_password".match(new RegExp("\b"+p+"\b"))?s[p]="********":p.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)?s[p]=H.localeDate(O):p.match(/^(_startTime|_updateTime)$/)&&(s[p]=H.strToLocaleDate(O)))):delete s[p];for(o in L=[],M){for(x=[],u=0,f=(n=M[o]).length;u<f;u++)if(t=n[u],s[t])if(s[t].toString().match(/"type":\s*"(?:TOTP|U2F|UBK|WebAuthn)"/)){for(x.push({title:"type",value:"name",epoch:"date",td:"0"}),a=0,g=(e=JSON.parse(s[t])).length;a<g;a++){for(p in A=e[a])O=A[p],"type"===p&&(k=O),"name"===p&&(v=O),"epoch"===p&&(l=O);x.push({title:k,value:v,epoch:l,td:"1"})}delete s[t]}else if(s[t].toString().match(/"rp":\s*"[\w-]+"/)){for(x.push({title:"RP",value:"scope",epoch:"date",td:"0"}),c=0,h=(e=JSON.parse(s[t])).length;c<h;c++){for(p in S=e[c])O=S[p],"rp"===p&&(k=O),"scope"===p&&(v=O),"epoch"===p&&(l=O);x.push({title:k,value:v,epoch:l,td:"2"})}delete s[t]}else s[t].toString().match(/\w+/)&&x.push({title:t,value:s[t],epoch:""}),delete s[t];else delete s[t];0<x.length&&L.push({title:"__"+o+"__",nodes:x})}if(R("^openid","OpenID"),R("^notification_(.+)","__notificationsDone__"),s._loginHistory){if(I=[],s._loginHistory.successLogin)for(T=0,_=(b=s._loginHistory.successLogin).length;T<_;T++){for(p in r="",d=b[T])O=d[p],p.match(/^(_utime|ipAddr|error)$/)||(r+=", "+p+" : "+O);(C=r.split(", ")).sort(),r=C.join(", "),I.push({t:d._utime,title:H.localeDate(d._utime),value:"Success (IP "+d.ipAddr+")"+r})}if(s._loginHistory.failedLogin)for(w=0,m=(D=s._loginHistory.failedLogin).length;w<m;w++){for(p in r="",d=D[w])O=d[p],p.match(/^(_utime|ipAddr|error)$/)||(r+=", "+p+" : "+O);(C=r.split(", ")).sort(),r=C.join(", "),I.push({t:d._utime,title:H.localeDate(d._utime),value:"Error "+d.error+" (IP "+d.ipAddr+")"+r})}delete s._loginHistory,I.sort(function(e,t){return t.t-e.t}),L.push({title:"__loginHistory__",nodes:I})}for(p in I=[],s)O=s[p],I.push({title:p,value:O});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("^"+H.impPrefix+".+$"))?(console.log(i,"-> real attribute"),B.push(i)):P.push(i);return I=P.concat(B),L.push({title:"__attributesAndMacros__",nodes:I}),{_utime:E,nodes:L}};return H.currentScope=e,t=e.$modelValue.session,o.get(scriptname+"sessions/"+d+"/"+t).then(function(e){return H.currentSession=n(e.data),H.currentSession.id=t}),H.showT=!1},H.localeDate=function(e){return new Date(1e3*e).toLocaleString()},H.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)},H.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},H.getLanguage=function(e){return H.lang=e,H.form="white",H.init(),H.showM=!1},n=function(e,t,n){t=t.match(/#!?\/(\w+)/);return d="global",null===t?H.type="_whatToTrace":t[1].match(/^(persistent|offline)$/)?(d=RegExp.$1,H.type="_session_uid"):H.type=t[1],H.init()},H.$on("$locationChangeSuccess",n),p=0,H.updateTree=function(i,s,l,u,e,t){var a,c,n;if(H.waiting=!0,c=f[H.type]||("_updateTime"===H.type?f._startTime:f._whatToTrace),a=c[l](H.type,i,e),25<t&&g[H.type]&&(n=g[H.type](H.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,H.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&&(H.total=e.total)}return H.waiting=!1},function(e){return H.waiting=!1}),console.log("Selection",d),H.navssoStyle={color:"#777"},H.offlineStyle={color:"#777"},H.persistentStyle={color:"#777"},"global"===d&&(H.navssoStyle={color:"#333"}),"offline"===d&&(H.offlineStyle={color:"#333"}),"persistent"===d)return H.persistentStyle={color:"#333"}},H.init=function(){return H.waiting=!0,H.data=[],H.currentScope=null,H.currentSession=null,e.all([t.init(H.lang),H.updateTree("",H.data,0,0)]).then(function(){return H.waiting=!1},function(e){return H.waiting=!1}),H.activeModule="sessions",H.myStyle={color:"#ffb84d"}},n=r.path().match(/^\/(\w+)/),H.type=n?n[1]:"_whatToTrace"}])}.call(this);