diff --git a/lemonldap-ng-handler/t/test-psgi-lib.pm b/lemonldap-ng-handler/t/test-psgi-lib.pm index 368b381bb..d72bf0e16 100644 --- a/lemonldap-ng-handler/t/test-psgi-lib.pm +++ b/lemonldap-ng-handler/t/test-psgi-lib.pm @@ -53,7 +53,7 @@ sub init { . $now . ',"uid":"dwho","_issuerDB":"Null","_session_id":"f5eec18ebb9bc96352595e2d8ce962e8ecf7af7c9a98cb9a43f9cd181cf4b545","authenticationLevel":1,"_whatToTrace":"dwho","_auth":"Demo","_utime":' . $now - . ',"loginHistory":{"successLogin":[{"ipAddr":"127.0.0.1","_utime":' + . ',"_loginHistory":{"successLogin":[{"ipAddr":"127.0.0.1","_utime":' . $now . '}]},"cn":"Doctor Who","mail":"dwho@badwolf.org"}'; close F; diff --git a/lemonldap-ng-manager/site/coffee/sessions.coffee b/lemonldap-ng-manager/site/coffee/sessions.coffee index 49d232f4c..d6196622f 100644 --- a/lemonldap-ng-manager/site/coffee/sessions.coffee +++ b/lemonldap-ng-manager/site/coffee/sessions.coffee @@ -217,21 +217,21 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location', _insert '^notification_(.+)', '__notificationsDone__' # 4. Add session history if exists - if session.loginHistory + if session._loginHistory tmp = [] - if session.loginHistory.successLogin - for l in session.loginHistory.successLogin + if session._loginHistory.successLogin + for l in session._loginHistory.successLogin tmp.push t: l._utime title: $scope.localeDate l._utime value: "Success (IP #{l.ipAddr})" - if session.loginHistory.failedLogin - for l in session.loginHistory.failedLogin + if session._loginHistory.failedLogin + for l in session._loginHistory.failedLogin tmp.push t: l._utime title: $scope.localeDate l._utime value: "#{l.error} (IP #{l.ipAddr})" - delete session.loginHistory + delete session._loginHistory tmp.sort (a,b) -> a.t - b.t res.push diff --git a/lemonldap-ng-manager/site/htdocs/static/js/sessions.js b/lemonldap-ng-manager/site/htdocs/static/js/sessions.js index c7d437f80..12ac6fd4e 100644 --- a/lemonldap-ng-manager/site/htdocs/static/js/sessions.js +++ b/lemonldap-ng-manager/site/htdocs/static/js/sessions.js @@ -254,10 +254,10 @@ } _insert('^openid', 'OpenID'); _insert('^notification_(.+)', '__notificationsDone__'); - if (session.loginHistory) { + if (session._loginHistory) { tmp = []; - if (session.loginHistory.successLogin) { - ref = session.loginHistory.successLogin; + if (session._loginHistory.successLogin) { + ref = session._loginHistory.successLogin; for (j = 0, len1 = ref.length; j < len1; j++) { l = ref[j]; tmp.push({ @@ -267,8 +267,8 @@ }); } } - if (session.loginHistory.failedLogin) { - ref1 = session.loginHistory.failedLogin; + if (session._loginHistory.failedLogin) { + ref1 = session._loginHistory.failedLogin; for (k = 0, len2 = ref1.length; k < len2; k++) { l = ref1[k]; tmp.push({ @@ -278,7 +278,7 @@ }); } } - delete session.loginHistory; + delete session._loginHistory; tmp.sort(function(a, b) { return a.t - b.t; }); diff --git a/lemonldap-ng-manager/site/htdocs/static/js/sessions.min.js b/lemonldap-ng-manager/site/htdocs/static/js/sessions.min.js index 3ce51388f..35fafb25a 100644 --- a/lemonldap-ng-manager/site/htdocs/static/js/sessions.min.js +++ b/lemonldap-ng-manager/site/htdocs/static/js/sessions.min.js @@ -1 +1 @@ -(function(){var c,e,d,b,g,f,a;b=25;a={_whatToTrace:[function(i,h){return"groupBy=substr("+i+",1)"},function(i,h){return i+"="+h+"*&groupBy="+i},function(i,h){return i+"="+h}],ipAddr:[function(i,h){return"groupBy=net("+i+",16,1)"},function(i,h){if(!h.match(/:/)){h=h+"."}return i+"="+h+"*&groupBy=net("+i+",32,2)"},function(i,h){if(!h.match(/:/)){h=h+"."}return i+"="+h+"*&groupBy=net("+i+",48,3)"},function(i,h){if(!h.match(/:/)){h=h+"."}return i+"="+h+"*&groupBy=net("+i+",128,4)"},function(i,h){return i+"="+h+"&groupBy=_whatToTrace"},function(i,h,j){return j.replace(/\&groupBy.*$/,"")+("&_whatToTrace="+h)}],_startTime:[function(i,h){return"groupBy=substr("+i+",8)"},function(i,h){return i+"="+h+"*&groupBy=substr("+i+",10)"},function(i,h){return i+"="+h+"*&groupBy=substr("+i+",11)"},function(i,h){return i+"="+h+"*&groupBy=substr("+i+",12)"},function(i,h){return i+"="+h+"*&groupBy=_whatToTrace"},function(i,h,j){console.log(i);console.log(h);console.log(j);return j.replace(/\&groupBy.*$/,"")+("&_whatToTrace="+h)}],doubleIp:[function(i,h){return i},function(i,h){return"_whatToTrace="+h+"&groupBy=ipAddr"},function(i,h,j){return j.replace(/\&groupBy.*$/,"")+("&ipAddr="+h)}]};f={_whatToTrace:function(i,h,k,j){if(k===1){return i+"="+h+"*&groupBy=substr("+i+","+(k+j)+")"}else{return null}},ipAddr:function(i,h,k,j){if(k>0&&k<4){return i+"="+h+"*&groupBy=net("+i+","+(16*k+4*(j+1))+",2)"}else{return null}}};e="_password";c={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"]};g={session:[{title:"deleteSession",icon:"trash"}],home:[]};d=angular.module("llngSessionsExplorer",["ui.tree","ui.bootstrap","llApp"]);d.controller("SessionsExplorerCtrl",["$scope","$translator","$location","$q","$http",function(p,h,i,j,m){var n,l,k,o;p.links=links;p.menulinks=menulinks;p.staticPrefix=staticPrefix;p.scriptname=scriptname;p.formPrefix=formPrefix;p.availableLanguages=availableLanguages;p.waiting=true;p.showM=false;p.showT=true;p.data=[];p.currentScope=null;p.currentSession=null;p.menu=g;p.translateP=h.translateP;p.translate=h.translate;p.translateTitle=function(q){return h.translateField(q,"title")};o="global";p.menuClick=function(q){if(q.popup){window.open(q.popup)}else{if(!q.action){q.action=q.title}switch(typeof q.action){case"function":q.action(p.currentNode,p);break;case"string":p[q.action]();break;default:console.log(typeof q.action)}}return p.showM=false};p.deleteSession=function(){p.waiting=true;return m["delete"](scriptname+"sessions/"+o+"/"+p.currentSession.id).then(function(q){p.currentSession=null;p.currentScope.remove();return p.waiting=false},function(q){p.currentSession=null;p.currentScope.remove();return p.waiting=false})};p.stoggle=function(q){var r;r=q.$modelValue;if(r.nodes.length===0){p.updateTree(r.value,r.nodes,r.level,r.over,r.query,r.count)}return q.toggle()};p.displaySession=function(r){var s,q;q=function(t){var y,A,E,C,G,J,B,I,H,O,F,K,x,w,u,z,N,M,v,L,D;A=function(P){return P};y=function(S,U){var Q,R,P,T;P=[];R=new RegExp(S);for(Q in t){T=t[Q];if(Q.match(R)&&T){P.push({title:Q,value:T});delete t[Q]}}if(P.length>0){return N.push({title:U,nodes:P})}};v=t._utime;B=t._session_id;for(O in t){D=t[O];if(!D){delete t[O]}else{if(typeof t==="string"&&D.match(/; /)){t[O]=D.split("; ")}if(typeof t[O]!=="object"){if(e.match(new RegExp("\b"+O+"\b"))){t[O]="********"}else{if(O.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)){t[O]=p.localeDate(D)}else{if(O.match(/^(_startTime|_updateTime)$/)){t[O]=A(D)}}}}}}N=[];for(G in c){C=c[G];M=[];for(J=0,K=C.length;J0){N.push({title:"__"+G+"__",nodes:M})}}y("^openid","OpenID");y("^notification_(.+)","__notificationsDone__");if(t.loginHistory){L=[];if(t.loginHistory.successLogin){u=t.loginHistory.successLogin;for(I=0,x=u.length;IP.title){return 1}else{if(Q.titleb&&f[p.type]){if(t=f[p.type](p.type,y,q,v,x)){v++;w=t;q=q-1}else{v=0}}else{v=0}return m.get(scriptname+"sessions/"+o+"?"+w).then(function(A){var D,B,z,E,C;D=A.data;if(D.result){C=D.values;for(B=0,z=C.length;B0&&k<4){return i+"="+h+"*&groupBy=net("+i+","+(16*k+4*(j+1))+",2)"}else{return null}}};e="_password";c={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"]};g={session:[{title:"deleteSession",icon:"trash"}],home:[]};d=angular.module("llngSessionsExplorer",["ui.tree","ui.bootstrap","llApp"]);d.controller("SessionsExplorerCtrl",["$scope","$translator","$location","$q","$http",function(p,h,i,j,m){var n,l,k,o;p.links=links;p.menulinks=menulinks;p.staticPrefix=staticPrefix;p.scriptname=scriptname;p.formPrefix=formPrefix;p.availableLanguages=availableLanguages;p.waiting=true;p.showM=false;p.showT=true;p.data=[];p.currentScope=null;p.currentSession=null;p.menu=g;p.translateP=h.translateP;p.translate=h.translate;p.translateTitle=function(q){return h.translateField(q,"title")};o="global";p.menuClick=function(q){if(q.popup){window.open(q.popup)}else{if(!q.action){q.action=q.title}switch(typeof q.action){case"function":q.action(p.currentNode,p);break;case"string":p[q.action]();break;default:console.log(typeof q.action)}}return p.showM=false};p.deleteSession=function(){p.waiting=true;return m["delete"](scriptname+"sessions/"+o+"/"+p.currentSession.id).then(function(q){p.currentSession=null;p.currentScope.remove();return p.waiting=false},function(q){p.currentSession=null;p.currentScope.remove();return p.waiting=false})};p.stoggle=function(q){var r;r=q.$modelValue;if(r.nodes.length===0){p.updateTree(r.value,r.nodes,r.level,r.over,r.query,r.count)}return q.toggle()};p.displaySession=function(r){var s,q;q=function(t){var y,A,E,C,G,J,B,I,H,O,F,K,x,w,u,z,N,M,v,L,D;A=function(P){return P};y=function(S,U){var Q,R,P,T;P=[];R=new RegExp(S);for(Q in t){T=t[Q];if(Q.match(R)&&T){P.push({title:Q,value:T});delete t[Q]}}if(P.length>0){return N.push({title:U,nodes:P})}};v=t._utime;B=t._session_id;for(O in t){D=t[O];if(!D){delete t[O]}else{if(typeof t==="string"&&D.match(/; /)){t[O]=D.split("; ")}if(typeof t[O]!=="object"){if(e.match(new RegExp("\b"+O+"\b"))){t[O]="********"}else{if(O.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)){t[O]=p.localeDate(D)}else{if(O.match(/^(_startTime|_updateTime)$/)){t[O]=A(D)}}}}}}N=[];for(G in c){C=c[G];M=[];for(J=0,K=C.length;J0){N.push({title:"__"+G+"__",nodes:M})}}y("^openid","OpenID");y("^notification_(.+)","__notificationsDone__");if(t._loginHistory){L=[];if(t._loginHistory.successLogin){u=t._loginHistory.successLogin;for(I=0,x=u.length;IP.title){return 1}else{if(Q.titleb&&f[p.type]){if(t=f[p.type](p.type,y,q,v,x)){v++;w=t;q=q-1}else{v=0}}else{v=0}return m.get(scriptname+"sessions/"+o+"?"+w).then(function(A){var D,B,z,E,C;D=A.data;if(D.result){C=D.values;for(B=0,z=C.length;B[0] eq 'LoginHistory' ) { $moduleHash->{'SUCCESS_LOGIN'} = $self->p->mkSessionArray( - $req->{sessionInfo}->{loginHistory}->{successLogin}, + $req->{sessionInfo}->{_loginHistory}->{successLogin}, "", 0, 0 ); $moduleHash->{'FAILED_LOGIN'} = $self->p->mkSessionArray( - $req->{sessionInfo}->{loginHistory}->{failedLogin}, + $req->{sessionInfo}->{_loginHistory}->{failedLogin}, "", 0, 1 ); } push @$displayModules, $moduleHash; diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm index 7ff217e04..54dfb008f 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm @@ -775,7 +775,7 @@ sub registerLogin { return unless ( $self->conf->{loginHistoryEnabled} and defined $req->authResult ); - my $history = $req->sessionInfo->{loginHistory} ||= {}; + my $history = $req->sessionInfo->{_loginHistory} ||= {}; my $type = ( $req->authResult > 0 ? 'failed' : 'success' ) . 'Login'; $history->{$type} ||= []; $self->logger->debug("Current login saved into $type"); @@ -793,7 +793,7 @@ sub registerLogin { if ( scalar @{ $history->{$type} } > $self->conf->{ $type . "Number" } ); # Save into persistent session - $self->updatePersistentSession( $req, { loginHistory => $history, } ); + $self->updatePersistentSession( $req, { _loginHistory => $history, } ); } # put main session data into a hash ref diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/History.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/History.pm index d16c17285..53fcdeb40 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/History.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/History.pm @@ -19,16 +19,16 @@ sub run { $self->logger->debug('History asked'); $req->info( ( - $req->sessionInfo->{loginHistory}->{successLogin} + $req->sessionInfo->{_loginHistory}->{successLogin} ? $self->mkSessionArray( - $req->sessionInfo->{loginHistory}->{successLogin}, + $req->sessionInfo->{_loginHistory}->{successLogin}, 'lastLogins', 0, 0 ) : "" ) . ( - $req->sessionInfo->{loginHistory}->{failedLogin} + $req->sessionInfo->{_loginHistory}->{failedLogin} ? $self->mkSessionArray( - $req->sessionInfo->{loginHistory}->{failedLogin}, + $req->sessionInfo->{_loginHistory}->{failedLogin}, 'lastFailedLogins', 0, 1 ) : "" ) diff --git a/lemonldap-ng-portal/t/sessions2/6e30af4ffa5689b3e49a104d1b160d316db2b2161a0f45776994eed19dbdc101 b/lemonldap-ng-portal/t/sessions2/6e30af4ffa5689b3e49a104d1b160d316db2b2161a0f45776994eed19dbdc101 index 158770517..ae85a9334 100644 --- a/lemonldap-ng-portal/t/sessions2/6e30af4ffa5689b3e49a104d1b160d316db2b2161a0f45776994eed19dbdc101 +++ b/lemonldap-ng-portal/t/sessions2/6e30af4ffa5689b3e49a104d1b160d316db2b2161a0f45776994eed19dbdc101 @@ -1 +1 @@ -{"authenticationLevel":0,"_auth":"Demo","_whatToTrace":"dwho","_session_kind":"SSO","_user":"dwho","hGroups":{},"cn":"Doctor Who","_lastAuthnUTime":1464295296,"_session_id":"6e30af4ffa5689b3e49a104d1b160d316db2b2161a0f45776994eed19dbdc101","_passwordDB":"Demo","_issuerDB":"Null","_updateTime":"20160526224136","UA":"Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0","uid":"dwho","groups":"","_utime":1464295296,"_timezone":"2","_url":"http://manager.example.com:19876/","loginHistory":{"successLogin":[{"ipAddr":"127.0.0.1","_utime":1464295296}]},"ipAddr":"127.0.0.1","mail":"dwho@badwolf.org","_startTime":"20160526224136","_userDB":"Demo"} +{"authenticationLevel":0,"_auth":"Demo","_whatToTrace":"dwho","_session_kind":"SSO","_user":"dwho","hGroups":{},"cn":"Doctor Who","_lastAuthnUTime":1464295296,"_session_id":"6e30af4ffa5689b3e49a104d1b160d316db2b2161a0f45776994eed19dbdc101","_passwordDB":"Demo","_issuerDB":"Null","_updateTime":"20160526224136","UA":"Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0","uid":"dwho","groups":"","_utime":1464295296,"_timezone":"2","_url":"http://manager.example.com:19876/","_loginHistory":{"successLogin":[{"ipAddr":"127.0.0.1","_utime":1464295296}]},"ipAddr":"127.0.0.1","mail":"dwho@badwolf.org","_startTime":"20160526224136","_userDB":"Demo"}