[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [1834] trunk
- Subject: SF.net SVN: ledger-smb: [1834] trunk
- From: ..hidden..
- Date: Thu, 01 Nov 2007 15:06:41 -0700
Revision: 1834
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1834&view=rev
Author: einhverfr
Date: 2007-11-01 15:06:34 -0700 (Thu, 01 Nov 2007)
Log Message:
-----------
Moving Auth functions into Session handler
Modified Paths:
--------------
trunk/LedgerSMB/Session/DB.pm
trunk/LedgerSMB.pm
Modified: trunk/LedgerSMB/Session/DB.pm
===================================================================
--- trunk/LedgerSMB/Session/DB.pm 2007-11-01 21:45:53 UTC (rev 1833)
+++ trunk/LedgerSMB/Session/DB.pm 2007-11-01 22:06:34 UTC (rev 1834)
@@ -241,6 +241,25 @@
}
+sub get_credentials {
+ # Handling of HTTP Basic Auth headers
+ my $auth = $ENV{'HTTP_AUTHORIZATION'};
+ $auth =~ s/Basic //i; # strip out basic authentication preface
+ $auth = MIME::Base64::decode($auth);
+ my $return_value = {};
+ ($return_value->{login}, $return_value->{password}) = split(/:/, $auth);
+
+ return $return_value;
+
+}
+
+sub credential_prompt{
+ print "WWW-Authenticate: Basic realm=\"LedgerSMB\"\n";
+ print "Status: 401 Unauthorized\n\n";
+ print "Please enter your credentials.\n";
+ exit;
+}
+
sub password_check {
use Digest::MD5;
Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm 2007-11-01 21:45:53 UTC (rev 1833)
+++ trunk/LedgerSMB.pm 2007-11-01 22:06:34 UTC (rev 1834)
@@ -215,27 +215,7 @@
sub _get_password {
my ($self) = shift @_;
$self->{sessionexpired} = shift @_;
- $self->{hidden} = [];
- for (keys %$self){
- next if $_ =~ /(^script$|^endsession$|^password$|^hidden$)/;
- my $attr = {};
- $attr->{name} = $_;
- $attr->{value} = $self->{$_};
- push @{$self->{hidden}}, $attr;
- }
- print "WWW-Authenticate: Basic realm=\"LedgerSMB\"\n";
- print "Status: 401 Unauthorized\n\n";
- print "Please enter your credentials.\n";
- exit;
-# my $template = LedgerSMB::Template->new(
-# user =>$self->{_user},
-# locale => $self->{_locale},
-# path => 'UI',
-# template => 'get_password',
-# format => 'HTML'
-# );
-# $template->render($self);
-# $template->output('http');
+ Session::credential_prompt();
exit;
}
@@ -654,13 +634,9 @@
my $self = shift @_;
my %args = @_;
-
- # Handling of HTTP Basic Auth headers
- my $auth = $ENV{'HTTP_AUTHORIZATION'};
- $auth =~ s/Basic //i; # strip out basic authentication preface
- $auth = MIME::Base64::decode($auth);
- my ($login, $password) = split(/:/, $auth);
- $self->{login} = $login;
+ my $creds = Session::get_credentials();
+
+ $self->{login} = $creds->{login};
if (!$self->{company}){
$self->{company} = $LedgerSMB::Sysconfig::default_db;
}
@@ -671,7 +647,7 @@
# Just in case, however, I think it is a good idea to include the DBI
# error string. CT
$self->{dbh} = DBI->connect(
- "dbi:Pg:dbname=$dbname", "$login", "$password", { AutoCommit => 0 }
+ "dbi:Pg:dbname=$dbname", "$creds->{login}", "$creds->{password}", { AutoCommit => 0 }
);
my $dbh = $self->{dbh};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.