1 #################################################################################
2 # Xestia Scanner Server - Auth System Module #
5 # Copyright (C) 2010-2011 Steve Brokenshire <sbrokenshire@xestia.co.uk> #
7 # This module is licensed under the same license as Xestia Scanner Server which #
8 # is licensed under the GPL version 3. #
10 # This program is free software: you can redistribute it and/or modify #
11 # it under the terms of the GNU General Public License as published by #
12 # the Free Software Foundation, version 3 of the License. #
14 # This program is distributed in the hope that it will be useful, #
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17 # GNU General Public License for more details. #
19 # You should have received a copy of the GNU General Public License #
20 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
21 #################################################################################
23 package Modules::System::Auth;
25 use Modules::System::Common;
30 our @ISA = qw(Exporter);
31 our @EXPORT = qw(xestiascan_auth_authenticate xestiascan_auth_logout);
33 sub xestiascan_auth_authenticate{
34 #################################################################################
35 # xestiascan_auth_authenticate: Provides a form for authentication. #
39 # xestiascan_auth_authenticate(authfailure); #
41 # authfailure Display authentication failure message. #
42 #################################################################################
44 my $authfailure = shift;
46 $authfailure = 0 if !$authfailure;
48 if ($authfailure eq 1){
50 $main::xestiascan_presmodule->startbox("errorsectionbox");
51 $main::xestiascan_presmodule->startbox("errorboxheader");
52 $main::xestiascan_presmodule->addtext($main::xestiascan_lang{error}{error});
53 $main::xestiascan_presmodule->endbox();
54 $main::xestiascan_presmodule->startbox("errorbox");
55 $main::xestiascan_presmodule->addtext($main::xestiascan_lang{auth}{loginerror});
56 $main::xestiascan_presmodule->endbox();
57 $main::xestiascan_presmodule->endbox();
61 $main::xestiascan_presmodule->startbox("sectionbox");
62 $main::xestiascan_presmodule->startbox("sectiontitle");
63 $main::xestiascan_presmodule->addtext($main::xestiascan_lang{auth}{login});
64 $main::xestiascan_presmodule->endbox();
65 $main::xestiascan_presmodule->startbox("secondbox");
67 $main::xestiascan_presmodule->startform($main::xestiascan_env{"script_filename"}, "POST");
68 $main::xestiascan_presmodule->addhiddendata("mode", "auth");
69 $main::xestiascan_presmodule->starttable("", { CellPadding => "5", CellSpacing => "0" });
70 $main::xestiascan_presmodule->startrow();
71 $main::xestiascan_presmodule->addcell("tablecell1");
72 $main::xestiascan_presmodule->addtext($main::xestiascan_lang{auth}{username});
73 $main::xestiascan_presmodule->endcell();
74 $main::xestiascan_presmodule->addcell("tablecell2");
75 $main::xestiascan_presmodule->addinputbox("username", { Size => 32, MaxLength => 32 });
76 $main::xestiascan_presmodule->endcell();
77 $main::xestiascan_presmodule->endrow();
78 $main::xestiascan_presmodule->startrow();
79 $main::xestiascan_presmodule->addcell("tablecell1");
80 $main::xestiascan_presmodule->addtext($main::xestiascan_lang{auth}{password});
81 $main::xestiascan_presmodule->endcell();
82 $main::xestiascan_presmodule->addcell("tablecell2");
83 $main::xestiascan_presmodule->addinputbox("password", { Size => 64, MaxLength => 128, Password => 1 });
84 $main::xestiascan_presmodule->endcell();
85 $main::xestiascan_presmodule->endrow();
86 $main::xestiascan_presmodule->startrow();
87 $main::xestiascan_presmodule->addcell("tablecell1");
88 $main::xestiascan_presmodule->addtext($main::xestiascan_lang{common}{options});
89 $main::xestiascan_presmodule->endcell();
90 $main::xestiascan_presmodule->addcell("tablecell2");
91 $main::xestiascan_presmodule->addcheckbox("stayloggedin", { OptionDescription => $main::xestiascan_lang{auth}{keeploggedin} });
92 $main::xestiascan_presmodule->endcell();
93 $main::xestiascan_presmodule->endrow();
94 $main::xestiascan_presmodule->endtable();
95 $main::xestiascan_presmodule->addlinebreak();
96 $main::xestiascan_presmodule->addsubmit($main::xestiascan_lang{auth}{loginbutton});
97 $main::xestiascan_presmodule->addtext(" | ");
98 $main::xestiascan_presmodule->addreset($main::xestiascan_lang{common}{clearvalues});
99 $main::xestiascan_presmodule->endform();
101 $main::xestiascan_presmodule->endbox();
102 $main::xestiascan_presmodule->endbox();
104 return $main::xestiascan_presmodule->grab();
108 sub xestiascan_auth_logout{
109 #################################################################################
110 # xestiascan_auth_logout: Logout of the Xestia Scanner Server installation. #
111 #################################################################################
113 $main::xestiascan_presmodule->addtext($main::xestiascan_lang{auth}{loggedout}, { Style => "pageheader" });
114 $main::xestiascan_presmodule->addlinebreak();
115 $main::xestiascan_presmodule->addlinebreak();
116 $main::xestiascan_presmodule->addtext($main::xestiascan_lang{auth}{loggedoutmsg});
117 $main::xestiascan_presmodule->addlinebreak();
118 $main::xestiascan_presmodule->addlinebreak();
119 $main::xestiascan_presmodule->addlink($main::xestiascan_env{"script_filename"}, { Text => $main::xestiascan_lang{auth}{displaylogin} });
121 return $main::xestiascan_presmodule->grab();