← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:10 2015

Filename/var/www/foswiki11/lib/Foswiki/LoginManager/ApacheLogin.pm
StatementsExecuted 33 statements in 548µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11127µs120µsFoswiki::LoginManager::ApacheLogin::::newFoswiki::LoginManager::ApacheLogin::new
21122µs169µsFoswiki::LoginManager::ApacheLogin::::loginUrlFoswiki::LoginManager::ApacheLogin::loginUrl
11115µs28µsFoswiki::LoginManager::ApacheLogin::::BEGIN@24Foswiki::LoginManager::ApacheLogin::BEGIN@24
11111µs13µsFoswiki::LoginManager::ApacheLogin::::getUserFoswiki::LoginManager::ApacheLogin::getUser
11110µs15µsFoswiki::LoginManager::ApacheLogin::::BEGIN@25Foswiki::LoginManager::ApacheLogin::BEGIN@25
1119µs9µsFoswiki::LoginManager::ApacheLogin::::__ANON__[:46]Foswiki::LoginManager::ApacheLogin::__ANON__[:46]
1118µs22µsFoswiki::LoginManager::ApacheLogin::::BEGIN@26Foswiki::LoginManager::ApacheLogin::BEGIN@26
1114µs4µsFoswiki::LoginManager::ApacheLogin::::BEGIN@28Foswiki::LoginManager::ApacheLogin::BEGIN@28
0000s0sFoswiki::LoginManager::ApacheLogin::::forceAuthenticationFoswiki::LoginManager::ApacheLogin::forceAuthentication
0000s0sFoswiki::LoginManager::ApacheLogin::::loginFoswiki::LoginManager::ApacheLogin::login
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
24228µs241µs
# spent 28µs (15+13) within Foswiki::LoginManager::ApacheLogin::BEGIN@24 which was called: # once (15µs+13µs) by Foswiki::LoginManager::makeLoginManager at line 24
use strict;
# spent 28µs making 1 call to Foswiki::LoginManager::ApacheLogin::BEGIN@24 # spent 13µs making 1 call to strict::import
25228µs220µs
# spent 15µs (10+5) within Foswiki::LoginManager::ApacheLogin::BEGIN@25 which was called: # once (10µs+5µs) by Foswiki::LoginManager::makeLoginManager at line 25
use warnings;
# spent 15µs making 1 call to Foswiki::LoginManager::ApacheLogin::BEGIN@25 # spent 5µs making 1 call to warnings::import
26227µs236µs
# spent 22µs (8+14) within Foswiki::LoginManager::ApacheLogin::BEGIN@26 which was called: # once (8µs+14µs) by Foswiki::LoginManager::makeLoginManager at line 26
use Assert;
# spent 22µs making 1 call to Foswiki::LoginManager::ApacheLogin::BEGIN@26 # spent 14µs making 1 call to Assert::import
27
282388µ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
2917µsour @ISA = ('Foswiki::LoginManager');
30
31=begin TML
32
33---++ ClassMethod new ($session)
34
35Construct the ApacheLogin object
36
37=cut
38
39
# spent 120µs (27+94) within Foswiki::LoginManager::ApacheLogin::new which was called: # once (27µs+94µs) by Foswiki::LoginManager::makeLoginManager at line 136 of /var/www/foswiki11/lib/Foswiki/LoginManager.pm
sub new {
401800ns my ( $class, $session ) = @_;
41115µs188µs my $this = $class->SUPER::new($session);
# spent 88µs making 1 call to Foswiki::LoginManager::new
42
4312µs14µs $session->enterContext('can_login');
# spent 4µs making 1 call to Foswiki::enterContext
44
45 # Can't logout, though
46213µs12µs
# spent 9µs within Foswiki::LoginManager::ApacheLogin::__ANON__[/var/www/foswiki11/lib/Foswiki/LoginManager/ApacheLogin.pm:46] which was called: # once (9µs+0s) by Foswiki::_expandMacroOnTopicRendering at line 3160 of /var/www/foswiki11/lib/Foswiki.pm
Foswiki::registerTagHandler( 'LOGOUT', sub { return '' } );
# spent 2µs making 1 call to Foswiki::registerTagHandler
4713µs return $this;
48}
49
50=begin TML
51
52---++ ObjectMethod forceAuthentication () -> boolean
53
54method called when authentication is required - redirects to (...|view)auth
55Triggered on auth fail
56
57=cut
58
59sub forceAuthentication {
60 my $this = shift;
61 my $session = $this->{session};
62 my $query = $session->{request};
63
64 # See if there is an 'auth' version
65 # of this script, may be a result of not being logged in.
66 my $newAction = $query->action() . 'auth';
67
68 if ( !$query->remote_user()
69 && exists $Foswiki::cfg{SwitchBoard}{$newAction} )
70 {
71
72 # Assemble the new URL using the host, the changed script name,
73 # and the path info.
74 my $url = $session->getScriptUrl( 1, $newAction );
75 if ( $query->path_info() ) {
76 $url .= '/'
77 unless $url =~ m#/$# || $query->path_info() =~ m#^/#;
78 $url .= $query->path_info();
79 }
80
81 # Redirect with passthrough so we don't lose the original query params
82 $session->redirect( $url, 1 );
83 return 1;
84 }
85 return 0;
86}
87
88=begin TML
89
90---++ ObjectMethod loginUrl () -> $loginUrl
91
92TODO: why is this not used internally? When is it called, and why
93Content of a login link
94
95=cut
96
97
# spent 169µs (22+147) within Foswiki::LoginManager::ApacheLogin::loginUrl which was called 2 times, avg 85µs/call: # 2 times (22µs+147µs) by Foswiki::LoginManager::_LOGIN at line 1154 of /var/www/foswiki11/lib/Foswiki/LoginManager.pm, avg 85µs/call
sub loginUrl {
9821µs my $this = shift;
9922µs my $session = $this->{session};
10022µs my $topic = $session->{topicName};
10121µs my $web = $session->{webName};
102217µs2147µs return $session->getScriptUrl( 0, 'logon', $web, $topic, @_ );
# spent 147µs making 2 calls to Foswiki::getScriptUrl, avg 74µs/call
103}
104
105=begin TML
106
107---++ ObjectMethod login( $query, $session )
108
109this allows the login and logon cgi-scripts to use the same code.
110all a logon does, is re-direct to viewauth, and apache then figures out
111if it needs to challenge the user
112
113=cut
114
115sub login {
116 my ( $this, $query, $session ) = @_;
117
118 my $url =
119 $session->getScriptUrl( 0, 'viewauth', $session->{webName},
120 $session->{topicName}, t => time() );
121
122 $url .= ( ';' . $query->query_string() ) if $query->query_string();
123
124 $session->redirect( $url, 1 ); # with passthrough
125}
126
127=begin TML
128
129---++ ObjectMethod getUser () -> $authUser
130
131returns the userLogin if stored in the apache CGI query (ie session)
132
133=cut
134
135
# spent 13µs (11+3) within Foswiki::LoginManager::ApacheLogin::getUser which was called: # once (11µs+3µs) by Foswiki::LoginManager::loadSession at line 296 of /var/www/foswiki11/lib/Foswiki/LoginManager.pm
sub getUser {
1361300ns my $this = shift;
137
1381500ns my $query = $this->{session}->{request};
1391100ns my $authUser;
140
141 # Ignore remote user if we got here via an error
142 # Only useful with CGI engine & Apache webserver
14311µs unless ( ( $ENV{REDIRECT_STATUS} || 0 ) >= 400 ) {
14412µs12µs $authUser = $query->remote_user() if $query;
# spent 2µs making 1 call to Foswiki::Request::remoteUser
14512µs1700ns Foswiki::LoginManager::_trace( $this,
146 "apache getUser says " . ( $authUser || 'undef' ) );
147 }
14813µs return $authUser;
149}
150
15113µs1;
152__END__