summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Oetiker <tobi@oetiker.ch>2012-03-24 21:00:28 +0100
committerTobias Oetiker <tobi@oetiker.ch>2012-03-24 21:00:28 +0100
commit6fae074f1a8a305b0a8361626902110e7351a65b (patch)
treeedc8bc12c004e8bb6a2a5908f2174ac0643cecf9
parent79b6c9346c950d0b3e22dc9ba337bbcdcbed052e (diff)
parent11cf1d954dc92e4d4f2a8dc8fed729f0ef04bf7a (diff)
downloadsmokeping-6fae074f1a8a305b0a8361626902110e7351a65b.tar.gz
smokeping-6fae074f1a8a305b0a8361626902110e7351a65b.tar.xz
Merge pull request #6 from mcdarren/integration
HTTP auth user template support
-rw-r--r--doc/smokeping_install.pod2
-rw-r--r--etc/basepage.html.dist1
-rw-r--r--lib/Smokeping.pm4
3 files changed, 7 insertions, 0 deletions
diff --git a/doc/smokeping_install.pod b/doc/smokeping_install.pod
index f3b81bd..0c922d9 100644
--- a/doc/smokeping_install.pod
+++ b/doc/smokeping_install.pod
@@ -175,6 +175,8 @@ Edit the html template to your likings. Please do not remove the link to the
SmokePing counter and my name from the template. The content of the
template will be renderd by smokeping.cgi. This means that all embedded
links must be relative to smokeping.cgi.
+If you are using HTTP authentication, then the template variable C<authuser> will be populated
+from the C<$ENV{REMOTE_USER}> environment variable.
=item F<etc/smokemail>
diff --git a/etc/basepage.html.dist b/etc/basepage.html.dist
index ff347c1..fbf0d55 100644
--- a/etc/basepage.html.dist
+++ b/etc/basepage.html.dist
@@ -66,6 +66,7 @@ a.menulink:hover {
<TR>
<TD class="menubar" align="left" width="130" valign="top">
<P></P>
+ <P><h3>Logged in as <##authuser##></h3></P>
<P><B>SmokePing Targets:</B>&nbsp;&nbsp;</P>
<P><##menu##></P>
<br/>
diff --git a/lib/Smokeping.pm b/lib/Smokeping.pm
index f5743c0..bba2a6b 100644
--- a/lib/Smokeping.pm
+++ b/lib/Smokeping.pm
@@ -1677,6 +1677,7 @@ sub display_webpage($$){
my $display_tree = $tree->{__tree_link} ? $tree->{__tree_link} : $tree;
+ my $authuser = $ENV{REMOTE_USER} || 'Guest';
my $page = fill_template
($cfg->{Presentation}{template},
{
@@ -1700,6 +1701,7 @@ sub display_webpage($$){
step => $step,
rrdlogo => '<A HREF="http://oss.oetiker.ch/rrdtool/"><img border="0" src="'.$cfg->{General}{imgurl}.'/rrdtool.png"></a>',
smokelogo => '<A HREF="http://oss.oetiker.ch/smokeping/counter.cgi/'.$VERSION.'"><img border="0" src="'.$cfg->{General}{imgurl}.'/smokeping.png"></a>',
+ authuser => $authuser,
}
);
my $expi = $cfg->{Database}{step} > 120 ? $cfg->{Database}{step} : 120;
@@ -3953,6 +3955,7 @@ sub gen_page ($$$) {
my $step = $probes->{$tree->{probe}}->step();
my $readversion = "?";
$VERSION =~ /(\d+)\.(\d{3})(\d{3})/ and $readversion = sprintf("%d.%d.%d",$1,$2,$3);
+ my $authuser = $ENV{REMOTE_USER} || 'Guest';
$page = fill_template
($cfg->{Presentation}{template},
{
@@ -3971,6 +3974,7 @@ sub gen_page ($$$) {
step => $step,
rrdlogo => '<A HREF="http://oss.oetiker.ch/rrdtool/"><img border="0" src="'.$cfg->{General}{imgurl}.'/rrdtool.png"></a>',
smokelogo => '<A HREF="http://oss.oetiker.ch/smokeping/counter.cgi/'.$VERSION.'"><img border="0" src="'.$cfg->{General}{imgurl}.'/smokeping.png"></a>',
+ authuser => $authuser,
});
print PAGEFILE $page || "<HTML><BODY>ERROR: Reading page template ".$cfg->{Presentation}{template}."</BODY></HTML>";