lemonldap-ng/lemonldap-ng-manager/site/htdocs/static/js/sessions.min.js
2019-12-20 16:07:52 +01:00

2 lines
8.8 KiB
JavaScript

(function(){var e,t,n,o,r,i,s;o=25,s={_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}]},i={_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),n>0&&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),n>3?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}},t="_password",e={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"]},r={session:[{title:"deleteSession",icon:"trash"}],home:[]},n=angular.module("llngSessionsExplorer",["ui.tree","ui.bootstrap","llApp"]),n.controller("SessionsExplorerCtrl",["$scope","$translator","$location","$q","$http",function(n,u,l,a,c){var p,d,g,f;return n.links=links,n.menulinks=menulinks,n.staticPrefix=staticPrefix,n.scriptname=scriptname,n.formPrefix=formPrefix,n.impPrefix=impPrefix,n.sessionTTL=sessionTTL,n.availableLanguages=availableLanguages,n.waiting=!0,n.showM=!1,n.showT=!0,n.data=[],n.currentScope=null,n.currentSession=null,n.menu=r,n.translateP=u.translateP,n.translate=u.translate,n.translateTitle=function(e){return u.translateField(e,"title")},f="global",n.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(n.currentNode,n);break;case"string":n[e.action]();break;default:console.log(typeof e.action)}return n.showM=!1},n.deleteOIDCConsent=function(e,t){var o;return o=angular.element(".data-"+t),o.remove(),n.waiting=!0,c.delete(scriptname+"sessions/OIDCConsent/"+f+"/"+n.currentSession.id+"?rp="+e+"&epoch="+t).then(function(e){return n.waiting=!1},function(e){return n.waiting=!1}),n.showT=!1},n.deleteSession=function(){return n.waiting=!0,c.delete(scriptname+"sessions/"+f+"/"+n.currentSession.id).then(function(e){return n.currentSession=null,n.currentScope.remove(),n.waiting=!1},function(e){return n.currentSession=null,n.currentScope.remove(),n.waiting=!1})},n.stoggle=function(e){var t;return t=e.$modelValue,0===t.nodes.length&&n.updateTree(t.value,t.nodes,t.level,t.over,t.query,t.count),e.toggle()},n.displaySession=function(o){var r,i;return i=function(o){var r,i,s,u,l,a,c,p,d,g,f,h,_,m,T,y,w,v,S,$,B,b,D,L,A,P,x,C,I,k,O,R,E,H,M,U;r=function(e,t){var n,r,i,s;i=[],r=new RegExp(e);for(n in o)s=o[n],n.match(r)&&s&&(i.push({title:n,value:s}),delete o[n]);if(i.length>0)return I.push({title:t,nodes:i})},E=o._utime,g=o._session_id;for(_ in o)U=o[_],U?("string"==typeof o&&U.match(/; /)&&(o[_]=U.split("; ")),"object"!=typeof o[_]&&(t.match(new RegExp("\b"+_+"\b"))?o[_]="********":_.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)?o[_]=n.localeDate(U):_.match(/^(_startTime|_updateTime)$/)&&(o[_]=n.strToLocaleDate(U)))):delete o[_];I=[];for(l in e){for(u=e[l],R=[],d=0,T=u.length;d<T;d++)if(s=u[d],o[s])if(o[s].toString().match(/"type":\s*"(?:TOTP|U2F|UBK)"/)){for(R.push({title:"type",value:"name",epoch:"date",td:"0"}),i=JSON.parse(o[s]),f=0,y=i.length;f<y;f++){k=i[f];for(_ in k)U=k[_],"type"===_&&(H=U),"name"===_&&(b=U),"epoch"===_&&(p=U);R.push({title:H,value:b,epoch:p,td:"1"})}delete o[s]}else if(o[s].toString().match(/"rp":\s*"[\w-]+"/)){for(R.push({title:"rp",value:"scope",epoch:"date",td:"0"}),i=JSON.parse(o[s]),h=0,w=i.length;h<w;h++){L=i[h];for(_ in L)U=L[_],"rp"===_&&(H=U),"scope"===_&&(b=U),"epoch"===_&&(p=U);R.push({title:H,value:b,epoch:p,td:"2"})}delete o[s]}else o[s].toString().match(/\w+/)?(R.push({title:s,value:o[s],epoch:""}),delete o[s]):delete o[s];else delete o[s];R.length>0&&I.push({title:"__"+l+"__",nodes:R})}if(r("^openid","OpenID"),r("^notification_(.+)","__notificationsDone__"),o._loginHistory){if(M=[],o._loginHistory.successLogin)for(x=o._loginHistory.successLogin,B=0,v=x.length;B<v;B++){m=x[B],a="";for(_ in m)U=m[_],_.match(/^(_utime|ipAddr|error)$/)||(a+=", "+_+" : "+U);M.push({t:m._utime,title:n.localeDate(m._utime),value:"Success (IP "+m.ipAddr+")"+a})}if(o._loginHistory.failedLogin)for(C=o._loginHistory.failedLogin,D=0,S=C.length;D<S;D++){m=C[D],a="";for(_ in m)U=m[_],_.match(/^(_utime|ipAddr|error)$/)||(a+=", "+_+" : "+U);M.push({t:m._utime,title:n.localeDate(m._utime),value:"Error "+m.error+" (IP "+m.ipAddr+")"+a})}delete o._loginHistory,M.sort(function(e,t){return t.t-e.t}),I.push({title:"__loginHistory__",nodes:M})}M=[];for(_ in o)U=o[_],M.push({title:_,value:U});for(M.sort(function(e,t){return e.title>t.title?1:e.title<t.title?-1:0}),P=[],O=[],A=0,$=M.length;A<$;A++)c=M[A],c.title.match(new RegExp("^"+n.impPrefix+".+$"))?(console.log(c,"-> real attribute"),P.push(c)):O.push(c);return M=O.concat(P),I.push({title:"__attributesAndMacros__",nodes:M}),{_utime:E,id:g,nodes:I}},n.currentScope=o,r=o.$modelValue.session,c.get(scriptname+"sessions/"+f+"/"+r).then(function(e){return n.currentSession=i(e.data)}),n.showT=!1},n.localeDate=function(e){var t;return t=new Date(1e3*e),t.toLocaleString()},n.isValid=function(e,t){var n,o,r;return r=l.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||l.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)},n.strToLocaleDate=function(e){var t,n;return t=e.match(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/),t.length?(n=new Date(t[1]+"-"+t[2]+"-"+t[3]+"T"+t[4]+":"+t[5]+":"+t[6]),n.toLocaleString()):e},n.getLanguage=function(e){return n.lang=e,n.form="white",n.init(),n.showM=!1},g=function(e,t,o){var r;return r=t.match(/#!?\/(\w+)/),f="global",null===r?n.type="_whatToTrace":r[1].match(/^(persistent|offline)$/)?(f=RegExp.$1,n.type="_session_uid"):n.type=r[1],n.init()},n.$on("$locationChangeSuccess",g),p=0,n.updateTree=function(e,t,r,u,l,a){var d,g,h;return n.waiting=!0,g=s[n.type]?s[n.type]:"_updateTime"===n.type?s._startTime:s._whatToTrace,d=g[r](n.type,e,l),a>o&&i[n.type]&&(h=i[n.type](n.type,e,r,u,l))?(u++,d=h,r-=1):u=0,c.get(scriptname+"sessions/"+f+"?"+d).then(function(o){var i,s,l,a,c;if(i=o.data,i.result){for(c=i.values,s=0,l=c.length;s<l;s++)a=c[s],p++,a.id="node"+p,r<g.length-1&&(a.nodes=[],a.level=r+1,a.query=d,a.over=u,n.type.match(/^(?:start|update)Time$/)&&(a.title=a.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"))),t.push(a);""===e&&(n.total=i.total)}return n.waiting=!1},function(e){return n.waiting=!1})},n.init=function(){return n.waiting=!0,n.data=[],n.currentScope=null,n.currentSession=null,a.all([u.init(n.lang),n.updateTree("",n.data,0,0)]).then(function(){return n.waiting=!1},function(e){return n.waiting=!1}),n.activeModule="sessions",n.myStyle={color:"#ffb84d"}},d=l.path().match(/^\/(\w+)/),n.type=d?d[1]:"_whatToTrace"}])}).call(this);
//# sourceMappingURL=lemonldap-ng-manager/site/htdocs/static/js/sessions.min.js.map