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,c,p,n,d,f,g,h,_,o,r,m,y,T,v,w,S,$,b,B,D,L,A,P,C,l,x,k,i,I,O,u,a,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(o in s)(a=s[o])?("string"==typeof s&&a.match(/; /)&&(s[o]=a.split("; ")),"object"!=typeof s[o]&&("_password".match(new RegExp("\b"+o+"\b"))?s[o]="********":o.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)?s[o]=H.localeDate(a):o.match(/^(_startTime|_updateTime)$/)&&(s[o]=H.strToLocaleDate(a)))):delete s[o];for(p in l=[],M){for(i=[],g=0,m=(c=M[p]).length;g<m;g++)if(t=c[g],s[t])if(s[t].toString().match(/"type":\s*"(?:TOTP|U2F|UBK|WebAuthn)"/)){for(i.push({title:"type",value:"name",epoch:"date",td:"0"}),h=0,y=(e=JSON.parse(s[t])).length;h<y;h++){for(o in x=e[h])a=x[o],"type"===o&&(O=a),"name"===o&&(b=a),"epoch"===o&&(f=a);i.push({title:O,value:b,epoch:f,td:"1"})}delete s[t]}else if(s[t].toString().match(/"rp":\s*"[\w-]+"/)){for(i.push({title:"RP",value:"scope",epoch:"date",td:"0"}),_=0,T=(e=JSON.parse(s[t])).length;_<T;_++){for(o in D=e[_])a=D[o],"rp"===o&&(O=a),"scope"===o&&(b=a),"epoch"===o&&(f=a);i.push({title:O,value:b,epoch:f,td:"2"})}delete s[t]}else s[t].toString().match(/\w+/)&&i.push({title:t,value:s[t],epoch:""}),delete s[t];else delete s[t];0<i.length&&l.push({title:"__"+p+"__",nodes:i})}if(R("^openid","OpenID"),R("^notification_(.+)","__notificationsDone__"),s._loginHistory){if(u=[],s._loginHistory.successLogin)for($=0,v=(P=s._loginHistory.successLogin).length;$<v;$++){for(o in n="",r=P[$])a=r[o],o.match(/^(_utime|ipAddr|error)$/)||(n+=", "+o+" : "+a);(I=n.split(", ")).sort(),n=I.join(", "),u.push({t:r._utime,title:H.localeDate(r._utime),value:"Success (IP "+r.ipAddr+")"+n})}if(s._loginHistory.failedLogin)for(B=0,w=(C=s._loginHistory.failedLogin).length;B<w;B++){for(o in n="",r=C[B])a=r[o],o.match(/^(_utime|ipAddr|error)$/)||(n+=", "+o+" : "+a);(I=n.split(", ")).sort(),n=I.join(", "),u.push({t:r._utime,title:H.localeDate(r._utime),value:"Error "+r.error+" (IP "+r.ipAddr+")"+n})}delete s._loginHistory,u.sort(function(e,t){return t.t-e.t}),l.push({title:"__loginHistory__",nodes:u})}for(o in u=[],s)a=s[o],u.push({title:o,value:a});for(u.sort(function(e,t){return e.title>t.title?1:e.title<t.title?-1:0}),A=[],k=[],L=0,S=u.length;L<S;L++)(d=u[L]).title.match(new RegExp("^"+H.impPrefix+".+$"))?(console.log(d,"-> real attribute"),A.push(d)):k.push(d);return u=k.concat(A),l.push({title:"__attributesAndMacros__",nodes:u}),{_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),n=o-e<sessionTTL||r.path().match(/^\/persistent/),"msg"===t?(console.log("Return msg"),n?"info":"warning"):"style"===t?(console.log("Return style"),n?{}:{color:"#627990","font-style":"italic"}):(console.log("Return isValid"),n)},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},H.$on("$locationChangeSuccess",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()}),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"},H.bannerStyle={"background-color":""+window.bannerColor}},n=r.path().match(/^\/(\w+)/),H.type=n?n[1]:"_whatToTrace"}])}.call(this);