summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-01-18 14:37:26 -0800
committerIvan Kohler <ivan@freeside.biz>2015-01-18 14:37:26 -0800
commit7d6db2c0fed3624edeb29de8890e982f743ff158 (patch)
tree9192f7b7c8c26876f1cdcb6a9e833621d9c812dd /FS
parent844cadb72e5e37ba0c78ffc8b6f2eded669b2226 (diff)
DRY
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/AuthCookieHandler.pm12
-rw-r--r--FS/FS/AuthCookieHandler24.pm44
2 files changed, 14 insertions, 42 deletions
diff --git a/FS/FS/AuthCookieHandler.pm b/FS/FS/AuthCookieHandler.pm
index b571e47..93d8ea6 100644
--- a/FS/FS/AuthCookieHandler.pm
+++ b/FS/FS/AuthCookieHandler.pm
@@ -6,6 +6,12 @@ use FS::UID qw( adminsuidsetup preuser_setup );
use FS::CurrentUser;
use FS::Auth;
+#Apache 2.2 and below
+sub useragent_ip {
+ my( $self, $r ) = @_;
+ $r->connection->remote_ip;
+}
+
sub authen_cred {
my( $self, $r, $username, $password ) = @_;
@@ -14,11 +20,11 @@ sub authen_cred {
my $info = {};
unless ( FS::Auth->authenticate($username, $password, $info) ) {
- warn "failed auth $username from ". $r->connection->remote_ip. "\n";
+ warn "failed auth $username from ". $self->useragent_ip($r). "\n";
return undef;
}
- warn "authenticated $username from ". $r->connection->remote_ip. "\n";
+ warn "authenticated $username from ". $self->useragent_ip($r). "\n";
FS::CurrentUser->load_user( $username,
'autocreate' => FS::Auth->auth_class->autocreate,
@@ -36,7 +42,7 @@ sub authen_ses_key {
my $curuser = FS::CurrentUser->load_user_session( $sessionkey );
unless ( $curuser ) {
- warn "bad session $sessionkey from ". $r->connection->remote_ip. "\n";
+ warn "bad session $sessionkey from ". $self->useragent_ip($r). "\n";
return undef;
}
diff --git a/FS/FS/AuthCookieHandler24.pm b/FS/FS/AuthCookieHandler24.pm
index fa24890..d65934f 100644
--- a/FS/FS/AuthCookieHandler24.pm
+++ b/FS/FS/AuthCookieHandler24.pm
@@ -1,46 +1,12 @@
package FS::AuthCookieHandler24;
-use base qw( Apache2::AuthCookie );
+use base qw( FS::AuthCookieHandler );
use strict;
-use FS::UID qw( adminsuidsetup preuser_setup );
-use FS::CurrentUser;
-use FS::Auth;
-sub authen_cred {
- my( $self, $r, $username, $password ) = @_;
-
- preuser_setup();
-
- my $info = {};
-
- unless ( FS::Auth->authenticate($username, $password, $info) ) {
- warn "failed auth $username from ". $r->useragent_ip. "\n";
- return undef;
- }
-
- warn "authenticated $username from ". $r->useragent_ip. "\n";
-
- FS::CurrentUser->load_user( $username,
- 'autocreate' => FS::Auth->auth_class->autocreate,
- %$info,
- );
-
- FS::CurrentUser->new_session;
-}
-
-sub authen_ses_key {
- my( $self, $r, $sessionkey ) = @_;
-
- preuser_setup();
-
- my $curuser = FS::CurrentUser->load_user_session( $sessionkey );
-
- unless ( $curuser ) {
- warn "bad session $sessionkey from ". $r->useragent_ip. "\n";
- return undef;
- }
-
- $curuser->username;
+#Apache 2.4+ / Apache2::AuthCookie 3.19+
+sub useragent_ip {
+ my( $self, $r ) = @_;
+ $r->useragent_ip;
}
1;