From 91812b74eb70bb5c8c8861995db47dc2d8f15e1d Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 25 Oct 2008 00:53:31 +0000 Subject: [PATCH] Fixed basic auth to work on WRE demo servers. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI.pm | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 0d4502969..d2980dcb0 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -4,6 +4,7 @@ and the profile.extras field when viewing a profile. - Added the NotifyAboutThing workflow activity. Use this activity to create workflows for the add / edit / delete workflows for a thingy's things. + - Fixed basic auth to work on WRE demo servers. - fixed #8839: Documentation is wrong for Stock Ticker - Added Guid form control. - Moved Asset ID and Class Name fields to the Meta tab of all assets. diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index 5cc0a0918..2d4971334 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -53,7 +53,7 @@ These subroutines are available from this package: #------------------------------------------------------------------- -=head2 authen ( requestObject, [ user, pass ]) +=head2 authen ( requestObject, [ user, pass, config ]) HTTP Basic auth for WebGUI. @@ -69,11 +69,15 @@ The username to authenticate with. Will pull from the request object if not spec The password to authenticate with. Will pull from the request object if not specified. +=head3 config + +A reference to a WebGUI::Config object. One will be created if it isn't specified. + =cut sub authen { - my ($request, $username, $password) = @_; + my ($request, $username, $password, $config) = @_; $request = Apache2::Request->new($request); my $server = Apache2::ServerUtil->server; my $status = Apache2::Const::OK; @@ -89,12 +93,12 @@ sub authen { } } - my $config = WebGUI::Config->new($server->dir_config('WebguiRoot'),$request->dir_config('WebguiConfig')); + $config ||= WebGUI::Config->new($server->dir_config('WebguiRoot'),$request->dir_config('WebguiConfig')); my $cookies = APR::Request::Apache2->handle($request)->jar(); # determine session id my $sessionId = $cookies->{$config->getCookieName}; - my $session = WebGUI::Session->open($server->dir_config('WebguiRoot'),$request->dir_config('WebguiConfig'), $request, $server, $sessionId); + my $session = WebGUI::Session->open($server->dir_config('WebguiRoot'),$config->getFilename, $request, $server, $sessionId); my $log = $session->log; $request->pnotes(wgSession => $session); @@ -167,10 +171,10 @@ sub handler { my $auth = $request->headers_in->{'Authorization'}; if ($auth =~ m/^Basic/) { # machine oriented $auth =~ s/Basic //; - authen($request, split(":",MIME::Base64::decode_base64($auth))); + authen($request, split(":",MIME::Base64::decode_base64($auth)), $config); } else { # realm oriented - $request->push_handlers(PerlAuthenHandler => sub { return WebGUI::authen($request)}); + $request->push_handlers(PerlAuthenHandler => sub { return WebGUI::authen($request, undef, undef, $config)}); } # url handlers