← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 18:42:36 2015
Reported on Fri Jul 31 18:48:15 2015

Filename/var/www/foswikidev/core/lib/Foswiki/LoginManager/ApacheLogin.pm
StatementsExecuted 24 statements in 577µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11128µs117µsFoswiki::LoginManager::ApacheLogin::::newFoswiki::LoginManager::ApacheLogin::new
11113µs27µsFoswiki::LoginManager::ApacheLogin::::BEGIN@24Foswiki::LoginManager::ApacheLogin::BEGIN@24
11111µs15µsFoswiki::LoginManager::ApacheLogin::::getUserFoswiki::LoginManager::ApacheLogin::getUser
11110µs14µsFoswiki::LoginManager::ApacheLogin::::BEGIN@25Foswiki::LoginManager::ApacheLogin::BEGIN@25
11110µs40µsFoswiki::LoginManager::ApacheLogin::::BEGIN@26Foswiki::LoginManager::ApacheLogin::BEGIN@26
1114µs4µsFoswiki::LoginManager::ApacheLogin::::__ANON__[:53]Foswiki::LoginManager::ApacheLogin::__ANON__[:53]
1114µs4µsFoswiki::LoginManager::ApacheLogin::::BEGIN@28Foswiki::LoginManager::ApacheLogin::BEGIN@28
1114µs4µsFoswiki::LoginManager::ApacheLogin::::BEGIN@31Foswiki::LoginManager::ApacheLogin::BEGIN@31
0000s0sFoswiki::LoginManager::ApacheLogin::::forceAuthenticationFoswiki::LoginManager::ApacheLogin::forceAuthentication
0000s0sFoswiki::LoginManager::ApacheLogin::::loginFoswiki::LoginManager::ApacheLogin::login
0000s0sFoswiki::LoginManager::ApacheLogin::::loginUrlFoswiki::LoginManager::ApacheLogin::loginUrl
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# See bottom of file for license and copyright information
2
3=begin TML
4
5---+ package Foswiki::LoginManager::ApacheLogin
6
7This is login manager that you can specify in the security setup section of
8[[%SCRIPTURL{"configure"}%][configure]]. It instructs Foswiki to
9cooperate with your web server (typically Apache) to require authentication
10information (username & password) from users. It requires that you configure
11your web server to demand authentication for scripts named "login" and anything
12ending in "auth". The latter should be symlinks to existing scripts; e.g.,
13=viewauth -> view=, =editauth -> edit=, and so on.
14
15See also UserAuthentication.
16
17Subclass of Foswiki::LoginManager; see that class for documentation of the
18methods of this class.
19
20=cut
21
22package Foswiki::LoginManager::ApacheLogin;
23
24230µs240µs
# spent 27µs (13+13) within Foswiki::LoginManager::ApacheLogin::BEGIN@24 which was called: # once (13µs+13µs) by Foswiki::LoginManager::makeLoginManager at line 24
use strict;
# spent 27µs making 1 call to Foswiki::LoginManager::ApacheLogin::BEGIN@24 # spent 13µs making 1 call to strict::import
25224µs218µs
# spent 14µs (10+4) within Foswiki::LoginManager::ApacheLogin::BEGIN@25 which was called: # once (10µs+4µs) by Foswiki::LoginManager::makeLoginManager at line 25
use warnings;
# spent 14µs making 1 call to Foswiki::LoginManager::ApacheLogin::BEGIN@25 # spent 4µs making 1 call to warnings::import
26226µs270µs
# spent 40µs (10+30) within Foswiki::LoginManager::ApacheLogin::BEGIN@26 which was called: # once (10µs+30µs) by Foswiki::LoginManager::makeLoginManager at line 26
use Assert;
# spent 40µs making 1 call to Foswiki::LoginManager::ApacheLogin::BEGIN@26 # spent 30µs making 1 call to Exporter::import
27
28257µs14µs
# spent 4µs within Foswiki::LoginManager::ApacheLogin::BEGIN@28 which was called: # once (4µs+0s) by Foswiki::LoginManager::makeLoginManager at line 28
use Foswiki::LoginManager ();
# spent 4µs making 1 call to Foswiki::LoginManager::ApacheLogin::BEGIN@28
2918µsour @ISA = ('Foswiki::LoginManager');
30
31
# spent 4µs within Foswiki::LoginManager::ApacheLogin::BEGIN@31 which was called: # once (4µs+0s) by Foswiki::LoginManager::makeLoginManager at line 36
BEGIN {
3215µs if ( $Foswiki::cfg{UseLocale} ) {
33 require locale;
34 import locale();
35 }
361384µs14µs}
# spent 4µs making 1 call to Foswiki::LoginManager::ApacheLogin::BEGIN@31
37
38=begin TML
39
40---++ ClassMethod new ($session)
41
42Construct the ApacheLogin object
43
44=cut
45
46
# spent 117µs (28+89) within Foswiki::LoginManager::ApacheLogin::new which was called: # once (28µs+89µs) by Foswiki::LoginManager::makeLoginManager at line 152 of /var/www/foswikidev/core/lib/Foswiki/LoginManager.pm
sub new {
471800ns my ( $class, $session ) = @_;
48116µs183µs my $this = $class->SUPER::new($session);
# spent 83µs making 1 call to Foswiki::LoginManager::new
49
5012µs14µs $session->enterContext('can_login');
# spent 4µs making 1 call to Foswiki::enterContext
51
52 # Can't logout, though
5328µs12µs
# spent 4µs within Foswiki::LoginManager::ApacheLogin::__ANON__[/var/www/foswikidev/core/lib/Foswiki/LoginManager/ApacheLogin.pm:53] which was called: # once (4µs+0s) by Foswiki::_expandMacroOnTopicRendering at line 3435 of /var/www/foswikidev/core/lib/Foswiki.pm
Foswiki::registerTagHandler( 'LOGOUT', sub { return '' } );
# spent 2µs making 1 call to Foswiki::registerTagHandler
5413µs return $this;
55}
56
57=begin TML
58
59---++ ObjectMethod forceAuthentication () -> boolean
60
61method called when authentication is required - redirects to (...|view)auth
62Triggered on auth fail
63
64=cut
65
66sub forceAuthentication {
67 my $this = shift;
68 my $session = $this->{session};
69 my $query = $session->{request};
70
71 # See if there is an 'auth' version
72 # of this script, may be a result of not being logged in.
73 my $newAction = $query->action() . 'auth';
74
75 if ( !$query->remote_user()
76 && exists $Foswiki::cfg{SwitchBoard}{$newAction} )
77 {
78
79 # Assemble the new URL using the host, the changed script name,
80 # and the path info.
81 my $url = $session->getScriptUrl( 1, $newAction );
82 if ( $query->path_info() ) {
83 $url .= '/'
84 unless $url =~ m#/$# || $query->path_info() =~ m#^/#;
85 $url .= $query->path_info();
86 }
87
88 # Redirect with passthrough so we don't lose the original query params
89 $session->redirect( $url, 1 );
90 return 1;
91 }
92 return 0;
93}
94
95=begin TML
96
97---++ ObjectMethod loginUrl () -> $loginUrl
98
99TODO: why is this not used internally? When is it called, and why
100Content of a login link
101
102=cut
103
104sub loginUrl {
105 my $this = shift;
106 my $session = $this->{session};
107 my $topic = $session->{topicName};
108 my $web = $session->{webName};
109 return $session->getScriptUrl( 0, 'logon', $web, $topic, @_ );
110}
111
112=begin TML
113
114---++ ObjectMethod login( $query, $session )
115
116this allows the login and logon cgi-scripts to use the same code.
117all a logon does, is re-direct to viewauth, and apache then figures out
118if it needs to challenge the user
119
120=cut
121
122sub login {
123 my ( $this, $query, $session ) = @_;
124
125 my $url =
126 $session->getScriptUrl( 0, 'viewauth', $session->{webName},
127 $session->{topicName}, t => time() );
128
129 $url .= ( ';' . $query->query_string() ) if $query->query_string();
130
131 $session->redirect( $url, 1 ); # with passthrough
132}
133
134=begin TML
135
136---++ ObjectMethod getUser () -> $authUser
137
138returns the userLogin if stored in the apache CGI query (ie session)
139
140=cut
141
142
# spent 15µs (11+4) within Foswiki::LoginManager::ApacheLogin::getUser which was called: # once (11µs+4µs) by Foswiki::LoginManager::loadSession at line 310 of /var/www/foswikidev/core/lib/Foswiki/LoginManager.pm
sub getUser {
1431300ns my $this = shift;
144
1451400ns my $query = $this->{session}->{request};
1461100ns my $authUser;
147
148 # Ignore remote user if we got here via an error
149 # Only useful with CGI engine & Apache webserver
15011µs unless ( ( $ENV{REDIRECT_STATUS} || 0 ) >= 400 ) {
15113µs13µs $authUser = $query->remote_user() if $query;
# spent 3µs making 1 call to Foswiki::Request::remoteUser
15212µs1700ns Foswiki::LoginManager::_trace( $this,
153 "apache getUser says " . ( $authUser || 'undef' ) );
154 }
15514µs return $authUser;
156}
157
15813µs1;
159__END__