WIP - Append U2F module to manage users U2F Key (delete only at the moment)

This commit is contained in:
Christophe Maudoux 2018-03-01 00:07:31 +01:00
parent 31398c78bc
commit 9dfce47dfb
10 changed files with 57 additions and 35 deletions

24
.gitignore vendored
View File

@ -1 +1,25 @@
node_modules node_modules
e2e-tests/conf/
lemonldap-ng-common/MYMETA.json
lemonldap-ng-common/MYMETA.yml
lemonldap-ng-common/Makefile
lemonldap-ng-common/blib/
lemonldap-ng-common/pm_to_blib
lemonldap-ng-handler/MYMETA.json
lemonldap-ng-handler/MYMETA.yml
lemonldap-ng-handler/Makefile
lemonldap-ng-handler/blib/
lemonldap-ng-handler/pm_to_blib
lemonldap-ng-manager/MYMETA.json
lemonldap-ng-manager/MYMETA.yml
lemonldap-ng-manager/Makefile
lemonldap-ng-manager/blib/
lemonldap-ng-manager/pm_to_blib
lemonldap-ng-portal/MYMETA.json
lemonldap-ng-portal/MYMETA.yml
lemonldap-ng-portal/Makefile
lemonldap-ng-portal/blib/
lemonldap-ng-portal/t/
.gitignore
lemonldap-ng-portal/pm_to_blib
e2e-tests/lemonldap-ng.ini

View File

@ -32,6 +32,7 @@ useRedirectOnError = 0
[manager] [manager]
enabledModules = conf, sessions, notifications, U2F
protection = manager protection = manager
staticPrefix = /static staticPrefix = /static
languages = fr, en, vi, ar languages = fr, en, vi, ar

View File

@ -33,6 +33,8 @@ sub hAttr {
$_[0]->{hiddenAttributes} || $_[0]->conf->{hiddenAttributes}; $_[0]->{hiddenAttributes} || $_[0]->conf->{hiddenAttributes};
} }
### SEE LEMONLDAP::NG::COMMON::SESSION FOR AVAILABLE FUNCTIONS
sub delSession { sub delSession {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
return $self->sendJSONresponse( $req, { result => 1 } ) return $self->sendJSONresponse( $req, { result => 1 } )
@ -61,20 +63,17 @@ sub delU2FKey {
# Try to read session # Try to read session
my $apacheSession = $self->getApacheSession( $mod, $id ) my $session = $self->getApacheSession( $mod, $id )
or return $self->sendError( $req, undef, 400 ); or return $self->sendError( $req, undef, 400 );
my %session = %{ $apacheSession->data }; # Delete U2F key attributs and update session
$session{_session_uid} = 'TOTO'; $session->data->{_u2fKeyHandle} = 'TOF';
$session->data->{_u2fUserKey} = 'TOF';
$apacheSession->update(\%session); $session->update( \%{$session->data} );
#return $self->sendError( $req, $session->data->{_session_uid}, 666 );
Lemonldap::NG::Handler::PSGI::Main->localUnlog( $req, $id ); Lemonldap::NG::Handler::PSGI::Main->localUnlog( $req, $id );
if ( $apacheSession->error ) { if ( $session->error ) {
return $self->sendError( $req, $apacheSession->error, 200 ); return $self->sendError( $req, $session->error, 200 );
} }
return $self->sendJSONresponse( $req, { result => 1 } ); return $self->sendJSONresponse( $req, { result => 1 } );
} }

View File

@ -90,7 +90,7 @@ sub init {
$self->defaultRoute( $working[0]->defaultRoute ); $self->defaultRoute( $working[0]->defaultRoute );
my $linksIcons = my $linksIcons =
{ 'conf' => 'cog', 'sessions' => 'duplicate', 'notifications' => 'bell' }; { 'conf' => 'cog', 'sessions' => 'duplicate', 'notifications' => 'bell', 'U2F' => 'wrench' };
$self->links( [] ); $self->links( [] );
for ( my $i = 0 ; $i < @links ; $i++ ) { for ( my $i = 0 ; $i < @links ; $i++ ) {

View File

@ -31,19 +31,19 @@ sub addRoutes {
$self->addRoute( 'u2f.html', undef, ['GET'] ) $self->addRoute( 'u2f.html', undef, ['GET'] )
# READ # READ
->addRoute( sessions => { ':sessionType' => 'sessions' }, ['GET'] ) ->addRoute( u2f => { ':sessionType' => 'sessions' }, ['GET'] )
# DELETEU2FKey # DELETE U2F KEY ATTRIBUTS
->addRoute( ->addRoute(
sessions => { ':sessionType' => { ':sessionId' => 'delU2FKey' } }, u2f => { ':sessionType' => { ':sessionId' => 'delU2FKey' } },
['POST'] ['DELETE']
); );
# DELETE # UPDATE U2F KEY ATTRIBUTS
#~ ->addRoute( # ->addRoute(
#~ sessions => { ':sessionType' => { ':sessionId' => 'delSession' } }, # u2f => { ':sessionType' => { ':sessionId' => { ':updateSession' } },
#~ ['DELETE'] # ['PUT']
#); #);
$self->setTypes($conf); $self->setTypes($conf);
@ -56,7 +56,7 @@ sub addRoutes {
# II. DISPLAY METHODS # # II. DISPLAY METHODS #
####################### #######################
sub sessions { sub u2f {
my ( $self, $req, $session, $skey ) = @_; my ( $self, $req, $session, $skey ) = @_;
# Case 1: only one session is required # Case 1: only one session is required

View File

@ -1,5 +1,5 @@
### ###
# U2F manager # Session explorer
### ###
# Max number of session to display (see overScheme) # Max number of session to display (see overScheme)
@ -119,7 +119,7 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location',
$scope.translate = $translator.translate $scope.translate = $translator.translate
$scope.translateTitle = (node) -> $scope.translateTitle = (node) ->
$translator.translateField node, 'title' $translator.translateField node, 'title'
sessionType = 'Persistent' sessionType = 'global'
# Handle menu items # Handle menu items
$scope.menuClick = (button) -> $scope.menuClick = (button) ->
@ -138,10 +138,10 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location',
# SESSION MANAGEMENT # SESSION MANAGEMENT
# Delete U2F Key # Delete
$scope.deleteU2FKey = -> $scope.deleteU2FKey = ->
$scope.waiting = true $scope.waiting = true
$http['post']("#{scriptname}sessions/#{sessionType}/#{$scope.currentSession.id}").then (response) -> $http['delete']("#{scriptname}u2f/#{sessionType}/#{$scope.currentSession.id}").then (response) ->
$scope.currentSession = null $scope.currentSession = null
$scope.currentScope.remove() $scope.currentScope.remove()
$scope.waiting = false $scope.waiting = false

View File

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.10.0 // Generated by CoffeeScript 1.9.3
/* /*
* Session explorer * Session explorer

View File

@ -1,7 +1,7 @@
// Generated by CoffeeScript 1.9.3 // Generated by CoffeeScript 1.9.3
/* /*
* U2F manager * Session explorer
*/ */
(function() { (function() {
@ -141,7 +141,7 @@
$scope.translateTitle = function(node) { $scope.translateTitle = function(node) {
return $translator.translateField(node, 'title'); return $translator.translateField(node, 'title');
}; };
sessionType = 'Persistent'; sessionType = 'global';
$scope.menuClick = function(button) { $scope.menuClick = function(button) {
if (button.popup) { if (button.popup) {
window.open(button.popup); window.open(button.popup);
@ -164,7 +164,7 @@
}; };
$scope.deleteU2FKey = function() { $scope.deleteU2FKey = function() {
$scope.waiting = true; $scope.waiting = true;
return $http['post'](scriptname + "sessions/" + sessionType + "/" + $scope.currentSession.id).then(function(response) { return $http['delete'](scriptname + "u2f/" + sessionType + "/" + $scope.currentSession.id).then(function(response) {
$scope.currentSession = null; $scope.currentSession = null;
$scope.currentScope.remove(); $scope.currentScope.remove();
return $scope.waiting = false; return $scope.waiting = false;

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
<TMPL_INCLUDE NAME="header.tpl"> <TMPL_INCLUDE NAME="header.tpl">
<title>LemonLDAP::NG U2F manager</title> <title>LemonLDAP::NG sessions explorer</title>
</head> </head>
<body ng-app="llngSessionsExplorer" ng-controller="SessionsExplorerCtrl" ng-csp> <body ng-app="llngSessionsExplorer" ng-controller="SessionsExplorerCtrl" ng-csp>
@ -15,7 +15,6 @@
<div class="navbar navbar-default"> <div class="navbar navbar-default">
<div class="navbar-collapse"> <div class="navbar-collapse">
<ul class="nav navbar-nav" role="grid"> <ul class="nav navbar-nav" role="grid">
<!--
<li uib-dropdown> <li uib-dropdown>
<a id="navsso" name="menu" uib-dropdown-toggle data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="glyphicon glyphicon-user"></i> {{translate('ssoSessions')}} <span class="caret"></span></a> <a id="navsso" name="menu" uib-dropdown-toggle data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="glyphicon glyphicon-user"></i> {{translate('ssoSessions')}} <span class="caret"></span></a>
<ul uib-dropdown-menu aria-labelled-by="navsso"> <ul uib-dropdown-menu aria-labelled-by="navsso">
@ -26,7 +25,6 @@
<li><a id="a-updatetime" href="#/_updateTime" role="row"><i class="glyphicon glyphicon-hourglass"></i> {{translate('_updateTime')}}</a></li> <li><a id="a-updatetime" href="#/_updateTime" role="row"><i class="glyphicon glyphicon-hourglass"></i> {{translate('_updateTime')}}</a></li>
</ul> </ul>
</li> </li>
-->
<li><a id="a-persistent" href="#/persistent" role="row"><i class="glyphicon glyphicon-exclamation-sign"></i> {{translate('persistentSessions')}}</a></li> <li><a id="a-persistent" href="#/persistent" role="row"><i class="glyphicon glyphicon-exclamation-sign"></i> {{translate('persistentSessions')}}</a></li>
</ul> </ul>
</div> </div>