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

1 line
9.1 KiB
JavaScript

(function(){var M,s,g,h;h={_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"],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"],oidcConsents:["_oidcConsents"]},s={session:[{title:"deleteSession",icon:"trash"}],home:[]},angular.module("llngSessionsExplorer",["ui.tree","ui.bootstrap","llApp"]).controller("SessionsExplorerCtrl",["$scope","$translator","$location","$q","$http",function(H,t,i,e,o){var d,n,r,f;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=s,H.translateP=t.translateP,H.translate=t.translate,H.translateTitle=function(e){return t.translateField(e,"title")},f="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;return i=document.querySelectorAll(".data-"+t),H.waiting=!0,o.delete(scriptname+"sessions/OIDCConsent/"+f+"/"+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/"+f+"/"+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;return 0===(t=e.$modelValue).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;return n=function(s){var e,t,n,o,r,i,l,u,a,c,p,d,f,g,h,_,m,y,T,w,v,S,$,B,b,D,L,A,P,x,C,I,k,R,O,E;for(d in e=function(e,t){var n,o,r,i;for(n in r=[],o=new RegExp(e),s)i=s[n],n.match(o)&&i&&(r.push({title:n,value:i}),delete s[n]);if(0<r.length)return A.push({title:t,nodes:r})},k=s._utime,s)(E=s[d])?("string"==typeof s&&E.match(/; /)&&(s[d]=E.split("; ")),"object"!=typeof s[d]&&("_password".match(new RegExp("\b"+d+"\b"))?s[d]="********":d.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)?s[d]=H.localeDate(E):d.match(/^(_startTime|_updateTime)$/)&&(s[d]=H.strToLocaleDate(E)))):delete s[d];for(r in A=[],M){for(C=[],a=0,g=(o=M[r]).length;a<g;a++)if(n=o[a],s[n])if(s[n].toString().match(/"type":\s*"(?:TOTP|U2F|UBK)"/)){for(C.push({title:"type",value:"name",epoch:"date",td:"0"}),c=0,h=(t=JSON.parse(s[n])).length;c<h;c++){for(d in P=t[c])E=P[d],"type"===d&&(R=E),"name"===d&&(v=E),"epoch"===d&&(u=E);C.push({title:R,value:v,epoch:u,td:"1"})}delete s[n]}else if(s[n].toString().match(/"rp":\s*"[\w-]+"/)){for(C.push({title:"RP",value:"scope",epoch:"date",td:"0"}),p=0,_=(t=JSON.parse(s[n])).length;p<_;p++){for(d in $=t[p])E=$[d],"rp"===d&&(R=E),"scope"===d&&(v=E),"epoch"===d&&(u=E);C.push({title:R,value:v,epoch:u,td:"2"})}delete s[n]}else s[n].toString().match(/\w+/)&&C.push({title:n,value:s[n],epoch:""}),delete s[n];else delete s[n];0<C.length&&A.push({title:"__"+r+"__",nodes:C})}if(e("^openid","OpenID"),e("^notification_(.+)","__notificationsDone__"),s._loginHistory){if(O=[],s._loginHistory.successLogin)for(w=0,m=(D=s._loginHistory.successLogin).length;w<m;w++){for(d in i="",f=D[w])E=f[d],d.match(/^(_utime|ipAddr|error)$/)||(i+=", "+d+" : "+E);(I=i.split(", ")).sort(),i=I.join(", "),O.push({t:f._utime,title:H.localeDate(f._utime),value:"Success (IP "+f.ipAddr+")"+i})}if(s._loginHistory.failedLogin)for(S=0,y=(L=s._loginHistory.failedLogin).length;S<y;S++){for(d in i="",f=L[S])E=f[d],d.match(/^(_utime|ipAddr|error)$/)||(i+=", "+d+" : "+E);(I=i.split(", ")).sort(),i=I.join(", "),O.push({t:f._utime,title:H.localeDate(f._utime),value:"Error "+f.error+" (IP "+f.ipAddr+")"+i})}delete s._loginHistory,O.sort(function(e,t){return t.t-e.t}),A.push({title:"__loginHistory__",nodes:O})}for(d in O=[],s)E=s[d],O.push({title:d,value:E});for(O.sort(function(e,t){return e.title>t.title?1:e.title<t.title?-1:0}),b=[],x=[],B=0,T=O.length;B<T;B++)(l=O[B]).title.match(new RegExp("^"+H.impPrefix+".+$"))?(console.log(l,"-> real attribute"),b.push(l)):x.push(l);return O=x.concat(b),A.push({title:"__attributesAndMacros__",nodes:O}),{_utime:k,nodes:A}},H.currentScope=e,t=e.$modelValue.session,o.get(scriptname+"sessions/"+f+"/"+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,o,r;return r=i.path(),o=Date.now()/1e3,console.log("Path",r),console.log("Session epoch",e),console.log("Current date",o),console.log("Session TTL",sessionTTL),n=o-e<sessionTTL||i.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;return(t=e.match(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/)).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},r=function(e,t,n){var o;return o=t.match(/#!?\/(\w+)/),f="global",null===o?H.type="_whatToTrace":o[1].match(/^(persistent|offline)$/)?(f=RegExp.$1,H.type="_session_uid"):H.type=o[1],H.init()},H.$on("$locationChangeSuccess",r),d=0,H.updateTree=function(s,l,u,a,e,t){var c,p,n;if(H.waiting=!0,p=h[H.type]?h[H.type]:"_updateTime"===H.type?h._startTime:h._whatToTrace,c=p[u](H.type,s,e),25<t&&g[H.type]&&(n=g[H.type](H.type,s,u,a,e))?(a++,c=n,u-=1):a=0,o.get(scriptname+"sessions/"+f+"?"+c).then(function(e){var t,n,o,r,i;if((t=e.data).result){for(n=0,o=(i=t.values).length;n<o;n++)r=i[n],d++,r.id="node"+d,u<p.length-1&&(r.nodes=[],r.level=u+1,r.query=c,r.over=a,H.type.match(/^(?:start|update)Time$/)&&(r.title=r.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"))),l.push(r);""===s&&(H.total=t.total)}return H.waiting=!1},function(e){return H.waiting=!1}),console.log("Selection",f),H.navssoStyle={color:"#777"},H.offlineStyle={color:"#777"},H.persistentStyle={color:"#777"},"global"===f&&(H.navssoStyle={color:"#333"}),"offline"===f&&(H.offlineStyle={color:"#333"}),"persistent"===f)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=i.path().match(/^\/(\w+)/),H.type=n?n[1]:"_whatToTrace"}])}).call(this);