Commit 3bee7401 authored by Christophe Maudoux's avatar Christophe Maudoux 🐛
Browse files

display headers (#2458)

parent 6e1efc8b
......@@ -72,6 +72,7 @@ q"I refuse to compile rules.json when useSafeJail isn't activated! Yes I know, I
}
}
$class->logger->debug("DevOps handler called by $vhost");
$class->locationRulesInit( undef, { $vhost => $json->{rules} } );
$class->headersInit( undef, { $vhost => $json->{headers} } );
$class->tsv->{lastVhostUpdate}->{$vhost} = time;
......
......@@ -775,12 +775,6 @@ sub tree {
form => 'simpleInputContainer',
nodes => [ 'checkState', 'checkStateSecret', ],
},
{
title => 'devOpsCheck',
help => 'checkdevops.html',
form => 'simpleInputContainer',
nodes => ['checkDevOps'],
},
{
title => 'checkUsers',
help => 'checkuser.html',
......@@ -805,6 +799,12 @@ sub tree {
},
]
},
{
title => 'devOpsCheck',
help => 'checkdevops.html',
form => 'simpleInputContainer',
nodes => ['checkDevOps'],
},
{
title => 'impersonation',
help => 'impersonation.html',
......
......@@ -68,6 +68,7 @@ sub display {
sub run {
my ( $self, $req ) = @_;
my ( $msg, $alert );
my $headers = [];
# Check token
if ( $self->ottRule->( $req, {} ) ) {
......@@ -107,15 +108,23 @@ sub run {
my $json = eval { from_json( $req->param('checkDevOpsFile') ) };
if ($@) {
$self->userLogger->error("CheckDevOps: bad 'rules.json' file ($@)");
$msg = 'PE' . PE_BAD_DEVOPS_FILE;
$alert = 'alert-danger';
$json = '';
$json = '';
$self->userLogger->error("CheckDevOps: bad 'rules.json' file ($@)");
}
else {
my $vhost = $self->p->HANDLER->resolveAlias($req);
$self->p->HANDLER->headersInit( undef, { $vhost => $json->{headers} } );
$self->p->HANDLER->locationRulesInit( undef,
{ $vhost => $json->{rules} } );
$headers = $self->p->HANDLER->checkHeaders( $req, $req->userData );
my $list = join ', ', map { "$_->{key}:$_->{value}" } @$headers;
$self->logger->debug("CheckDevOps compiled headers: $list");
$msg = 'checkDevOps';
$alert = 'alert-info';
$json = $req->param('checkDevOpsFile');
$self->logger->debug("CheckDevOps provided file: $json");
}
my $params = {
......@@ -126,6 +135,7 @@ sub run {
MSG => $msg,
ALERTE => $alert,
FILE => $json,
HEADERS => $headers,
TOKEN => (
$self->ottRule->( $req, {} )
? $self->ott->createToken()
......
......@@ -2,6 +2,18 @@
<div id="errorcontent" class="container">
<div class="alert <TMPL_VAR NAME="ALERTE"> alert"><div class="text-center"><span trspan="<TMPL_VAR NAME="MSG">"></span></div></div>
<TMPL_IF NAME="HEADERS">
<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>
<div class="font-weight-bold">
<TMPL_LOOP NAME="HEADERS">
<TMPL_VAR NAME="key">: <TMPL_VAR NAME="value"><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>
<TMPL_IF NAME="TOKEN">
......
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