~kosova/+junk/tuxfamily-twiki

« back to all changes in this revision

Viewing changes to foswiki/lib/Foswiki/Configure/UIs/AUTH.pm

  • Committer: James Michael DuPont
  • Date: 2009-07-18 19:58:49 UTC
  • Revision ID: jamesmikedupont@gmail.com-20090718195849-vgbmaht2ys791uo2
added foswiki

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# See bottom of file for license and copyright information
 
2
 
 
3
package Foswiki::Configure::UIs::AUTH;
 
4
 
 
5
use strict;
 
6
 
 
7
use Foswiki::Configure::UI;
 
8
 
 
9
use base 'Foswiki::Configure::UI';
 
10
 
 
11
my %nonos = (
 
12
    cfgAccess => 1,
 
13
    newCfgP   => 1,
 
14
    confCfgP  => 1,
 
15
);
 
16
 
 
17
sub ui {
 
18
    my ( $this, $canChangePW, $actionMess ) = @_;
 
19
    my $output = '';
 
20
 
 
21
    my @script     = File::Spec->splitdir( $ENV{SCRIPT_NAME} );
 
22
    my $scriptName = pop(@script);
 
23
    $scriptName =~ s/.*[\/\\]//;    # Fix for Item3511, on Win XP
 
24
 
 
25
    $output .= CGI::start_form( { name => 'twiki_configure', action => $scriptName, method => 'post' } );
 
26
 
 
27
    # Pass URL params through, except those below
 
28
    foreach my $param ( $Foswiki::query->param ) {
 
29
        next if ( $nonos{$param} );
 
30
        $output .= $this->hidden( $param, $Foswiki::query->param($param) );
 
31
        $output .= "\n";
 
32
    }
 
33
 
 
34
    # and add a few more
 
35
    $output .= "<div id ='twikiPassword'><div class='foswikiFormSteps'>\n";
 
36
 
 
37
    $output .= CGI::div( { class => 'foswikiFormStep' },
 
38
        CGI::h3('Enter the configuration password') );
 
39
 
 
40
    $output .= CGI::div(
 
41
        { class => 'foswikiFormStep' },
 
42
        CGI::h3( CGI::strong("Your Password:") )
 
43
          . CGI::p(
 
44
                CGI::password_field( -name=>'cfgAccess', -size =>20, -maxlength=>80, -class => 'foswikiInputField' ) 
 
45
              . '&nbsp;'
 
46
              . CGI::submit(
 
47
                -class => 'foswikiSubmit',
 
48
                -value => $actionMess
 
49
              )
 
50
          )
 
51
    );
 
52
 
 
53
    if ( $Foswiki::cfg{Password} ne '' ) {
 
54
        $output .= CGI::div(
 
55
            { class => 'foswikiFormStep' },
 
56
            CGI::p( CGI::strong('Forgotten your password?') )
 
57
              . CGI::p(<<'HERE') );
 
58
To reset the password, log in to the server and delete the
 
59
<code>$Foswiki::cfg{Password} = '...';</code> line from
 
60
<code>lib/LocalSite.cfg</code>
 
61
HERE
 
62
    }
 
63
 
 
64
    $output .= '</div><!--/foswikiFormSteps--></div><!--/twikiPassword-->';
 
65
 
 
66
    if ($canChangePW) {
 
67
        $output .=
 
68
          "<div id='twikiPasswordChange'><div class='foswikiFormSteps'>\n";
 
69
        $output .= '<div class="foswikiNotification" style="margin:1em;">';
 
70
        $output .= CGI::img(
 
71
            {
 
72
                width  => '16',
 
73
                height => '16',
 
74
                src    => $scriptName
 
75
                  . '?action=image;image=warning.gif;type=image/gif',
 
76
                alt => ''
 
77
            }
 
78
        );
 
79
        $output .= '&nbsp;'
 
80
          . CGI::span( { class => 'foswikiAlert' },
 
81
            CGI::strong('Notes on Security') );
 
82
        $output .= <<HERE;
 
83
<ul>
 
84
 <li>
 
85
  If you don't set a password, or the password is cracked, then
 
86
  <code>configure</code> could be used to do <strong>very</strong> nasty
 
87
  things to your server.
 
88
 </li>
 
89
 <li>
 
90
  If you are running Foswiki on a public website, you are
 
91
  <strong>strongly</strong> advised to totally disable saving from
 
92
  <code>configure</code> by making <code>lib/LocalSite.cfg</code> readonly once
 
93
  you are happy with your configuration.
 
94
 </li>
 
95
</ul>
 
96
</div><!--expanation-->
 
97
HERE
 
98
 
 
99
        my $submitStr = $actionMess;
 
100
        $output .= CGI::div(
 
101
            { class => 'foswikiFormStep' },
 
102
            CGI::h3(
 
103
                { class => 'foswikiFormStep' },
 
104
                'You may set a new password here:'
 
105
            )
 
106
        );
 
107
        $output .= CGI::div(
 
108
            { class => 'foswikiFormStep' },
 
109
            CGI::strong('New Password:')
 
110
              . CGI::p( CGI::password_field( -name=>'newCfgP', -size=>20, -maxlength=>80, -class => 'foswikiInputField' ) )
 
111
        );
 
112
        $output .= CGI::div(
 
113
            { class => 'foswikiFormStep' },
 
114
            CGI::strong('Confirm Password:')
 
115
              . CGI::p( CGI::password_field( -name=>'confCfgP', size=>20, -maxlength=>80, -class => 'foswikiInputField' ) )
 
116
        );
 
117
        $submitStr = 'Change Password and ' . $submitStr;
 
118
        $output .= CGI::div( { class => 'foswikiFormStep foswikiLast' },
 
119
            CGI::submit( -class => 'foswikiSubmit', -value => $submitStr ) );
 
120
        $output .=
 
121
          "</div><!--/foswikiFormSteps--></div><!--/twikiPasswordChange-->";
 
122
    }
 
123
 
 
124
    return $output . CGI::end_form();
 
125
}
 
126
 
 
127
1;
 
128
__DATA__
 
129
#
 
130
# Foswiki - The Free and Open Source Wiki, http://foswiki.org/
 
131
#
 
132
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
 
133
# Foswiki Contributors are listed in the AUTHORS file in the root
 
134
# of this distribution. NOTE: Please extend that file, not this notice.
 
135
#
 
136
# Additional copyrights apply to some or all of the code in this
 
137
# file as follows:
 
138
#
 
139
# Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
 
140
# TWiki Contributors are listed in the AUTHORS file in the root
 
141
# of this distribution. NOTE: Please extend that file, not this notice.
 
142
#
 
143
# This program is free software; you can redistribute it and/or
 
144
# modify it under the terms of the GNU General Public License
 
145
# as published by the Free Software Foundation; either version 2
 
146
# of the License, or (at your option) any later version. For
 
147
# more details read LICENSE in the root of this distribution.
 
148
#
 
149
# This program is distributed in the hope that it will be useful,
 
150
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
151
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
152
#
 
153
# As per the GPL, removal of this notice is prohibited.