Skip to content

Commit

Permalink
Item13897: A number of bugs and mistypes have been fixed.
Browse files Browse the repository at this point in the history
Few circular attribute dependencies causing infinite loops were resolved.

Admin user is now able to login.

Configure is capable of saving LSC.

Extensions wizard is starting – not sure if it does something besides it.
  • Loading branch information
vrurg committed May 6, 2016
1 parent 3ebf44b commit 6b0ee42
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 35 deletions.
4 changes: 2 additions & 2 deletions core/lib/Foswiki.pm
Expand Up @@ -480,7 +480,7 @@ sub __deprecated_BUILDARGS {
return $params;
}

sub BUILD {
sub __deprecated_BUILD {
my $this = shift;

if (SINGLE_SINGLETONS_TRACE) {
Expand Down Expand Up @@ -1204,7 +1204,7 @@ sub _parsePath {
return ( $web, $topic );
}

sub DEMOLISH {
sub __depreacated_DEMOLISH {
my $this = shift;

$this->clear_plugins;
Expand Down
28 changes: 17 additions & 11 deletions core/lib/Foswiki/App.pm
Expand Up @@ -222,12 +222,13 @@ has ui => (
},
);
has remoteUser => (
is => 'rw',
lazy => 1,
clearer => 1,
default => sub {
is => 'rw',
lazy => 1,
clearer => 1,
predicate => 1,
default => sub {
my $this = shift;
my $user = $this->has_user ? $this->user : $this->app->engine->user;
my $user = $this->has_user ? $this->user : $this->engine->user;
return $this->users->loadSession($user);
},
);
Expand Down Expand Up @@ -419,12 +420,7 @@ sub run {
}

if ( defined $app && defined $app->logger ) {
$app->logger->log(
{
level => 'error',
extra => [ $e->stringify ],
}
);
$app->logger->log( 'error', $e->stringify, );
}

# Low-level report of errors to user.
Expand Down Expand Up @@ -1331,6 +1327,16 @@ sub _prepareEngine {
sub _prepareRequest {
my $this = shift;

state $preparing = 0;

if ($preparing) {
Foswiki::Exception::Fatal->throw(
text => 'Circular call to _prepareRequest' );
}
else {
$preparing = 1;
}

# The following is preferable form of Request creation. The request
# constructor will then initialize itself using $app->engine as the source
# of information about the environment we're running under.
Expand Down
3 changes: 3 additions & 0 deletions core/lib/Foswiki/Config.pm
Expand Up @@ -1137,11 +1137,13 @@ sub _populatePresets {
$cfgData->{SwitchBoard}{login} = {
package => undef,
function => 'logon',
request => 'Foswiki::Request',
context => { ( login => 1, logon => 1 ) },
};
$cfgData->{SwitchBoard}{logon} = {
package => undef,
function => 'logon',
request => 'Foswiki::Request',
context => { ( login => 1, logon => 1 ) },
};
$cfgData->{SwitchBoard}{manage} = {
Expand All @@ -1153,6 +1155,7 @@ sub _populatePresets {
$cfgData->{SwitchBoard}{oops} = {
package => 'Foswiki::UI::Oops',
function => 'oops_cgi',
request => 'Foswiki::Request',
context => { oops => 1 },
};
$cfgData->{SwitchBoard}{preview} = {
Expand Down
2 changes: 2 additions & 0 deletions core/lib/Foswiki/Configure/Dependency.pm
Expand Up @@ -138,13 +138,15 @@ has name => (
},
);
has data => ( is => 'rw', );
has compatibility => ( is => 'rw', );
has module => ( is => 'rw', );
has installed => ( is => 'rw', );
has installedVersion => ( is => 'rw', );
has installedRelease => ( is => 'rw', );
has location => ( is => 'rw', );
has notes => ( is => 'rw', default => '', );
has repository => ( is => 'rw', );
has release => ( is => 'rw', );
has trigger => ( is => 'rw', default => 1, );
has type => ( is => 'rw', default => 'external', ); # assume external module

Expand Down
7 changes: 4 additions & 3 deletions core/lib/Foswiki/Configure/Wizards/Save.pm
Expand Up @@ -237,7 +237,7 @@ sub save {
die "Internal error: $@" if ($@);
}
else {
$Foswiki::app->cfg->clean_data;
$Foswiki::app->cfg->clear_data;

# Read without expansions but with the .spec
$Foswiki::app->cfg->readConfig( 1, 0, 1 );
Expand Down Expand Up @@ -404,11 +404,12 @@ sub _compareConfigs {

#print STDERR "REPORT ON $vs->{keys} $old $new\n";
if ( $old ne $new ) {
if ( $vs->{typename} eq 'PASSWORD' ) {
if ( $vs->attrs->{typename} eq 'PASSWORD' ) {
$old = '_[redacted]_';
$new = '_[redacted]_';
}
$old = "($vs->{default})" if $old eq 'undef' && $vs->{default};
$old = "(" . $vs->attrs->{default} . ")"
if $old eq 'undef' && $vs->attrs->{default};
_logAndReport( $report, $logger, $keypath, $old, $new );
return 0;
}
Expand Down
7 changes: 1 addition & 6 deletions core/lib/Foswiki/Exception.pm
Expand Up @@ -146,12 +146,7 @@ sub BUILD {
) unless $this->text;

if ( DEBUG && defined $Foswiki::app ) {
$Foswiki::app->logger->log(
{
level => 'debug',
extra => [ $this->stringify ],
}
);
$Foswiki::app->logger->log( 'debug', $this->stringify, );
}

say STDERR "New exception object created: ", $this->stringify
Expand Down
15 changes: 8 additions & 7 deletions core/lib/Foswiki/LoginManager.pm
Expand Up @@ -828,6 +828,8 @@ sub userLoggedIn {
$app->user( $app->users->getCanonicalUserID($authUser) );
}

my $remoteUser = $app->has_remoteUser ? $app->remoteUser : undef;

if ( $app->inContext('command_line') ) {

# Command line is automatically 'authenticated' unless the guest user
Expand Down Expand Up @@ -857,33 +859,32 @@ sub userLoggedIn {
|| $Foswiki::cfg{DefaultUserLogin};

_trace( $this, "==== Initial user is $sessUser" );
_trace( $this, "==== Remote user is " . $app->request->remoteUser() )
if defined $app->request->remoteUser();
_trace( $this, "==== Remote user is " . $remoteUser )
if defined $remoteUser;

if ( $authUser && $authUser ne $Foswiki::cfg{DefaultUserLogin} ) {
_trace( $this,
'Authenticated; converting from '
. ( $app->remoteUser || $sessUser || 'undef' ) . ' to '
. ( $remoteUser || $sessUser || 'undef' ) . ' to '
. $authUser
. ' - default '
. $Foswiki::cfg{DefaultUserLogin} );

# SMELL: right now anyone that makes a template login url can log
# in multiple times - should i forbid it
if ( $Foswiki::cfg{UseClientSessions} ) {
if ( defined( $app->remoteUser )
if ( defined($remoteUser)
&& $app->inContext('sudo_login') )
{
$app->logger->log(
{
level => 'info',
action => 'sudo login',
extra => 'from ' . ( $app->remoteUser || '' ),
extra => 'from ' . ( $remoteUser || '' ),
user => $authUser
}
);
$this->_cgisession->param( 'SUDOFROMAUTHUSER',
$app->remoteUser );
$this->_cgisession->param( 'SUDOFROMAUTHUSER', $remoteUser );
}

# SMELL: these are bare logins, so if and when there are
Expand Down
5 changes: 4 additions & 1 deletion core/lib/Foswiki/LoginManager/ApacheLogin.pm
Expand Up @@ -119,7 +119,10 @@ if it needs to challenge the user
=cut

sub login {
my ( $this, $query, $app ) = @_;
my $this = shift;

$app //= $this->app;
my $query = $app->request;

my $url =
$app->cfg->getScriptUrl( 0, 'viewauth', $app->request->web,
Expand Down
4 changes: 3 additions & 1 deletion core/lib/Foswiki/LoginManager/TemplateLogin.pm
Expand Up @@ -155,7 +155,9 @@ database, that can then be displayed by referring to
=cut

sub login {
my ( $this, $query, $app ) = @_;
my $this = shift;
my $app = $this->app;
my $query = $app->request;
my $users = $app->users;

my $origin = $query->param('foswiki_origin');
Expand Down
2 changes: 2 additions & 0 deletions core/lib/Foswiki/Request.pm
Expand Up @@ -140,6 +140,8 @@ has method => (
lazy => 1,
default => sub { $_[0]->app->engine->connectionData->{method} },
);

# SMELL XXX remote_user is not used anymore, it is now Foswiki::App::remoteUser attribute.
has remote_user => ( is => 'rw', );
has server_port => (
is => 'rw',
Expand Down
10 changes: 6 additions & 4 deletions core/lib/Foswiki/UI.pm
Expand Up @@ -372,7 +372,9 @@ Handler for "logon" action.
=cut

sub logon {
my $app = shift;
my $this = shift;
my $app = $this->app;
my $req = $app->request;

if ( defined $Foswiki::cfg{LoginManager}
&& $Foswiki::cfg{LoginManager} eq 'none' )
Expand All @@ -384,14 +386,14 @@ sub logon {
);
}

my $action = $app->request->param('foswikiloginaction');
$app->request->delete('foswikiloginaction');
my $action = $req->param('foswikiloginaction');
$req->delete('foswikiloginaction');

if ( defined $action && $action eq 'validate' ) {
Foswiki::Validation::validate($app);
}
else {
$app->getLoginManager()->login( $app->request, $app );
$app->users->loginManager->login;
}
}

Expand Down

0 comments on commit 6b0ee42

Please sign in to comment.