Commit 110974cc authored by Christophe Maudoux's avatar Christophe Maudoux 🐛
Browse files

Display rules (#2458)

parent 60cbb6d5
......@@ -2,7 +2,7 @@ package Lemonldap::NG::Portal::Plugins::CheckDevOps;
use strict;
use Mouse;
use JSON qw(from_json to_json);
use JSON qw(from_json);
use Lemonldap::NG::Portal::Main::Constants qw(
PE_OK
PE_ERROR
......@@ -66,9 +66,9 @@ sub display {
}
sub run {
my ( $self, $req ) = @_;
my ( $msg, $alert );
my $headers = [];
my ( $self, $req ) = @_;
my ( $headers, $rules ) = ( [], [] );
my ( $msg, $alert );
# Check token
if ( $self->ottRule->( $req, {} ) ) {
......@@ -88,6 +88,7 @@ sub run {
$token = $self->ott->createToken();
}
# Prepare form
my $params = {
PORTAL => $self->conf->{portal},
MAIN_LOGO => $self->conf->{portalMainLogo},
......@@ -108,29 +109,56 @@ sub run {
my $json = eval { from_json( $req->param('checkDevOpsFile') ) };
if ($@) {
# Prepare form params
$msg = 'PE' . PE_BAD_DEVOPS_FILE;
$alert = 'alert-danger';
$json = '';
$self->userLogger->error("CheckDevOps: bad 'rules.json' file ($@)");
}
else {
my $vhost = $self->p->HANDLER->resolveAlias($req);
my $handler = $self->p->HANDLER;
my $vhost = $handler->resolveAlias($req);
# Removed forbidden session attributes
foreach my $v ( split /\s+/, $self->conf->{hiddenAttributes} ) {
foreach ( keys %{ $json->{headers} } ) {
if ( $json->{headers}->{$_} eq '$' . $v ) {
delete $json->{headers}->{$_};
my $user = $req->userData->{ $self->conf->{whatToTrace} };
$self->userLogger->warn(
"CheckDevOps: $user try to retrieve hidden attribute $v"
);
}
}
}
# Compile headers & rules
$handler->headersInit( undef, { $vhost => $json->{headers} } );
$handler->locationRulesInit( undef, { $vhost => $json->{rules} } );
# Compile headers
$handler->headersInit( undef, { $vhost => $json->{headers} } );
$headers = $handler->checkHeaders( $req, $req->userData );
my $list = join ', ', map { "$_->{key}:$_->{value}" } @$headers;
$self->logger->debug("CheckDevOps compiled headers: $list");
my $headers_list = join ', ', map { "$_->{key}:$_->{value}" } @$headers;
$self->logger->debug("CheckDevOps compiled headers: $headers_list");
# Compile rules
@$rules = map {
my ( $sub, $flag ) = $handler->conditionSub( $json->{rules}->{$_} );
{
uri => $_,
access => $sub->( $req, $req->userData )
? 'allowed'
: 'forbidden'
}
} keys %{ $json->{rules} };
my $rules_list = join ', ', map { "$_->{uri}:$_->{access}" } @$rules;
$self->logger->debug("CheckDevOps compiled rules: $rules_list");
# Prepare form
# Prepare form params
$msg = 'checkDevOps';
$alert = 'alert-info';
$json = $req->param('checkDevOpsFile');
$self->logger->debug("CheckDevOps provided file: $json");
$json = JSON->new->ascii->pretty->encode($json); # Pretty print
}
# Prepare form
my $params = {
PORTAL => $self->conf->{portal},
MAIN_LOGO => $self->conf->{portalMainLogo},
......@@ -140,6 +168,7 @@ sub run {
ALERTE => $alert,
FILE => $json,
HEADERS => $headers,
RULES => $rules,
TOKEN => (
$self->ottRule->( $req, {} )
? $self->ott->createToken()
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimal special characters:",
"passwordPolicyNone":"You are free to choose your password!",
"passwordPolicySpecialChar":"Allowed special characters:",
"pasteHere":"Paste your file here...",
"ppGrace":"المصادقات المتبقية، غير كلمة المرور الخاصة بك!",
"proxyError":"بوابة سيئة: غير قادر على الانضمام لالخادم البعيد",
"pwd":"كلمة المرور",
......@@ -268,6 +269,7 @@
"resetPwd":"إعادة تعيين كلمة المرور الخاصة بي",
"rest2f":"Verification code",
"rightsReloadNeedsLogout":" إعادة تحميل الحقوق تحتاج إلى تسجيل الخروج وتسجيل الدخول مرة أخرى",
"rules":"RULES",
"scope":"نطاق",
"search":"Search",
"searchingAttributes":"Searching attributes",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimal special characters:",
"passwordPolicyNone":"You are free to choose your password!",
"passwordPolicySpecialChar":"Allowed special characters:",
"pasteHere":"Paste your file here...",
"ppGrace":"verbleibende Authentifizierungen, bitte Passwort ändern !",
"proxyError":"Bad gateway: Der Remote-Server kann nicht verbunden werden",
"pwd":"Passwort",
......@@ -268,6 +269,7 @@
"resetPwd":"Mein Passwort zurücksetzen",
"rest2f":"Verification code",
"rightsReloadNeedsLogout":"Zum Neuladen der Rechte musst du dich ab- und wieder anmelden",
"rules":"RULES",
"scope":"Scope",
"search":"Search",
"searchingAttributes":"Searching attributes",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimal special characters:",
"passwordPolicyNone":"You are free to choose your password!",
"passwordPolicySpecialChar":"Allowed special characters:",
"pasteHere":"Paste your file here...",
"ppGrace":"authentications remaining, change your password!",
"proxyError":"Bad gateway: unable to join remote server",
"pwd":"Password",
......@@ -268,6 +269,7 @@
"resetPwd":"Reset my password",
"rest2f":"Verification code",
"rightsReloadNeedsLogout":"Rights reloads need to logout and login again",
"rules":"RULES",
"scope":"Scope",
"search":"Search",
"searchingAttributes":"Searching attributes",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimal special characters:",
"passwordPolicyNone":"You are free to choose your password!",
"passwordPolicySpecialChar":"Allowed special characters:",
"pasteHere":"Paste your file here...",
"ppGrace":"autenticaciones restantes, ¡cambie su contraseña!.",
"proxyError":"Puerta de enlace no válida: servidor remoto inalcanzable",
"pwd":"Contraseña",
......@@ -268,6 +269,7 @@
"resetPwd":"Reiniciar mi contraseña",
"rest2f":"Código de verificación",
"rightsReloadNeedsLogout":"La recarga de derechos necesita desconectarse y conectarse de nuevo",
"rules":"RULES",
"scope":"Alcance",
"search":"Buscar",
"searchingAttributes":"Searching attributes",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimal special characters:",
"passwordPolicyNone":"You are free to choose your password!",
"passwordPolicySpecialChar":"Allowed special characters:",
"pasteHere":"Paste your file here...",
"ppGrace":"authentications remaining, change your password!",
"proxyError":"Bad gateway: unable to join remote server",
"pwd":"Salasana",
......@@ -268,6 +269,7 @@
"resetPwd":"Palauta salasanani?",
"rest2f":"Verification code",
"rightsReloadNeedsLogout":"Rights reloads need to logout and login again",
"rules":"RULES",
"scope":"Scope",
"search":"Search",
"searchingAttributes":"Searching attributes",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimum de caractères spéciaux :",
"passwordPolicyNone":"Vous êtes libre de choisir votre mot de passe !",
"passwordPolicySpecialChar":"Caractères spéciaux autorisés :",
"pasteHere":"Coller votre fichier ici...",
"ppGrace": "authentifications restantes, changez votre mot de passe !",
"proxyError": "Mauvaise passerelle : impossible de joindre le serveur amont",
"pwd":"Mot de passe",
......@@ -268,6 +269,7 @@
"resetPwd":"Réinitialiser mon mot de passe",
"rest2f":"Code de vérification",
"rightsReloadNeedsLogout": "Le rechargement des droits nécessite une déconnexion",
"rules":"REGLES",
"scope": "Informations",
"search":"Chercher",
"searchingAttributes":"Attributs de recherche",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimal special characters:",
"passwordPolicyNone":"You are free to choose your password!",
"passwordPolicySpecialChar":"Allowed special characters:",
"pasteHere":"Paste your file here...",
"ppGrace":"autenticazioni restanti, modifica la tua password!",
"proxyError":"Gateway errata: impossibile associarsi a un server remoto",
"pwd":"Password",
......@@ -268,6 +269,7 @@
"resetPwd":"Reimpostare la password",
"rest2f":"Verification code",
"rightsReloadNeedsLogout":"Le ricariche dei diritti necessitano di disconnettersi e di riconnettersi",
"rules":"RULES",
"scope":"Ambito",
"search":"Ricerca",
"searchingAttributes":"Searching attributes",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimal special characters:",
"passwordPolicyNone":"You are free to choose your password!",
"passwordPolicySpecialChar":"Allowed special characters:",
"pasteHere":"Paste your file here...",
"ppGrace":"authentications remaining, change your password!",
"proxyError":"Bad gateway: unable to join remote server",
"pwd":"Password",
......@@ -268,6 +269,7 @@
"resetPwd":"Reset my password",
"rest2f":"Verification code",
"rightsReloadNeedsLogout":"Rights reloads need to logout and login again",
"rules":"RULES",
"scope":"Scope",
"search":"Search",
"searchingAttributes":"Searching attributes",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimalna liczba znaków specjalnych:",
"passwordPolicyNone":"Możesz sam wybrać hasło!",
"passwordPolicySpecialChar":"Dozwolone znaki specjalne:",
"pasteHere":"Paste your file here...",
"ppGrace":"pozostałe uwierzytelnienia, zmień hasło!",
"proxyError":"Zła brama: nie można dołączyć się do zdalnego serwera",
"pwd":"Hasło",
......@@ -268,6 +269,7 @@
"resetPwd":"Zresetuj moje hasło",
"rest2f":"Kod weryfikacyjny",
"rightsReloadNeedsLogout":"Przeładowania uprawnień wymaga wylogowania i ponownego zalogowania",
"rules":"RULES",
"scope":"Zakres",
"search":"Szukaj",
"searchingAttributes":"Searching attributes",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimal special characters:",
"passwordPolicyNone":"You are free to choose your password!",
"passwordPolicySpecialChar":"Allowed special characters:",
"pasteHere":"Paste your file here...",
"ppGrace":"authentications remaining, change your password!",
"proxyError":"Bad gateway: unable to join remote server",
"pwd":"Password",
......@@ -268,6 +269,7 @@
"resetPwd":"Reset my password",
"rest2f":"Verification code",
"rightsReloadNeedsLogout":"Rights reloads need to logout and login again",
"rules":"RULES",
"scope":"Scope",
"search":"Search",
"searchingAttributes":"Searching attributes",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimal special characters:",
"passwordPolicyNone":"You are free to choose your password!",
"passwordPolicySpecialChar":"Allowed special characters:",
"pasteHere":"Paste your file here...",
"ppGrace":"authentications remaining, change your password!",
"proxyError":"Bad gateway: unable to join remote server",
"pwd":"Password",
......@@ -268,6 +269,7 @@
"resetPwd":"Reset my password",
"rest2f":"Verification code",
"rightsReloadNeedsLogout":"Rights reloads need to logout and login again",
"rules":"RULES",
"scope":"Scope",
"search":"Search",
"searchingAttributes":"Searching attributes",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimum özel karakter sayısı:",
"passwordPolicyNone":"Parolanızı seçmekte özgürsünüz!",
"passwordPolicySpecialChar":"İzin verilen özel karakter sayısı:",
"pasteHere":"Paste your file here...",
"ppGrace":"kimlik doğrulaması kaldı, parolanızı değiştirin!",
"proxyError":"Kötü ağ geçidi: uzak sunucuya katılamıyor",
"pwd":"Parola",
......@@ -268,6 +269,7 @@
"resetPwd":"Parolamı sıfırla",
"rest2f":"Doğrulama kodu",
"rightsReloadNeedsLogout":"Yetkiler yeniden yüklendiğinde çıkış yapıp tekrar giriş yapmanız gerekir",
"rules":"RULES",
"scope":"Kapsam",
"search":"Ara",
"searchingAttributes":"Searching attributes",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimal special characters:",
"passwordPolicyNone":"You are free to choose your password!",
"passwordPolicySpecialChar":"Allowed special characters:",
"pasteHere":"Paste your file here...",
"ppGrace":"chứng thực vẫn còn, thay đổi mật khẩu của bạn!",
"proxyError":"Gateway không chính xác: không thể kết nối máy chủ từ xa",
"pwd":"Mật khẩu",
......@@ -268,6 +269,7 @@
"resetPwd":"Đặt lại mật khẩu của tôi",
"rest2f":"Verification code",
"rightsReloadNeedsLogout":"Tải lại quyền cần đăng xuất và đăng nhập lại",
"rules":"RULES",
"scope":"Phạm vi",
"search":"Search",
"searchingAttributes":"Searching attributes",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"Minimal special characters:",
"passwordPolicyNone":"You are free to choose your password!",
"passwordPolicySpecialChar":"Allowed special characters:",
"pasteHere":"Paste your file here...",
"ppGrace":"authentications remaining, change your password!",
"proxyError":"错误的网关:无法连接远程服务器",
"pwd":"密码",
......@@ -268,6 +269,7 @@
"resetPwd":"重置我的密码",
"rest2f":"Verification code",
"rightsReloadNeedsLogout":"重新加载权限需要登出并且再次登录",
"rules":"RULES",
"scope":"Scope",
"search":"搜索",
"searchingAttributes":"Searching attributes",
......
......@@ -241,6 +241,7 @@
"passwordPolicyMinSpeChar":"最少特殊字元:",
"passwordPolicyNone":"您可以自由選擇密碼!",
"passwordPolicySpecialChar":"已允許的特殊字元:",
"pasteHere":"Paste your file here...",
"ppGrace":"剩餘認證,請變更您的密碼!",
"proxyError":"Bad gateway:無法加入遠端伺服器",
"pwd":"密碼",
......@@ -268,6 +269,7 @@
"resetPwd":"重設我的密碼",
"rest2f":"驗證代碼",
"rightsReloadNeedsLogout":"重新載入權限需要登出然後再次登入",
"rules":"RULES",
"scope":"範圍",
"search":"搜尋",
"searchingAttributes":"Searching attributes",
......
......@@ -6,6 +6,7 @@
<div class="row">
<div class="card col border-secondary">
<div class="text-center bg-light text-dark"><b><span trspan="headers">HEADERS</span></b></div>
<br>
<div class="font-weight-bold">
<TMPL_LOOP NAME="HEADERS">
<TMPL_VAR NAME="key">: <TMPL_VAR NAME="value"><br/>
......@@ -14,8 +15,21 @@
</div>
</div>
</TMPL_IF>
<TMPL_IF NAME="RULES">
<div class="row">
<div class="card col border-secondary">
<div class="text-center bg-light text-dark"><b><span trspan="rules">RULES</span></b></div>
<br>
<div class="font-weight-bold">
<TMPL_LOOP NAME="RULES">
<TMPL_VAR NAME="uri">: <span trspan="<TMPL_VAR NAME="access">"><TMPL_VAR NAME="access"></span><br/>
</TMPL_LOOP>
</div>
</div>
</div>
</TMPL_IF>
<form id="checkDevOps" action="/checkdevops" method="post" class="password" role="form">
<pre><textarea id="checkDevOpsFile" name="checkDevOpsFile" class="form-control rounded-1" rows="6" trplaceholder="Paste your file here..." required><TMPL_VAR NAME="FILE"></textarea></pre>
<pre><textarea id="checkDevOpsFile" name="checkDevOpsFile" class="form-control rounded-1" rows="6" trplaceholder="pasteHere" required><TMPL_VAR NAME="FILE"></textarea></pre>
<TMPL_IF NAME="TOKEN">
<input type="hidden" name="token" value="<TMPL_VAR NAME="TOKEN">" />
</TMPL_IF>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment