WIP - delete U2F key attributes from manager with U2F module

This commit is contained in:
Christophe Maudoux 2018-02-27 12:01:33 +01:00
parent 26d4667fd2
commit 31398c78bc
6 changed files with 50 additions and 17 deletions

View File

@ -318,7 +318,7 @@ Examples:
$self->addRoute( books => { ':bookId' => 'book' }, ['GET'] );
booId parameter will be stored in $req->params('bookId');
bookId parameter will be stored in $req->params('bookId');
=item to manage http://.../books/127/pages/5 with page(), use:

View File

@ -50,6 +50,35 @@ sub delSession {
return $self->sendJSONresponse( $req, { result => 1 } );
}
sub delU2FKey {
my ( $self, $req ) = @_;
return $self->sendJSONresponse( $req, { result => 1 } )
if ( $self->{demoMode} );
my $mod = $self->getMod($req)
or return $self->sendError( $req, undef, 400 );
my $id = $req->params('sessionId')
or return $self->sendError( $req, 'sessionId is missing', 400 );
# Try to read session
my $apacheSession = $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 );
Lemonldap::NG::Handler::PSGI::Main->localUnlog( $req, $id );
if ( $apacheSession->error ) {
return $self->sendError( $req, $apacheSession->error, 200 );
}
return $self->sendJSONresponse( $req, { result => 1 } );
}
sub session {
my ( $self, $req, $id, $skey ) = @_;
my ( %h, $res );

View File

@ -33,17 +33,17 @@ sub addRoutes {
# READ
->addRoute( sessions => { ':sessionType' => 'sessions' }, ['GET'] )
# UPDATE
# DELETEU2FKey
->addRoute(
sessions => { ':sessionType' => { ':sessionId' => 'delSession' } },
['PUT']
)
sessions => { ':sessionType' => { ':sessionId' => 'delU2FKey' } },
['POST']
);
# DELETE
->addRoute(
sessions => { ':sessionType' => { ':sessionId' => 'delSession' } },
['DELETE']
);
#~ ->addRoute(
#~ sessions => { ':sessionType' => { ':sessionId' => 'delSession' } },
#~ ['DELETE']
#);
$self->setTypes($conf);

View File

@ -138,16 +138,16 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location',
# SESSION MANAGEMENT
# Delete
# Delete U2F Key
$scope.deleteU2FKey = ->
$scope.waiting = true
$http['put']("#{scriptname}sessions/#{sessionType}/#{$scope.currentSession.id}").then (response) ->
# $scope.currentSession = null
# $scope.currentScope.remove()
$http['post']("#{scriptname}sessions/#{sessionType}/#{$scope.currentSession.id}").then (response) ->
$scope.currentSession = null
$scope.currentScope.remove()
$scope.waiting = false
, (resp) ->
# $scope.currentSession = null
# $scope.currentScope.remove()
$scope.currentSession = null
$scope.currentScope.remove()
$scope.waiting = false
# Open node

View File

@ -164,9 +164,13 @@
};
$scope.deleteU2FKey = function() {
$scope.waiting = true;
return $http['put'](scriptname + "sessions/" + sessionType + "/" + $scope.currentSession.id).then(function(response) {
return $http['post'](scriptname + "sessions/" + sessionType + "/" + $scope.currentSession.id).then(function(response) {
$scope.currentSession = null;
$scope.currentScope.remove();
return $scope.waiting = false;
}, function(resp) {
$scope.currentSession = null;
$scope.currentScope.remove();
return $scope.waiting = false;
});
};

File diff suppressed because one or more lines are too long