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
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]
enabledModules = conf, sessions, notifications, U2F
protection = manager
staticPrefix = /static
languages = fr, en, vi, ar

View File

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

View File

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

View File

@ -31,19 +31,19 @@ sub addRoutes {
$self->addRoute( 'u2f.html', undef, ['GET'] )
# READ
->addRoute( sessions => { ':sessionType' => 'sessions' }, ['GET'] )
->addRoute( u2f => { ':sessionType' => 'sessions' }, ['GET'] )
# DELETEU2FKey
# DELETE U2F KEY ATTRIBUTS
->addRoute(
sessions => { ':sessionType' => { ':sessionId' => 'delU2FKey' } },
['POST']
u2f => { ':sessionType' => { ':sessionId' => 'delU2FKey' } },
['DELETE']
);
# DELETE
#~ ->addRoute(
#~ sessions => { ':sessionType' => { ':sessionId' => 'delSession' } },
#~ ['DELETE']
#);
# UPDATE U2F KEY ATTRIBUTS
# ->addRoute(
# u2f => { ':sessionType' => { ':sessionId' => { ':updateSession' } },
# ['PUT']
#);
$self->setTypes($conf);
@ -56,7 +56,7 @@ sub addRoutes {
# II. DISPLAY METHODS #
#######################
sub sessions {
sub u2f {
my ( $self, $req, $session, $skey ) = @_;
# 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)
@ -119,7 +119,7 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location',
$scope.translate = $translator.translate
$scope.translateTitle = (node) ->
$translator.translateField node, 'title'
sessionType = 'Persistent'
sessionType = 'global'
# Handle menu items
$scope.menuClick = (button) ->
@ -138,10 +138,10 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location',
# SESSION MANAGEMENT
# Delete U2F Key
# Delete
$scope.deleteU2FKey = ->
$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.currentScope.remove()
$scope.waiting = false

View File

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

View File

@ -1,7 +1,7 @@
// Generated by CoffeeScript 1.9.3
/*
* U2F manager
* Session explorer
*/
(function() {
@ -141,7 +141,7 @@
$scope.translateTitle = function(node) {
return $translator.translateField(node, 'title');
};
sessionType = 'Persistent';
sessionType = 'global';
$scope.menuClick = function(button) {
if (button.popup) {
window.open(button.popup);
@ -164,7 +164,7 @@
};
$scope.deleteU2FKey = function() {
$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.currentScope.remove();
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">
<title>LemonLDAP::NG U2F manager</title>
<title>LemonLDAP::NG sessions explorer</title>
</head>
<body ng-app="llngSessionsExplorer" ng-controller="SessionsExplorerCtrl" ng-csp>
@ -15,7 +15,6 @@
<div class="navbar navbar-default">
<div class="navbar-collapse">
<ul class="nav navbar-nav" role="grid">
<!--
<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>
<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>
</ul>
</li>
-->
<li><a id="a-persistent" href="#/persistent" role="row"><i class="glyphicon glyphicon-exclamation-sign"></i> {{translate('persistentSessions')}}</a></li>
</ul>
</div>