Skip to content
Snippets Groups Projects
Commit 8de5f326 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Commit little login script I wrote to replace the existing TWiki

logon script, so that we do not have to use stinky HTPP basic auth.
parent d1791a25
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/perl
sub BEGIN { $ENV{PTKDB_STOP_TAG_COLOR} = "yellow" }
#
# TWiki WikiClone (see wiki.pm for $wikiversion and other info)
#
# Copyright (C) 1999 Peter Thoeny, peter@thoeny.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use lib ( '.' );
use lib ( '../lib' );
use TWiki;
use TWiki::Plugins::SessionPlugin;
my $oopsurl = "oopsnoweb";
$query= new CGI;
&main();
sub main
{
my $username = $query->param('username');
my $password = $query->param('password');
chomp($username);
chomp($password);
if (! ($username && $password)) {
my $url = &TWiki::getOopsUrl(undef, "", $oopsurl);
TWiki::redirect( $query, $url );
return;
}
#
# Suck out the password entry.
#
my $pwentry;
open(HTP, $htpasswdFilename) or
die("Could not open $htpasswdFilename\n");
while (<HTP>) {
if ($_ =~ /^${username}:.*$/) {
$pwentry = $_;
last;
}
}
close(HTP);
if (!defined($pwentry)) {
my $url = &TWiki::getOopsUrl(undef, "", $oopsurl);
TWiki::redirect( $query, $url );
return;
}
#
# Split up the entry and compare.
#
my ($wikiname, $encryptedpasswd) = split(":", $pwentry);
chomp($encryptedpasswd);
my $salt = substr($encryptedpasswd, 0, 2);
my $str = crypt($password, $salt);
if ($str ne $encryptedpasswd) {
my $url = &TWiki::getOopsUrl(undef, "", $oopsurl);
TWiki::redirect( $query, $url );
return;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment