CheckState plugin (fixes: #1400)

This commit is contained in:
Xavier Guimard 2018-05-15 21:20:31 +02:00
parent 86283952b0
commit e40d8ccc1e
14 changed files with 106 additions and 4 deletions

View File

@ -129,7 +129,7 @@
.\" ======================================================================== .\" ========================================================================
.\" .\"
.IX Title "llng-fastcgi-server 1" .IX Title "llng-fastcgi-server 1"
.TH llng-fastcgi-server 1 "2018-03-22" "perl v5.26.1" "User Contributed Perl Documentation" .TH llng-fastcgi-server 1 "2018-05-13" "perl v5.26.2" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents. .\" way too many mistakes in technical documents.
.if n .ad l .if n .ad l

View File

@ -753,6 +753,12 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
'cfgVersion' => { 'cfgVersion' => {
'type' => 'text' 'type' => 'text'
}, },
'checkState' => {
'type' => 'bool'
},
'checkStateSecret' => {
'type' => 'text'
},
'checkXSS' => { 'checkXSS' => {
'default' => 1, 'default' => 1,
'type' => 'bool' 'type' => 'bool'

View File

@ -368,6 +368,14 @@ sub attributes {
type => 'bool', type => 'bool',
documentation => 'Enable StayConnected plugin', documentation => 'Enable StayConnected plugin',
}, },
checkState => {
type => 'bool',
documentation => 'Enable CheckState plugin',
},
checkStateSecret => {
type => 'text',
documentation => 'Secret token for CheckState plugin',
},
# Loggers (ini only) # Loggers (ini only)
logLevel => { logLevel => {

View File

@ -635,6 +635,11 @@ sub tree {
help => 'autoSignin.html', help => 'autoSignin.html',
nodes => ['autoSigninRules'], nodes => ['autoSigninRules'],
}, },
{
title => 'stateCheck',
help => 'checkstate.html',
nodes => [ 'checkState', 'checkStateSecret', ],
},
] ]
}, },
{ {

View File

@ -146,6 +146,8 @@
"cfgVersion":"عملية ضبط الإصدارات", "cfgVersion":"عملية ضبط الإصدارات",
"checkXSS":"تحقق من هجمات XSS", "checkXSS":"تحقق من هجمات XSS",
"clickHereToForce":"انقر هنا لإجبار", "clickHereToForce":"انقر هنا لإجبار",
"checkState":"Activation",
"checkStateSecret":"Shared secret",
"choiceParams":"اختيارالإعدادات", "choiceParams":"اختيارالإعدادات",
"chooseLogo":"اختيار الشعار", "chooseLogo":"اختيار الشعار",
"chooseSkin":"اختيار الغلاف", "chooseSkin":"اختيار الغلاف",
@ -704,6 +706,7 @@
"SSLVar":"حقل الشهادة الرقمية المستخرجة", "SSLVar":"حقل الشهادة الرقمية المستخرجة",
"SSLVarIf":"حقل الشهادة الرقمية المستخرجة الشرطية", "SSLVarIf":"حقل الشهادة الرقمية المستخرجة الشرطية",
"ssoSessions":"جلسات السسو", "ssoSessions":"جلسات السسو",
"stateCheck":"State Check",
"stayConnected":"الاتصالات المستمرة", "stayConnected":"الاتصالات المستمرة",
"successfullySaved":"تم الحفظ بنجاح", "successfullySaved":"تم الحفظ بنجاح",
"storePassword":"تخزين كلمة مرور المستخدم في بيانات الجلسة", "storePassword":"تخزين كلمة مرور المستخدم في بيانات الجلسة",

View File

@ -146,6 +146,8 @@
"cfgVersion":"Configuration version", "cfgVersion":"Configuration version",
"checkXSS":"Check XSS attacks", "checkXSS":"Check XSS attacks",
"clickHereToForce":"Click here to force", "clickHereToForce":"Click here to force",
"checkState":"Activation",
"checkStateSecret":"Shared secret",
"choiceParams":"Choice parameters", "choiceParams":"Choice parameters",
"chooseLogo":"Choose logo", "chooseLogo":"Choose logo",
"chooseSkin":"Choose skin", "chooseSkin":"Choose skin",
@ -704,6 +706,7 @@
"SSLVar":"Extracted certificate field", "SSLVar":"Extracted certificate field",
"SSLVarIf":"Conditional extracted certificate field", "SSLVarIf":"Conditional extracted certificate field",
"ssoSessions":"SSO sessions", "ssoSessions":"SSO sessions",
"stateCheck":"State Check",
"stayConnected":"Persistent connections", "stayConnected":"Persistent connections",
"successfullySaved":"Successfully saved", "successfullySaved":"Successfully saved",
"storePassword":"Store user password in session datas", "storePassword":"Store user password in session datas",

View File

@ -146,6 +146,8 @@
"cfgVersion":"Version de la configuration", "cfgVersion":"Version de la configuration",
"checkXSS":"Contrôler les attaques XSS", "checkXSS":"Contrôler les attaques XSS",
"clickHereToForce":"Cliquer ici pour forcer", "clickHereToForce":"Cliquer ici pour forcer",
"checkState":"Activation",
"checkStateSecret":"Secret partagé",
"choiceParams":"Paramètres des choix", "choiceParams":"Paramètres des choix",
"chooseLogo":"Choisir le logo", "chooseLogo":"Choisir le logo",
"chooseSkin":"Choisir le thème", "chooseSkin":"Choisir le thème",
@ -704,6 +706,7 @@
"SSLVar":"Champ extrait du certificat", "SSLVar":"Champ extrait du certificat",
"SSLVarIf":"Champ conditionnel extrait du certificat", "SSLVarIf":"Champ conditionnel extrait du certificat",
"ssoSessions":"Sessions SSO", "ssoSessions":"Sessions SSO",
"stateCheck":"Vérification de l'état",
"stayConnected":"Connexions persistantes", "stayConnected":"Connexions persistantes",
"successfullySaved":"Sauvegarde effectuée", "successfullySaved":"Sauvegarde effectuée",
"storePassword":"Stocke le mot de passe de l'utilisateur en session", "storePassword":"Stocke le mot de passe de l'utilisateur en session",

View File

@ -146,6 +146,8 @@
"cfgVersion":"Versione configurazione", "cfgVersion":"Versione configurazione",
"checkXSS":"Verifica attacchi XSS", "checkXSS":"Verifica attacchi XSS",
"clickHereToForce":"Clicca qui per forzare", "clickHereToForce":"Clicca qui per forzare",
"checkState":"Activation",
"checkStateSecret":"Shared secret",
"choiceParams":"Scelta parametri", "choiceParams":"Scelta parametri",
"chooseLogo":"Scegli logo", "chooseLogo":"Scegli logo",
"chooseSkin":"Scegli interfaccia", "chooseSkin":"Scegli interfaccia",
@ -704,6 +706,7 @@
"SSLVar":"Campo certificato estratto", "SSLVar":"Campo certificato estratto",
"SSLVarIf":"Campo di certificato estratto condizionale", "SSLVarIf":"Campo di certificato estratto condizionale",
"ssoSessions":"Sessioni SSO", "ssoSessions":"Sessioni SSO",
"stateCheck":"State Check",
"stayConnected":"Connessioni persistenti", "stayConnected":"Connessioni persistenti",
"successfullySaved":"Salvato con successo", "successfullySaved":"Salvato con successo",
"storePassword":"Memorizzare la password dell'utente nei dati di sessione", "storePassword":"Memorizzare la password dell'utente nei dati di sessione",

View File

@ -146,6 +146,8 @@
"cfgVersion":"Phiên bản cấu hình", "cfgVersion":"Phiên bản cấu hình",
"checkXSS":"Kiểm tra tấn công XSS", "checkXSS":"Kiểm tra tấn công XSS",
"clickHereToForce":"Nhấp vào đây để bắt buộc", "clickHereToForce":"Nhấp vào đây để bắt buộc",
"checkState":"Activation",
"checkStateSecret":"Shared secret",
"choiceParams":"Các tham số lựa chọn", "choiceParams":"Các tham số lựa chọn",
"chooseLogo":"Chọn logo", "chooseLogo":"Chọn logo",
"chooseSkin":"Chọn giao diện", "chooseSkin":"Chọn giao diện",
@ -659,8 +661,8 @@
"save":"Lưu", "save":"Lưu",
"saveReport":"Lưu báo cáo", "saveReport":"Lưu báo cáo",
"savingConfirmation":"Lưu xác nhận", "savingConfirmation":"Lưu xác nhận",
"secondFactors":"Second factors",
"search":"Search ...", "search":"Search ...",
"secondFactors":"Second factors",
"securedCookie":"Cookie bảo mật (SSL)", "securedCookie":"Cookie bảo mật (SSL)",
"security":"An ninh", "security":"An ninh",
"serverError":"Lỗi máy chủ", "serverError":"Lỗi máy chủ",
@ -704,6 +706,7 @@
"SSLVar":"Trích xuất trường chứng chỉ", "SSLVar":"Trích xuất trường chứng chỉ",
"SSLVarIf":"Trích xuất trường chứng chỉ có điều kiện", "SSLVarIf":"Trích xuất trường chứng chỉ có điều kiện",
"ssoSessions":"Phiên SSO", "ssoSessions":"Phiên SSO",
"stateCheck":"State Check",
"stayConnected":"Duy trì kết nối", "stayConnected":"Duy trì kết nối",
"successfullySaved":"Lưu thành công", "successfullySaved":"Lưu thành công",
"storePassword":"Lưu trữ mật khẩu người dùng trong các dữ liệu phiên", "storePassword":"Lưu trữ mật khẩu người dùng trong các dữ liệu phiên",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -94,6 +94,7 @@ lib/Lemonldap/NG/Portal/Password/Null.pm
lib/Lemonldap/NG/Portal/Password/REST.pm lib/Lemonldap/NG/Portal/Password/REST.pm
lib/Lemonldap/NG/Portal/Plugins/AutoSignin.pm lib/Lemonldap/NG/Portal/Plugins/AutoSignin.pm
lib/Lemonldap/NG/Portal/Plugins/CDA.pm lib/Lemonldap/NG/Portal/Plugins/CDA.pm
lib/Lemonldap/NG/Portal/Plugins/CheckState.pm
lib/Lemonldap/NG/Portal/Plugins/GrantSession.pm lib/Lemonldap/NG/Portal/Plugins/GrantSession.pm
lib/Lemonldap/NG/Portal/Plugins/History.pm lib/Lemonldap/NG/Portal/Plugins/History.pm
lib/Lemonldap/NG/Portal/Plugins/MailReset.pm lib/Lemonldap/NG/Portal/Plugins/MailReset.pm

View File

@ -22,6 +22,7 @@ our @pList = (
grantSessionRule => '::Plugins::GrantSession', grantSessionRule => '::Plugins::GrantSession',
upgradeSession => '::Plugins::Upgrade', upgradeSession => '::Plugins::Upgrade',
autoSigninRules => '::Plugins::AutoSignin', autoSigninRules => '::Plugins::AutoSignin',
checkState => '::Plugins::CheckState',
); );
##@method list enabledPlugins ##@method list enabledPlugins

View File

@ -0,0 +1,66 @@
# Check state plugin
#
# test if portal is well loaded. If user/pasword parameters are set, it tests
# also login process
package Lemonldap::NG::Portal::Plugins::CheckState;
use strict;
use Mouse;
our $VERSION = '2.0.0';
extends 'Lemonldap::NG::Portal::Main::Plugin';
# INITIALIZATION
sub init {
my ($self) = @_;
unless ( $self->conf->{checkStateSecret} ) {
$self->logger->error(
'checkStateSecret is required for "check state" plugin');
return 0;
}
$self->addUnauthRoute( checkstate => 'check', ['GET'] );
return 1;
}
sub check {
my ( $self, $req ) = @_;
my @rep;
unless ($req->param('secret')
and $req->param('secret') eq $self->conf->{checkStateSecret} )
{
return $self->p->sendError( $req, 'Bad secret' );
}
$req->steps( [ 'controlUrl', @{ $self->p->beforeAuth } ] );
my $res = $self->p->process($req);
if ( $res > 0 ) {
push @rep, "Bad result before auth: $res";
}
if ( my $user = $req->param('user') and my $pwd = $req->param('password') )
{
# Note that "extractFormInfo" isn't launched due to "token"
$req->user($user);
$req->datas->{password} = $pwd;
$req->steps(
[
'getUser', 'authenticate',
@{ $self->p->betweenAuthAndDatas }, $self->p->sessionDatas,
@{ $self->p->afterDatas }
]
);
if ( $res = $self->p->process( $req, ) ) {
push @rep, "Bad result during auth: $res";
}
$self->p->deleteSession($req);
}
if (@rep) {
return $self->p->sendError( $req, join( ",\n", @rep ), 500 );
}
else {
return $self->p->sendJSONresponse( $req, { result => 1 } );
}
}
1;